aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2022-06-15 17:39:42 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2022-06-15 17:39:42 -0400
commit44681d454738837ec04752f2d1189a9a47ddf22d (patch)
tree7d60e21760b59ab0790211d6465e18bf9e222d24 /gcc
parent90f2a111413a6d4264335046d68ffa19725864b6 (diff)
downloadgcc-44681d454738837ec04752f2d1189a9a47ddf22d.zip
gcc-44681d454738837ec04752f2d1189a9a47ddf22d.tar.gz
gcc-44681d454738837ec04752f2d1189a9a47ddf22d.tar.bz2
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>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/uninit-1.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/analyzer/uninit-1.c b/gcc/testsuite/gcc.dg/analyzer/uninit-1.c
index 9a6576e..3d10216 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'" } */
+}