This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
execute/bf-sign-2.c (struct X): Add u15 field...
- To: egcs-patches at egcs dot cygnus dot com
- Subject: execute/bf-sign-2.c (struct X): Add u15 field...
- From: Jim Wilson <wilson at cygnus dot com>
- Date: Fri, 12 Mar 1999 16:23:10 -0800
I have checked in this patch.
The bf-sign-2.c test fails for targets with 16 bit ints. The patch fixes
this.
Two testcases, 970312-1.c and 980605-1.c, call printf, but some embedded
targets don't support console I/O. I changed the printf calls to sprintf
to fix this.
Fri Mar 12 16:17:28 1999 Jim Wilson <wilson@cygnus.com>
* execute/970312-1.c, execute/980605-1.c (f): Change printf to sprintf.
* execute/bf-sign-2.c (struct X): Add u15 field.
(main): Add check for u15. Conditionalize u31 check depending on
whether ints are <32 bits or >=32 bits.
Index: 970312-1.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/testsuite/gcc.c-torture/execute/970312-1.c,v
retrieving revision 1.2
diff -p -r1.2 970312-1.c
*** 970312-1.c 1998/12/16 22:14:36 1.2
--- 970312-1.c 1999/03/13 00:16:50
*************** getval (void)
*** 41,46 ****
--- 41,48 ----
return x++;
}
+ char buf[10];
+
void
f ()
{
*************** f ()
*** 59,65 ****
k = f2 (17.0);
! printf ("%d\n", a + b + c + d + e + f + g + h + i + j + k);
if (a + b + c + d + e + f + g + h + i + j + k != 227)
abort ();
}
--- 61,67 ----
k = f2 (17.0);
! sprintf (buf, "%d\n", a + b + c + d + e + f + g + h + i + j + k);
if (a + b + c + d + e + f + g + h + i + j + k != 227)
abort ();
}
Index: 980605-1.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/testsuite/gcc.c-torture/execute/980605-1.c,v
retrieving revision 1.2
diff -p -r1.2 980605-1.c
*** 980605-1.c 1998/12/16 22:14:53 1.2
--- 980605-1.c 1999/03/13 00:16:50
*************** getval (void)
*** 45,50 ****
--- 45,52 ----
return x++;
}
+ char buf[10];
+
void
f ()
{
*************** f ()
*** 64,70 ****
k = f2 (17.0);
! printf ("%d\n", a + b + c + d + e + f + g + h + i + j + k);
if (a + b + c + d + e + f + g + h + i + j + k != 227)
abort ();
}
--- 66,72 ----
k = f2 (17.0);
! sprintf (buf, "%d\n", a + b + c + d + e + f + g + h + i + j + k);
if (a + b + c + d + e + f + g + h + i + j + k != 227)
abort ();
}
Index: bf-sign-2.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/testsuite/gcc.c-torture/execute/bf-sign-2.c,v
retrieving revision 1.2
diff -p -r1.2 bf-sign-2.c
*** bf-sign-2.c 1998/12/16 22:15:17 1.2
--- bf-sign-2.c 1999/03/13 00:16:50
***************
*** 10,16 ****
We test the behavior by subtracting two from the promoted value: this will
result in a negitive value for signed types, a positive value for unsigned
types. This test (of course) assumes that the compiler is correctly
! implementing signed and unsigned arithmatic.
*/
struct X {
--- 10,16 ----
We test the behavior by subtracting two from the promoted value: this will
result in a negitive value for signed types, a positive value for unsigned
types. This test (of course) assumes that the compiler is correctly
! implementing signed and unsigned arithmetic.
*/
struct X {
*************** struct X {
*** 21,26 ****
--- 21,27 ----
unsigned long int u32:32;
unsigned long long ull3 :3;
unsigned long long ull35:35;
+ unsigned u15:15;
};
struct X x;
*************** main ()
*** 36,43 ****
if ((x.s32 - 2) >= 0) /* promoted value should be signed */
abort ();
! if ((x.u31 - 2) >= 0) /* promoted value should be signed */
abort ();
if ((x.u32 - 2) < 0) /* promoted value should be UNsigned */
abort ();
--- 37,55 ----
if ((x.s32 - 2) >= 0) /* promoted value should be signed */
abort ();
! if ((x.u15 - 2) >= 0) /* promoted value should be signed */
abort ();
+
+ if (sizeof (struct { unsigned long u32:32;}) <= sizeof (int))
+ {
+ if ((x.u31 - 2) >= 0) /* promoted value should be signed */
+ abort ();
+ }
+ else
+ {
+ if ((x.u31 - 2) < 0) /* promoted value should be UNsigned */
+ abort ();
+ }
if ((x.u32 - 2) < 0) /* promoted value should be UNsigned */
abort ();