From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2209) id DB1BD3858288; Wed, 15 Jun 2022 21:40:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DB1BD3858288 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: David Malcolm To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1116] analyzer: add more uninit test coverage X-Act-Checkin: gcc X-Git-Author: David Malcolm X-Git-Refname: refs/heads/master X-Git-Oldrev: 90f2a111413a6d4264335046d68ffa19725864b6 X-Git-Newrev: 44681d454738837ec04752f2d1189a9a47ddf22d Message-Id: <20220615214001.DB1BD3858288@sourceware.org> Date: Wed, 15 Jun 2022 21:40:01 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2022 21:40:02 -0000 https://gcc.gnu.org/g:44681d454738837ec04752f2d1189a9a47ddf22d commit r13-1116-g44681d454738837ec04752f2d1189a9a47ddf22d Author: David Malcolm Date: Wed Jun 15 17:39:42 2022 -0400 analyzer: add more uninit test coverage gcc/testsuite/ChangeLog: * gcc.dg/analyzer/uninit-1.c: Add test coverage of attempts to jump through an uninitialized function pointer, and of attempts to pass an uninitialized value to a function call. Signed-off-by: David Malcolm Diff: --- gcc/testsuite/gcc.dg/analyzer/uninit-1.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gcc/testsuite/gcc.dg/analyzer/uninit-1.c b/gcc/testsuite/gcc.dg/analyzer/uninit-1.c index 9a6576e1b0a..3d1021658bc 100644 --- a/gcc/testsuite/gcc.dg/analyzer/uninit-1.c +++ b/gcc/testsuite/gcc.dg/analyzer/uninit-1.c @@ -127,3 +127,22 @@ size_t test_builtin_strlen (void) const char *ptr; /* { dg-message "region created on stack here" } */ return __builtin_strlen (ptr); /* { dg-warning "use of uninitialized value 'ptr'" } */ } + +void test_calling_uninit_fn_ptr_1 (void) +{ + void (*fn_ptr) (void); /* { dg-message "region created on stack here" } */ + fn_ptr (); /* { dg-warning "use of uninitialized value 'fn_ptr'" } */ +} + +int test_calling_uninit_fn_ptr_2 (void) +{ + int (*fn_ptr) (void); /* { dg-message "region created on stack here" } */ + return fn_ptr (); /* { dg-warning "use of uninitialized value 'fn_ptr'" } */ +} + +extern void called_by_uninit_arg (int); +void test_passing_uninit_arg (void) +{ + int i; /* { dg-message "region created on stack here" } */ + called_by_uninit_arg (i); /* { dg-warning "use of uninitialized value 'i'" } */ +}