Patchwork Fix PR50067

login
register
mail settings
Submitter Richard Guenther
Date Aug. 22, 2011, 10:25 a.m.
Message ID <alpine.LNX.2.00.1108221225240.2130@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/110896/
State New
Headers show

Comments

Richard Guenther - Aug. 22, 2011, 10:25 a.m.
Applied.

Richard.

2011-08-22  Richard Guenther  <rguenther@suse.de>

	PR testsuite/50145
	* gcc.dg/torture/pr50067-1.c: Run on little-endian systems only.
	* gcc.dg/torture/pr50067-2.c: Likewise.

Patch

Index: gcc/testsuite/gcc.dg/torture/pr50067-1.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr50067-1.c	(revision 177949)
+++ gcc/testsuite/gcc.dg/torture/pr50067-1.c	(working copy)
@@ -9,10 +9,15 @@  short a[32] = { 0, 1, 2, 3, 4, 5, 6, 7,
 short b[32] = { 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, };
 int main()
 {
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
   int i;
-  for (i = 0; i < 32; ++i)
-    (*((unsigned short(*)[32])&a[0]))[i] = (*((char(*)[32])&a[0]))[i+8];
-  if (memcmp (&a, &b, sizeof (a)) != 0)
-    abort ();
+  if (sizeof (short) == 2)
+    {
+      for (i = 0; i < 32; ++i)
+	(*((unsigned short(*)[32])&a[0]))[i] = (*((char(*)[32])&a[0]))[i+8];
+      if (memcmp (&a, &b, sizeof (a)) != 0)
+	abort ();
+    }
+#endif
   return 0;
 }
Index: gcc/testsuite/gcc.dg/torture/pr50067-2.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr50067-2.c	(revision 177949)
+++ gcc/testsuite/gcc.dg/torture/pr50067-2.c	(working copy)
@@ -9,12 +9,17 @@  short a[32] = { 0, 1, 2, 3, 4, 5, 6, 7,
 short b[32] = { 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, };
 int main()
 {
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
   int i;
-  for (i = 0; i < 32; ++i)
+  if (sizeof (short) == 2)
     {
-      a[i] = (*((char(*)[32])&a[0]))[i+8];
+      for (i = 0; i < 32; ++i)
+	{
+	  a[i] = (*((char(*)[32])&a[0]))[i+8];
+	}
+      if (memcmp (&a, &b, sizeof (a)) != 0)
+	abort ();
     }
-  if (memcmp (&a, &b, sizeof (a)) != 0)
-    abort ();
+#endif
   return 0;
 }