public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-1116] analyzer: add more uninit test coverage
Date: Wed, 15 Jun 2022 21:40:01 +0000 (GMT)	[thread overview]
Message-ID: <20220615214001.DB1BD3858288@sourceware.org> (raw)

https://gcc.gnu.org/g:44681d454738837ec04752f2d1189a9a47ddf22d

commit r13-1116-g44681d454738837ec04752f2d1189a9a47ddf22d
Author: David Malcolm <dmalcolm@redhat.com>
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 <dmalcolm@redhat.com>

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'" } */
+}


                 reply	other threads:[~2022-06-15 21:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220615214001.DB1BD3858288@sourceware.org \
    --to=dmalcolm@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).