(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
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;
}
}
-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;
--- /dev/null
+/* 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));
+ }
+}