So it turns out the xfail uninit-pred-7_a.c didn't always happen
depending on the setting of logical-op-non-short-circuit.
So this creates a second copy of the testcase for the case
of `logical-op-non-short-circuit=0` without the xfail and then sets
`logical-op-non-short-circuit=1` for uninit-pred-7_a.c with still
the xfail.
Tested on x86_64-linux-gnu to make sure both pass and uninit-pred-7_a.c
xfails like it should. Also tested manually on powerpc64-linux-gnu to
see the bogus warning happen with logical-op-non-short-circuit=1.
PR testsuite/123377
gcc/testsuite/ChangeLog:
* gcc.dg/uninit-pred-7_a.c: Add
`--param logical-op-non-short-circuit=1` to the options.
* gcc.dg/uninit-pred-7_a_a.c: New test.
Signed-off-by: Andrew Pinski <[email protected]>
---
gcc/testsuite/gcc.dg/uninit-pred-7_a.c | 3 +-
gcc/testsuite/gcc.dg/uninit-pred-7_a_a.c | 53 ++++++++++++++++++++++++
2 files changed, 54 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/uninit-pred-7_a_a.c
diff --git a/gcc/testsuite/gcc.dg/uninit-pred-7_a.c
b/gcc/testsuite/gcc.dg/uninit-pred-7_a.c
index 7aaadf7def7..5dd92176c8f 100644
--- a/gcc/testsuite/gcc.dg/uninit-pred-7_a.c
+++ b/gcc/testsuite/gcc.dg/uninit-pred-7_a.c
@@ -1,6 +1,5 @@
-
/* { dg-do compile } */
-/* { dg-options "-Wuninitialized -O2" } */
+/* { dg-options "-Wuninitialized -O2 --param logical-op-non-short-circuit=1" }
*/
int g;
void bar();
diff --git a/gcc/testsuite/gcc.dg/uninit-pred-7_a_a.c
b/gcc/testsuite/gcc.dg/uninit-pred-7_a_a.c
new file mode 100644
index 00000000000..223f6747610
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pred-7_a_a.c
@@ -0,0 +1,53 @@
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized -O2 --param logical-op-non-short-circuit=0" }
*/
+
+int g;
+void bar();
+void blah(int);
+
+int foo (int n, int l, int m, int r)
+{
+ int v;
+
+ if (n || l)
+ v = r;
+
+ if (m) g++;
+ else bar();
+
+ if ( n && l)
+ blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */
+
+ if ( n )
+ blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */
+
+ if ( l )
+ blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */
+
+ return 0;
+}
+
+int foo_2 (int n, int l, int m, int r)
+{
+ int v;
+
+ if (n || l)
+ v = r;
+
+ if (m) g++;
+ else bar();
+
+ if ( n && l)
+ blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */
+
+ if ( n )
+ blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */
+
+ if (m || l)
+ blah (v); /* { dg-warning "uninitialized" "warning" } */
+
+ if ( l )
+ blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */
+
+ return 0;
+}
--
2.43.0