* gcc.c-torture/execute/20041112-1.c: New test.
authorEric Botcazou <ebotcazou@act-europe.fr>
Fri, 12 Nov 2004 09:03:03 +0000 (10:03 +0100)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Fri, 12 Nov 2004 09:03:03 +0000 (09:03 +0000)
From-SVN: r90522

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20041112-1.c [new file with mode: 0644]

index 874213559769012fdd1559988b4216e83ece92c6..f04c8abaf5a0019c220a263518766d17db832a2b 100644 (file)
@@ -1,3 +1,7 @@
+2004-11-12  Eric Botcazou  <ebotcazou@act-europe.fr>
+
+       * gcc.c-torture/execute/20041112-1.c: New test.
+
 2004-11-11  Janis Johnson  <janis187@us.ibm.com>
 
        * lib/gcc-dg.exp (dg-target-list): New.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20041112-1.c b/gcc/testsuite/gcc.c-torture/execute/20041112-1.c
new file mode 100644 (file)
index 0000000..0c6251c
--- /dev/null
@@ -0,0 +1,40 @@
+/* This was failing on Alpha because the comparison (p != -1) was rewritten
+   as (p+1 != 0) and p+1 isn't allowed to wrap for pointers.  */
+
+extern void abort(void);
+
+typedef __SIZE_TYPE__ size_t;
+
+int global;
+
+static void *foo(int p)
+{
+  if (p == 0)
+   {
+      global++;
+      return &global;
+   }
+
+  return (void *)(size_t)-1;
+}
+
+int bar(void)
+{
+  void *p;
+
+  p = foo(global);
+  if (p != (void *)(size_t)-1)
+    return 1;
+
+  global++;
+  return 0;
+}
+
+int main(void)
+{
+  global = 1;
+  if (bar () != 0)
+    abort();
+  
+  return 0;
+}