diff options
author | Martin Sebor <msebor@redhat.com> | 2021-05-13 16:05:50 -0600 |
---|---|---|
committer | Martin Sebor <msebor@redhat.com> | 2021-05-13 16:06:51 -0600 |
commit | 2efe245bb88bf4574e322ef7e6d2df83d9e13237 (patch) | |
tree | a6d0bbec49a776bda1dfb729d6a6a2290a73e57a /gcc/tree-ssa-uninit.c | |
parent | ca9bb74a5f856ccdceb4797f18b0a4ac8f49d069 (diff) | |
download | gcc-2efe245bb88bf4574e322ef7e6d2df83d9e13237.zip gcc-2efe245bb88bf4574e322ef7e6d2df83d9e13237.tar.gz gcc-2efe245bb88bf4574e322ef7e6d2df83d9e13237.tar.bz2 |
Avoid -Wuninitialized false negatives with sanitization and VLAs.
Resolves:
PR tree-optimization/93100 - gcc -fsanitize=address inhibits -Wuninitialized
PR middle-end/98583 - missing -Wuninitialized reading from a second VLA in its own block
gcc/ChangeLog:
PR tree-optimization/93100
PR middle-end/98583
* tree-ssa-uninit.c (check_defs): Exclude intrinsic functions that
don't modify referenced objects.
gcc/testsuite/ChangeLog:
PR tree-optimization/93100
PR middle-end/98583
* g++.dg/warn/uninit-pr93100.C: New test.
* gcc.dg/uninit-pr93100.c: New test.
* gcc.dg/uninit-pr98583.c: New test.
Diffstat (limited to 'gcc/tree-ssa-uninit.c')
-rw-r--r-- | gcc/tree-ssa-uninit.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c index 0800f59..f55ce19 100644 --- a/gcc/tree-ssa-uninit.c +++ b/gcc/tree-ssa-uninit.c @@ -209,6 +209,16 @@ check_defs (ao_ref *ref, tree vdef, void *data_) { check_defs_data *data = (check_defs_data *)data_; gimple *def_stmt = SSA_NAME_DEF_STMT (vdef); + + /* The ASAN_MARK intrinsic doesn't modify the variable. */ + if (is_gimple_call (def_stmt) + && gimple_call_internal_p (def_stmt, IFN_ASAN_MARK)) + return false; + + /* End of VLA scope is not a kill. */ + if (gimple_call_builtin_p (def_stmt, BUILT_IN_STACK_RESTORE)) + return false; + /* If this is a clobber then if it is not a kill walk past it. */ if (gimple_clobber_p (def_stmt)) { @@ -216,6 +226,7 @@ check_defs (ao_ref *ref, tree vdef, void *data_) return true; return false; } + /* Found a may-def on this path. */ data->found_may_defs = true; return true; |