]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
analyzer: add more uninit test coverage
authorDavid Malcolm <dmalcolm@redhat.com>
Wed, 15 Jun 2022 21:39:42 +0000 (17:39 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 15 Jun 2022 21:39:42 +0000 (17:39 -0400)
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>
gcc/testsuite/gcc.dg/analyzer/uninit-1.c

index 9a6576e1b0aa5fe00ef78ab27069673d005915b3..3d1021658bc469b2159aea156e85f340cdaba8c2 100644 (file)
@@ -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'" } */
+}