diff options
author | Martin Sebor <msebor@redhat.com> | 2018-04-20 23:43:51 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2018-04-20 17:43:51 -0600 |
commit | 8cd95cec0f5bde4d78dd26778f6070b3bdda6672 (patch) | |
tree | e2c3ae88ecc8a5de23f062a8f185c0f70860ae17 /gcc/gimple-fold.c | |
parent | 661eb8f9e5270df79c21601273219e2a8e282204 (diff) | |
download | gcc-8cd95cec0f5bde4d78dd26778f6070b3bdda6672.zip gcc-8cd95cec0f5bde4d78dd26778f6070b3bdda6672.tar.gz gcc-8cd95cec0f5bde4d78dd26778f6070b3bdda6672.tar.bz2 |
PR c/85365 - -Wrestrict false positives with -fsanitize=undefined
gcc/ChangeLog:
PR c/85365
* gimple-fold.c (gimple_fold_builtin_strcpy): Suppress -Wrestrict
for null pointers.
(gimple_fold_builtin_stxcpy_chk): Same.
* gimple-ssa-warn-restrict.c (check_bounds_or_overlap): Same.
gcc/testsuite/ChangeLog:
PR c/85365
* gcc.dg/Wrestrict-15.c: New test.
From-SVN: r259535
Diffstat (limited to 'gcc/gimple-fold.c')
-rw-r--r-- | gcc/gimple-fold.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 7771988..bd8c44a 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -1612,7 +1612,11 @@ gimple_fold_builtin_strcpy (gimple_stmt_iterator *gsi, /* If SRC and DEST are the same (and not volatile), return DEST. */ if (operand_equal_p (src, dest, 0)) { - if (!gimple_no_warning_p (stmt)) + /* Issue -Wrestrict unless the pointers are null (those do + not point to objects and so do not indicate an overlap; + such calls could be the result of sanitization and jump + threading). */ + if (!integer_zerop (dest) && !gimple_no_warning_p (stmt)) { tree func = gimple_call_fndecl (stmt); @@ -2593,7 +2597,11 @@ gimple_fold_builtin_stxcpy_chk (gimple_stmt_iterator *gsi, /* If SRC and DEST are the same (and not volatile), return DEST. */ if (fcode == BUILT_IN_STRCPY_CHK && operand_equal_p (src, dest, 0)) { - if (!gimple_no_warning_p (stmt)) + /* Issue -Wrestrict unless the pointers are null (those do + not point to objects and so do not indicate an overlap; + such calls could be the result of sanitization and jump + threading). */ + if (!integer_zerop (dest) && !gimple_no_warning_p (stmt)) { tree func = gimple_call_fndecl (stmt); |