Add new test for PR65178.
authorMartin Sebor <msebor@redhat.com>
Thu, 22 Jul 2021 17:49:33 +0000 (11:49 -0600)
committerMartin Sebor <msebor@redhat.com>
Thu, 22 Jul 2021 17:51:26 +0000 (11:51 -0600)
gcc/testsuite/ChangeLog:
PR tree-optimization/65178
* gcc.dg/uninit-pr65178.c: New test.

gcc/testsuite/gcc.dg/uninit-pr65178.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.dg/uninit-pr65178.c b/gcc/testsuite/gcc.dg/uninit-pr65178.c
new file mode 100644 (file)
index 0000000..21eb354
--- /dev/null
@@ -0,0 +1,21 @@
+/* PR  tree-optimizatiom/65178 - incorrect -Wmaybe-uninitialized when using
+   nested loops
+   { dg-do compile }
+   { dg-options "-O2 -Wall" } */
+
+void *bar (int);
+
+char *foo (void)
+{
+  char *c = "bla";
+  char *buf;
+  for (int a = 1;; a = 0)
+    {
+      for (char *s = c; *s; ++s)
+        {
+        }
+      if (!a) break;
+      buf = (char *) bar (1);
+    }
+  return buf;       // { dg-bogus "\\\[-Wmaybe-uninitialized" }
+}