From: Martin Sebor Date: Tue, 6 Aug 2019 00:30:02 +0000 (+0000) Subject: PR middle-end/50476 - Warn of pointer set to object whose lifetime is limited X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5e74e93c1ceb71116ae2cd8c092c969368d1cc8c;p=gcc.git 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 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4b871aaa9a4..a4af533613a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2019-08-05 Martin Sebor + 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 00000000000..db4146db314 --- /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" } +}