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-ssa-warn-restrict.c | |
parent | 661eb8f9e5270df79c21601273219e2a8e282204 (diff) |
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-ssa-warn-restrict.c')
-rw-r--r-- | gcc/gimple-ssa-warn-restrict.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/gcc/gimple-ssa-warn-restrict.c b/gcc/gimple-ssa-warn-restrict.c index e7a85fdcd13..3d0664da028 100644 --- a/gcc/gimple-ssa-warn-restrict.c +++ b/gcc/gimple-ssa-warn-restrict.c @@ -1880,11 +1880,20 @@ check_bounds_or_overlap (gcall *call, tree dst, tree src, tree dstsize, if (operand_equal_p (dst, src, 0)) { - warning_at (loc, OPT_Wrestrict, - "%G%qD source argument is the same as destination", - call, func); - gimple_set_no_warning (call, true); - return false; + /* 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 (dst) && !gimple_no_warning_p (call)) + { + warning_at (loc, OPT_Wrestrict, + "%G%qD source argument is the same as destination", + call, func); + gimple_set_no_warning (call, true); + return false; + } + + return true; } /* Return false when overlap has been detected. */ |