bug fix for c-torture test execute/bf-sign-2.c

Joern Rennecke amylaar@cygnus.co.uk
Wed Oct 22 06:54:00 GMT 1997


execute/bf-sign-2.c currently fails for targets with 16 bit ints.
Here is a fix:

Wed Oct 22 14:08:50 1997 J"orn Rennecke <amylaar@cygnus.co.uk>

	* execute/bf-sign-2.c (struct X): New member u15.
	(main): Check u15.  Check for u31 depends on size of int.

Index: testsuite/gcc.c-torture/execute/bf-sign-2.c
===================================================================
RCS file: /cvs/cvsfiles/egcs/gcc/testsuite/gcc.c-torture/execute/bf-sign-2.c,v
retrieving revision 1.1.1.1
diff -p -r1.1.1.1 bf-sign-2.c
*** bf-sign-2.c	1997/08/19 07:36:07	1.1.1.1
--- bf-sign-2.c	1997/10/22 13:09:46
***************
*** 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 ();



More information about the Gcc mailing list