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/gimple.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/gimple.c')
-rw-r--r-- | gcc/gimple.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/gimple.c b/gcc/gimple.c index 324e706..92c6e64 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -3285,6 +3285,19 @@ gimple_inexpensive_call_p (gcall *stmt) return false; } +/* Return a non-artificial location for STMT. If STMT does not have + location information, get the location from EXPR. */ + +location_t +gimple_or_expr_nonartificial_location (gimple *stmt, tree) +{ + location_t loc = gimple_nonartificial_location (stmt); + if (loc == UNKNOWN_LOCATION && EXPR_HAS_LOCATION (expr)) + loc = tree_nonartificial_location (expr); + return expansion_point_location_if_in_system_header (loc); +} + + #if CHECKING_P namespace selftest { |