* [committed] analyzer: add more uninit test coverage
@ 2022-06-15 21:49 David Malcolm
0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2022-06-15 21:49 UTC (permalink / raw)
To: gcc-patches
Tested on x86_64-pc-linux-gnu.
Pushed to trunk as r13-1116-g44681d45473883.
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 | 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'" } */
+}
--
2.26.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-15 21:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-15 21:49 [committed] analyzer: add more uninit test coverage David Malcolm
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).