From: Martin Sebor Date: Fri, 30 Jul 2021 17:41:02 +0000 (-0600) Subject: Move failed part of a test to a new file [PR101671] X-Git-Tag: basepoints/gcc-13~5679 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b3560d3a9f2b55ba4807f2b0f8cbbf6cee9e6e3;p=thirdparty%2Fgcc.git Move failed part of a test to a new file [PR101671] 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. --- diff --git a/gcc/testsuite/gcc.c-torture/compile/pr83510.c b/gcc/testsuite/gcc.c-torture/compile/pr83510.c index fc932e57f3ae..7f222fa9bdb5 100644 --- a/gcc/testsuite/gcc.c-torture/compile/pr83510.c +++ b/gcc/testsuite/gcc.c-torture/compile/pr83510.c @@ -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 index 000000000000..a49874df5da4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Warray-bounds-87.c @@ -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)); + } +}