diff options
author | Jeff Law <law@redhat.com> | 2020-03-05 14:01:30 -0700 |
---|---|---|
committer | Jeff Law <law@redhat.com> | 2020-03-05 14:01:30 -0700 |
commit | 55ace4d14637866466498ed43e02d6f95af98f10 (patch) | |
tree | 0bcdec4218fa6088b63ee2eb78903424aeb38f58 /gcc/tree-ssa-strlen.c | |
parent | 3a0e583bf17240e55fee7b490e13753cca52bfe1 (diff) | |
download | gcc-55ace4d14637866466498ed43e02d6f95af98f10.zip gcc-55ace4d14637866466498ed43e02d6f95af98f10.tar.gz gcc-55ace4d14637866466498ed43e02d6f95af98f10.tar.bz2 |
Fix location maybe_diag_overlap passes to diagnostics so that diagnostic pragmas work better.
PR tree-optimization/91890
* gimple-ssa-warn-restrict.c (maybe_diag_overlap): Remove LOC argument.
Use gimple_or_expr_nonartificial_location.
(check_bounds_overlap): Drop LOC argument to maybe_diag_access_bounds.
Use gimple_or_expr_nonartificial_location.
* gimple.c (gimple_or_expr_nonartificial_location): New function.
* gimple.h (gimple_or_expr_nonartificial_location): Declare it.
* tree-ssa-strlen.c (maybe_warn_overflow): Use
gimple_or_expr_nonartificial_location.
(maybe_diag_stxncpy_trunc, handle_builtin_stxncpy_strncat): Likewise.
(maybe_warn_pointless_strcmp): Likewise.
* gcc.dg/pragma-diag-8.c: New test.
Diffstat (limited to 'gcc/tree-ssa-strlen.c')
-rw-r--r-- | gcc/tree-ssa-strlen.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index 81be11d..8815cdb 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -2129,11 +2129,7 @@ maybe_warn_overflow (gimple *stmt, tree len, || !si || !is_strlen_related_p (si->ptr, len))) return; - location_t loc = gimple_nonartificial_location (stmt); - if (loc == UNKNOWN_LOCATION && dest && EXPR_HAS_LOCATION (dest)) - loc = tree_nonartificial_location (dest); - loc = expansion_point_location_if_in_system_header (loc); - + location_t loc = gimple_or_expr_nonartificial_location (stmt, dest); bool warned = false; if (wi::leu_p (lenrng[0], spcrng[1])) { @@ -3189,9 +3185,7 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt) } } - location_t callloc = gimple_nonartificial_location (stmt); - callloc = expansion_point_location_if_in_system_header (callloc); - + location_t callloc = gimple_or_expr_nonartificial_location (stmt, dst); tree func = gimple_call_fndecl (stmt); if (lenrange[0] != 0 || !wi::neg_p (lenrange[1])) @@ -3403,8 +3397,7 @@ handle_builtin_stxncpy_strncat (bool append_p, gimple_stmt_iterator *gsi) to strlen(S)). */ strinfo *silen = get_strinfo (pss->first); - location_t callloc = gimple_nonartificial_location (stmt); - callloc = expansion_point_location_if_in_system_header (callloc); + location_t callloc = gimple_or_expr_nonartificial_location (stmt, dst); tree func = gimple_call_fndecl (stmt); @@ -4331,10 +4324,7 @@ maybe_warn_pointless_strcmp (gimple *stmt, HOST_WIDE_INT bound, /* FIXME: Include a note pointing to the declaration of the smaller array. */ - location_t stmt_loc = gimple_nonartificial_location (stmt); - if (stmt_loc == UNKNOWN_LOCATION && EXPR_HAS_LOCATION (lhs)) - stmt_loc = tree_nonartificial_location (lhs); - stmt_loc = expansion_point_location_if_in_system_header (stmt_loc); + location_t stmt_loc = gimple_or_expr_nonartificial_location (stmt, lhs); tree callee = gimple_call_fndecl (stmt); bool warned = false; |