aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-strlen.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2018-08-01 23:39:35 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2018-08-01 17:39:35 -0600
commit8a45b051bf874c645b2b0316ea3b542be4b594db (patch)
tree26db1a736bc6394312b1820c7cdecd89d3a75fdf /gcc/tree-ssa-strlen.c
parentca9a1314ec5f2b58921e24abdcebae1482c0e2c6 (diff)
downloadgcc-8a45b051bf874c645b2b0316ea3b542be4b594db.zip
gcc-8a45b051bf874c645b2b0316ea3b542be4b594db.tar.gz
gcc-8a45b051bf874c645b2b0316ea3b542be4b594db.tar.bz2
PR tree-optimization/86650 - -Warray-bounds missing inlining context
gcc/c/ChangeLog: PR tree-optimization/86650 * c-objc-common.c (c_tree_printer): Move usage of EXPR_LOCATION (t) and TREE_BLOCK (t) from within percent_K_format to this callsite. gcc/c-family/ChangeLog: PR tree-optimization/86650 * c-family/c-format.c (gcc_tdiag_char_table): Update comment for "%G". (gcc_cdiag_char_table, gcc_cxxdiag_char_table): Same. (init_dynamic_diag_info): Update from "gcall *" to "gimple *". * c-format.h (T89_G): Update to be "gimple *" rather than "gcall *". (local_gcall_ptr_node): Rename... (local_gimple_ptr_node): ...to this. gcc/cp/ChangeLog: PR tree-optimization/86650 * error.c (cp_printer): Move usage of EXPR_LOCATION (t) and TREE_BLOCK (t) from within percent_K_format to this callsite. gcc/ChangeLog: PR tree-optimization/86650 * gimple-pretty-print.c (percent_G_format): Accept a "gimple *" rather than a "gcall *". Directly pass the data of interest to percent_K_format, rather than building a temporary CALL_EXPR to hold it. * gimple-fold.c (gimple_fold_builtin_strncpy): Adjust. (gimple_fold_builtin_strncat): Adjust. * gimple-ssa-warn-restrict.h (check_bounds_or_overlap): Replace gcall* argument with gimple*. * gimple-ssa-warn-restrict.c (check_call): Same. (wrestrict_dom_walker::before_dom_children): Same. (builtin_access::builtin_access): Same. (check_bounds_or_overlap): Same (maybe_diag_overlap): Same. (maybe_diag_offset_bounds): Same. * tree-diagnostic.c (default_tree_printer): Move usage of EXPR_LOCATION (t) and TREE_BLOCK (t) from within percent_K_format to this callsite. * tree-pretty-print.c (percent_K_format): Add argument. * tree-pretty-print.h: Add argument. * tree-ssa-ccp.c (pass_post_ipa_warn::execute): Adjust. * tree-ssa-strlen.c (maybe_diag_stxncpy_trunc): Adjust. (maybe_diag_stxncpy_trunc): Same. (handle_builtin_stxncpy): Same. (handle_builtin_strcat): Same. gcc/testsuite/ChangeLog: PR tree-optimization/86650 * gcc.dg/format/gcc_diag-10.c: Adjust. From-SVN: r263239
Diffstat (limited to 'gcc/tree-ssa-strlen.c')
-rw-r--r--gcc/tree-ssa-strlen.c35
1 files changed, 14 insertions, 21 deletions
diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c
index 1eaa9c5..1d813b4 100644
--- a/gcc/tree-ssa-strlen.c
+++ b/gcc/tree-ssa-strlen.c
@@ -1627,8 +1627,7 @@ handle_builtin_strcpy (enum built_in_function bcode, gimple_stmt_iterator *gsi)
tree type = TREE_TYPE (oldlen);
oldlen = fold_build2 (PLUS_EXPR, type, oldlen,
build_int_cst (type, 1));
- check_bounds_or_overlap (as_a <gcall *>(stmt), olddsi->ptr, src,
- oldlen, NULL_TREE);
+ check_bounds_or_overlap (stmt, olddsi->ptr, src, oldlen, NULL_TREE);
}
return;
@@ -1715,8 +1714,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 (as_a <gcall *>(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;
@@ -2031,8 +2029,6 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt)
lenrange[0] = wi::shwi (0, prec);
}
- gcall *call = as_a <gcall *> (stmt);
-
/* Set to true for strncat whose bound is derived from the length
of the destination (the expected usage pattern). */
bool cat_dstlen_bounded = false;
@@ -2048,7 +2044,7 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt)
"%G%qD output truncated before terminating nul "
"copying %E bytes from a string of the same "
"length",
- call, func, cnt);
+ stmt, func, cnt);
else if (!cat_dstlen_bounded)
{
if (wi::geu_p (lenrange[0], cntrange[1]))
@@ -2062,12 +2058,12 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt)
"from a string of length %wu",
"%G%qD output truncated copying %E bytes "
"from a string of length %wu",
- call, func, cnt, lenrange[0].to_uhwi ());
+ stmt, func, cnt, lenrange[0].to_uhwi ());
return warning_at (callloc, OPT_Wstringop_truncation,
"%G%qD output truncated copying between %wu "
"and %wu bytes from a string of length %wu",
- call, func, cntrange[0].to_uhwi (),
+ stmt, func, cntrange[0].to_uhwi (),
cntrange[1].to_uhwi (), lenrange[0].to_uhwi ());
}
else if (wi::geu_p (lenrange[1], cntrange[1]))
@@ -2081,12 +2077,12 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt)
"byte from a string of length %wu",
"%G%qD output may be truncated copying %E "
"bytes from a string of length %wu",
- call, func, cnt, lenrange[1].to_uhwi ());
+ stmt, func, cnt, lenrange[1].to_uhwi ());
return warning_at (callloc, OPT_Wstringop_truncation,
"%G%qD output may be truncated copying between "
"%wu and %wu bytes from a string of length %wu",
- call, func, cntrange[0].to_uhwi (),
+ stmt, func, cntrange[0].to_uhwi (),
cntrange[1].to_uhwi (), lenrange[1].to_uhwi ());
}
}
@@ -2102,7 +2098,7 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt)
return warning_at (callloc, OPT_Wstringop_truncation,
"%G%qD output may be truncated copying between "
"%wu and %wu bytes from a string of length %wu",
- call, func, cntrange[0].to_uhwi (),
+ stmt, func, cntrange[0].to_uhwi (),
cntrange[1].to_uhwi (), lenrange[0].to_uhwi ());
}
}
@@ -2122,7 +2118,7 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt)
if (cntrange[0] == cntrange[1])
return warning_at (callloc, OPT_Wstringop_truncation,
"%G%qD specified bound %E equals destination size",
- as_a <gcall *> (stmt), func, cnt);
+ stmt, func, cnt);
}
return false;
@@ -2180,8 +2176,7 @@ handle_builtin_stxncpy (built_in_function, gimple_stmt_iterator *gsi)
else
srcsize = NULL_TREE;
- if (!check_bounds_or_overlap (as_a <gcall *>(stmt), dst, src,
- dstsize, srcsize))
+ if (!check_bounds_or_overlap (stmt, dst, src, dstsize, srcsize))
{
gimple_set_no_warning (stmt, true);
return;
@@ -2222,13 +2217,13 @@ handle_builtin_stxncpy (built_in_function, gimple_stmt_iterator *gsi)
&& warning_at (callloc, OPT_Wstringop_truncation,
"%G%qD output truncated before terminating nul "
"copying as many bytes from a string as its length",
- as_a <gcall *>(stmt), func))
+ stmt, func))
warned = true;
else if (silen && is_strlen_related_p (src, silen->ptr))
warned = warning_at (callloc, OPT_Wstringop_overflow_,
"%G%qD specified bound depends on the length "
"of the source argument",
- as_a <gcall *>(stmt), func);
+ stmt, func);
if (warned)
{
location_t strlenloc = pss->second;
@@ -2479,8 +2474,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 (as_a <gcall *>(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;
@@ -2590,8 +2584,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 (as_a <gcall *>(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;