* gcc.dg/pr36227.c: Correct test for targets where long is not the same size as pointer.
authorAndy Hutchinson <hutchinsonandy@aim.com>
Wed, 2 Jul 2008 22:24:18 +0000 (22:24 +0000)
committerAndy Hutchinson <hutchinsonandy@gcc.gnu.org>
Wed, 2 Jul 2008 22:24:18 +0000 (22:24 +0000)
From-SVN: r137395

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr36227.c

index d7ef19ff58b7bff5151a5247d95e633b3e315df8..6cf1443fb6ff7145889f5af3ee50fada34512803 100644 (file)
@@ -1,3 +1,8 @@
+2008-07-02  Andy Hutchinson  <hutchinsonandy@aim.com>
+
+       * gcc.dg/pr36227.c: Correct test for targets where long is
+       not the same size as pointer.
+
 2008-07-02  Kaz Kojima  <kkojima@gcc.gnu.org>
 
        * g++.dg/cdce3.C: Test long double math functions for
index d6657632b91f365246218ab2495ffc64d9de7229..27fe00155059326e0cfab063ab6e2c3bf332d95d 100644 (file)
@@ -1,12 +1,22 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -Wstrict-overflow=3" } */
+#if (__SIZEOF_LONG_LONG__ == __SIZEOF_POINTER__)
+typedef unsigned long long ptrcast;
+#elif (__SIZEOF_LONG__ == __SIZEOF_POINTER__)
+typedef unsigned long ptrcast;
+#elif (__SIZEOF_INT__ == __SIZEOF_POINTER__)
+typedef unsigned int ptrcast;
+#else
+#error Add target support here
+#endif
 
 volatile unsigned long *
 sat_add(volatile unsigned long *ptr, unsigned long i, volatile unsigned long *end)
 {
-  if ((unsigned long)ptr + i * sizeof(*ptr) > (unsigned long)ptr) /* { dg-bogus "pointer wraparound" } */
+  if ((ptrcast)ptr + i * sizeof(*ptr) > (ptrcast)ptr) /* { dg-bogus "pointer wraparound" } */
     return ptr + i;
   else
     return end;
 }
 
+