aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2021-07-30 11:41:02 -0600
committerMartin Sebor <msebor@redhat.com>2021-07-30 11:44:09 -0600
commit0b3560d3a9f2b55ba4807f2b0f8cbbf6cee9e6e3 (patch)
tree4e96674961a934faf161c2c1eb6cad344146f348 /gcc
parente5e164effa30fd2b5c5bc3e6883d63889e96d8da (diff)
downloadgcc-0b3560d3a9f2b55ba4807f2b0f8cbbf6cee9e6e3.zip
gcc-0b3560d3a9f2b55ba4807f2b0f8cbbf6cee9e6e3.tar.gz
gcc-0b3560d3a9f2b55ba4807f2b0f8cbbf6cee9e6e3.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr83510.c25
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-87.c48
2 files changed, 48 insertions, 25 deletions
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr83510.c b/gcc/testsuite/gcc.c-torture/compile/pr83510.c
index fc932e5..7f222fa 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 0000000..a49874d
--- /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));
+ }
+}