Patchwork [testsuite] Fix pr35634 tests when char is unsigned.

login
register
mail settings
Submitter Steve Ellcey
Date Dec. 10, 2012, 6:32 p.m.
Message ID <94beee57-1486-4617-b0dd-b4f8af4a4c1d@EXCHHUB01.MIPS.com>
Download mbox | patch
Permalink /patch/205008/
State New
Headers show

Comments

Steve Ellcey - Dec. 10, 2012, 6:32 p.m.
The tests gcc.dg/torture/pr35634.c and g++.dg/torture/pr35634.C fail for
me on the mips-mti-elf target.  At first I thought it was because 'n'
was not initialized but then I realized it was because 'char' on this
target defaults to 'unsigned char', not 'signed char'.  Since I think
initializing 'n' is still a good idea I made that change as well as making
'c' an explicitly signed char.  This now passes on mips-mti-elf.

OK for checkin?

Steve Ellcey
sellcey@mips.com


2012-12-10  Steve Ellcey  <sellcey@mips.com>

	* gcc.dg/torture/pr35634.c: Initialize n, make c signed.
	* g++.dg/torgure/pr35634.C: Ditto.
Richard Guenther - Dec. 10, 2012, 7:01 p.m.
On Mon, Dec 10, 2012 at 7:32 PM, Steve Ellcey <sellcey@mips.com> wrote:
> The tests gcc.dg/torture/pr35634.c and g++.dg/torture/pr35634.C fail for
> me on the mips-mti-elf target.  At first I thought it was because 'n'
> was not initialized but then I realized it was because 'char' on this
> target defaults to 'unsigned char', not 'signed char'.  Since I think
> initializing 'n' is still a good idea I made that change as well as making
> 'c' an explicitly signed char.  This now passes on mips-mti-elf.

statics are zero-initialized according to C89.

> OK for checkin?

Ok minus the initialization.

Thanks,
Richard.

> Steve Ellcey
> sellcey@mips.com
>
>
> 2012-12-10  Steve Ellcey  <sellcey@mips.com>
>
>         * gcc.dg/torture/pr35634.c: Initialize n, make c signed.
>         * g++.dg/torgure/pr35634.C: Ditto.
>
> diff --git a/gcc/testsuite/g++.dg/torture/pr35634.C b/gcc/testsuite/g++.dg/torture/pr35634.C
> index 00848e3..1f03bb1 100644
> --- a/gcc/testsuite/g++.dg/torture/pr35634.C
> +++ b/gcc/testsuite/g++.dg/torture/pr35634.C
> @@ -5,7 +5,7 @@ extern "C" void exit (int);
>
>  void foo (int i)
>  {
> -    static int n;
> +    static int n = 0;
>      if (i < -128 || i > 127)
>          abort ();
>      if (++n > 1000)
> @@ -14,6 +14,6 @@ void foo (int i)
>
>  int main ()
>  {
> -    char c;
> +    signed char c;
>      for (c = 0; ; c++) foo (c);
>  }
> diff --git a/gcc/testsuite/gcc.dg/torture/pr35634.c b/gcc/testsuite/gcc.dg/torture/pr35634.c
> index 32df7d4..f8876a4 100644
> --- a/gcc/testsuite/gcc.dg/torture/pr35634.c
> +++ b/gcc/testsuite/gcc.dg/torture/pr35634.c
> @@ -5,7 +5,7 @@ void exit (int);
>
>  void foo (int i)
>  {
> -    static int n;
> +    static int n = 0;
>      if (i < -128 || i > 127)
>          abort ();
>      if (++n > 1000)
> @@ -14,6 +14,6 @@ void foo (int i)
>
>  int main ()
>  {
> -    char c;
> +    signed char c;
>      for (c = 0; ; c++) foo (c);
>  }
Steve Ellcey - Dec. 10, 2012, 7:21 p.m.
On Mon, 2012-12-10 at 20:01 +0100, Richard Biener wrote:

> 
> Ok minus the initialization.
> 
> Thanks,
> Richard.

Actually, it looks like you already fixed this last week.  I am not
seeing it in my git tree, but it is in the FSF subversion and
git trees so I think I have a local problem updating my tree.

Steve Ellcey
sellcey@mips.com

Patch

diff --git a/gcc/testsuite/g++.dg/torture/pr35634.C b/gcc/testsuite/g++.dg/torture/pr35634.C
index 00848e3..1f03bb1 100644
--- a/gcc/testsuite/g++.dg/torture/pr35634.C
+++ b/gcc/testsuite/g++.dg/torture/pr35634.C
@@ -5,7 +5,7 @@  extern "C" void exit (int);
 
 void foo (int i)
 {
-    static int n;
+    static int n = 0;
     if (i < -128 || i > 127)
         abort ();
     if (++n > 1000)
@@ -14,6 +14,6 @@  void foo (int i)
 
 int main ()
 {
-    char c;
+    signed char c;
     for (c = 0; ; c++) foo (c);
 }
diff --git a/gcc/testsuite/gcc.dg/torture/pr35634.c b/gcc/testsuite/gcc.dg/torture/pr35634.c
index 32df7d4..f8876a4 100644
--- a/gcc/testsuite/gcc.dg/torture/pr35634.c
+++ b/gcc/testsuite/gcc.dg/torture/pr35634.c
@@ -5,7 +5,7 @@  void exit (int);
 
 void foo (int i)
 {
-    static int n;
+    static int n = 0;
     if (i < -128 || i > 127)
         abort ();
     if (++n > 1000)
@@ -14,6 +14,6 @@  void foo (int i)
 
 int main ()
 {
-    char c;
+    signed char c;
     for (c = 0; ; c++) foo (c);
 }