]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Move failed part of a test to a new file [PR101671]
authorMartin Sebor <msebor@redhat.com>
Fri, 30 Jul 2021 17:41:02 +0000 (11:41 -0600)
committerMartin Sebor <msebor@redhat.com>
Fri, 30 Jul 2021 17:44:09 +0000 (11:44 -0600)
Related:
PR middle-end/101671 - pr83510 fails with -Os because threader confuses -Warray-bounds

gcc/testsuite:
PR middle-end/101671
* gcc.c-torture/compile/pr83510.c: Move test functions...
* gcc.dg/Warray-bounds-87.c: ...to this file.

gcc/testsuite/gcc.c-torture/compile/pr83510.c
gcc/testsuite/gcc.dg/Warray-bounds-87.c [new file with mode: 0644]

index fc932e57f3ae55ab31b8c3cdce9a2a06b21190b6..7f222fa9bdb5b803fa10aefe72bc6db6425e0119 100644 (file)
@@ -3,8 +3,6 @@
    (PR tree-optimization/83510).  */
 
 /* { dg-options "-Warray-bounds" } */
-/* { dg-xfail-if "" { "*-*-*" } { "-Os" } } */
-
 
 /*  This test is XFAILed because thread1 threads a switch statement
     such that the various cases have been split into different
@@ -70,19 +68,6 @@ int g(struct xyz * ctx) {
   return 0;
 }
 
-static unsigned int f_signed(struct xyz * ctx, int number)
-{
-  switch (number) {
-  case 0x9:
-    return ctx->a0;
-  case 0xA: case 0xB:
-  case 0xC: case 0xD: case 0xE: case 0xF:
-  case 0x10: case 0x11: case 0x12: case 0x13:
-    return arr[number];
-  }
-  return 0;
-}
-
 int g_signed(struct xyz * ctx) {
   int i;
 
@@ -103,16 +88,6 @@ void test_2 (struct xyz * ctx)
   }
 }
 
-void test_2_signed (struct xyz * ctx)
-{
-  int i;
-
-  for (i = 0; i < 10; i++) {
-    if (get_flag ())
-      wfm(ctx, i, f_signed(ctx, i));
-  }
-}
-
 void test_3 (struct xyz * ctx)
 {
   unsigned int i;
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-87.c b/gcc/testsuite/gcc.dg/Warray-bounds-87.c
new file mode 100644 (file)
index 0000000..a49874d
--- /dev/null
@@ -0,0 +1,48 @@
+/* PR middle-end/101671 - pr83510 fails with -Os because threader confuses
+   -Warray-bounds
+   { dg-do compile }
+   { dg-options "-Os -Wall" } */
+
+extern int f (void);
+extern void sink (unsigned int);
+
+unsigned int a[10];
+
+static unsigned int g (int i, int j)
+{
+  if (i == 9)
+    return j;
+  else if (i == 10)
+    return a[i];    // no warning here
+  return 0;
+}
+
+void test_g (int j)
+{
+  for (int i = 0; i < 10; i++)
+    {
+      if (f ())
+       sink (g (i, j));
+    }
+}
+
+static unsigned int h (int i, int j)
+{
+  switch (i)
+    {
+    case 9:
+      return j;
+    case 10:
+      return a[i];  // { dg-bogus "-Warray-bounds" "pr101671" { xfail *-*-* } }
+    }
+  return 0;
+}
+
+void test_h (int j)
+{
+  for (int i = 0; i < 10; i++)
+    {
+      if (f ())
+       sink (h (i, j));
+    }
+}