diff options
author | Martin Sebor <msebor@redhat.com> | 2021-07-20 13:08:39 -0600 |
---|---|---|
committer | Martin Sebor <msebor@redhat.com> | 2021-07-20 13:10:11 -0600 |
commit | e07d30fdcaec4906e0dcb948fc4748bf74c15c05 (patch) | |
tree | 37a8b2ec1c97700e2e63b2af4e278332715eb49a /gcc/tree-ssa-uninit.c | |
parent | 818203714e8640ce29c886b5060c91b12ad3a7c4 (diff) | |
download | gcc-e07d30fdcaec4906e0dcb948fc4748bf74c15c05.zip gcc-e07d30fdcaec4906e0dcb948fc4748bf74c15c05.tar.gz gcc-e07d30fdcaec4906e0dcb948fc4748bf74c15c05.tar.bz2 |
Handle all UBSAN built-ins in -Wuninitialized [PR101300].
Resolves:
PR middle-end/101300 - -fsanitize=undefined suppresses -Wuninitialized for a VLA read at -O0
gcc/ChangeLog:
PR middle-end/101300
* tree-ssa-uninit.c (check_defs): Handle UBSAN built-ins.
gcc/testsuite/ChangeLog:
PR middle-end/101300
* gcc.dg/uninit-pr101300.c: New test.
Diffstat (limited to 'gcc/tree-ssa-uninit.c')
-rw-r--r-- | gcc/tree-ssa-uninit.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c index 24ac031..148f3c2 100644 --- a/gcc/tree-ssa-uninit.c +++ b/gcc/tree-ssa-uninit.c @@ -228,9 +228,26 @@ check_defs (ao_ref *ref, tree vdef, void *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; + if (is_gimple_call (def_stmt)) + { + if (gimple_call_internal_p (def_stmt) + && gimple_call_internal_fn (def_stmt) == IFN_ASAN_MARK) + return false; + + if (tree fndecl = gimple_call_fndecl (def_stmt)) + { + /* Some sanitizer calls pass integer arguments to built-ins + that expect pointers. Avoid using gimple_call_builtin_p() + which fails for such calls. */ + if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL) + { + built_in_function fncode = DECL_FUNCTION_CODE (fndecl); + if (fncode > BEGIN_SANITIZER_BUILTINS + && fncode < END_SANITIZER_BUILTINS) + return false; + } + } + } /* End of VLA scope is not a kill. */ if (gimple_call_builtin_p (def_stmt, BUILT_IN_STACK_RESTORE)) |