diff options
author | Martin Sebor <msebor@redhat.com> | 2019-01-17 16:33:55 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2019-01-17 09:33:55 -0700 |
commit | 213694e56e6265044bc85dbf43bda9028f05dba7 (patch) | |
tree | 6e55de74c41ab1ba9949e3447f390dbb4c09b935 /gcc/tree-ssa-strlen.c | |
parent | 16d46c7bfda76b5b3e88a2d9a809aacdc3ed8e1a (diff) | |
download | gcc-213694e56e6265044bc85dbf43bda9028f05dba7.zip gcc-213694e56e6265044bc85dbf43bda9028f05dba7.tar.gz gcc-213694e56e6265044bc85dbf43bda9028f05dba7.tar.bz2 |
PR tree-optimization/88800 - Spurious -Werror=array-bounds for non-taken branch
gcc/ChangeLog:
PR tree-optimization/88800
* gimple-fold.c (gimple_fold_builtin_memory_op): Avoid checking
NO_WARNING bit here. Avoid folding out-of-bounds calls.
* gimple-ssa-warn-restrict.c (maybe_diag_offset_bounds): Remove
redundant argument. Add new argument and issue diagnostics under
its control. Detect out-of-bounds access even with warnings
disabled.
(check_bounds_or_overlap): Change return type. Add argument.
(wrestrict_dom_walker::check_call): Adjust.
* gimple-ssa-warn-restrict.h (check_bounds_or_overlap): Add argument.
* tree-ssa-strlen.c (handle_builtin_strcpy): Adjust to change in
check_bounds_or_overlap's return value.
(handle_builtin_stxncpy): Same.
(handle_builtin_strcat): Same.
gcc/testsuite/ChangeLog:
PR tree-optimization/88800
* c-c++-common/Wrestrict.c: Adjust.
* gcc.dg/Warray-bounds-37.c: New test.
* gcc.dg/builtin-memcpy-2.c: New test.
* gcc.dg/builtin-memcpy.c: New test.
From-SVN: r268037
Diffstat (limited to 'gcc/tree-ssa-strlen.c')
-rw-r--r-- | gcc/tree-ssa-strlen.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index 02ed1b4..df56970 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -1742,7 +1742,7 @@ handle_builtin_strcpy (enum built_in_function bcode, gimple_stmt_iterator *gsi) if (const strinfo *chksi = olddsi ? olddsi : dsi) if (si - && !check_bounds_or_overlap (stmt, chksi->ptr, si->ptr, NULL_TREE, len)) + && check_bounds_or_overlap (stmt, chksi->ptr, si->ptr, NULL_TREE, len)) { gimple_set_no_warning (stmt, true); set_no_warning = true; @@ -2214,7 +2214,7 @@ handle_builtin_stxncpy (built_in_function, gimple_stmt_iterator *gsi) else srcsize = NULL_TREE; - if (!check_bounds_or_overlap (stmt, dst, src, dstsize, srcsize)) + if (check_bounds_or_overlap (stmt, dst, src, dstsize, srcsize)) { gimple_set_no_warning (stmt, true); return; @@ -2512,7 +2512,7 @@ handle_builtin_strcat (enum built_in_function bcode, gimple_stmt_iterator *gsi) tree sptr = si && si->ptr ? si->ptr : src; - if (!check_bounds_or_overlap (stmt, dst, sptr, NULL_TREE, slen)) + if (check_bounds_or_overlap (stmt, dst, sptr, NULL_TREE, slen)) { gimple_set_no_warning (stmt, true); set_no_warning = true; @@ -2622,7 +2622,7 @@ handle_builtin_strcat (enum built_in_function bcode, gimple_stmt_iterator *gsi) tree sptr = si && si->ptr ? si->ptr : src; - if (!check_bounds_or_overlap (stmt, dst, sptr, dstlen, srcsize)) + if (check_bounds_or_overlap (stmt, dst, sptr, dstlen, srcsize)) { gimple_set_no_warning (stmt, true); set_no_warning = true; |