PR middle-end/50476 - Warn of pointer set to object whose lifetime is limited
authorMartin Sebor <msebor@redhat.com>
Tue, 6 Aug 2019 00:30:02 +0000 (00:30 +0000)
committerMartin Sebor <msebor@gcc.gnu.org>
Tue, 6 Aug 2019 00:30:02 +0000 (18:30 -0600)
gcc/testsuite/ChangeLog:
* gcc.dg/uninit-pr50476.c: New test.

From-SVN: r274135

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

index 4b871aaa9a42e8f51b4087479332726418169b2b..a4af533613a96af485e9a8c731055ed7abeea521 100644 (file)
@@ -1,5 +1,8 @@
 2019-08-05  Martin Sebor  <msebor@redhat.com>
 
+       PR middle-end/50476
+       * gcc.dg/uninit-pr50476.c: New test.
+
        PR c++/60517
        * g++.dg/pr60517.C: New test.
 
diff --git a/gcc/testsuite/gcc.dg/uninit-pr50476.c b/gcc/testsuite/gcc.dg/uninit-pr50476.c
new file mode 100644 (file)
index 0000000..db4146d
--- /dev/null
@@ -0,0 +1,18 @@
+/* PR middle-end/50476 - Warn of pointer set to object whose lifetime is limited
+   { dg-do compile }
+   { dg-options "-O1 -Wall" } */
+
+int *x = 0;
+
+void f (void)
+{
+  int y = 1;
+  x = &y;
+}
+
+int g (void)
+{
+  f ();
+
+  return *x;    // { dg-warning "\\\[-Wuninitialized" }
+}