aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2019-08-06 00:30:02 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2019-08-05 18:30:02 -0600
commit5e74e93c1ceb71116ae2cd8c092c969368d1cc8c (patch)
tree08093869c307244072997f71ca399850ff35198e
parent57771366f30028af9de32a14f481283cc717c57b (diff)
downloadgcc-5e74e93c1ceb71116ae2cd8c092c969368d1cc8c.zip
gcc-5e74e93c1ceb71116ae2cd8c092c969368d1cc8c.tar.gz
gcc-5e74e93c1ceb71116ae2cd8c092c969368d1cc8c.tar.bz2
PR middle-end/50476 - Warn of pointer set to object whose lifetime is limited
gcc/testsuite/ChangeLog: * gcc.dg/uninit-pr50476.c: New test. From-SVN: r274135
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/gcc.dg/uninit-pr50476.c18
2 files changed, 21 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4b871aa..a4af533 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..db4146d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr50476.c
@@ -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" }
+}