diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-02-03 16:28:07 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-02-03 16:28:07 +0000 |
commit | da136652aed5e6a614081e23424f9f214d3c4603 (patch) | |
tree | 65f55d088c341eb4bc1ca12f65d19dddbb3ac8c0 /gcc/builtins.c | |
parent | 01df1184161c4861e2b58bcf7d47c740d40a6aa8 (diff) | |
download | gcc-da136652aed5e6a614081e23424f9f214d3c4603.tar.gz |
PR c++/35652
* builtins.c (c_strlen): Use EXPR_LOCATION in diagnostics.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156469 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index ac9693400e4..b6fd1ead0fb 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -433,6 +433,7 @@ c_strlen (tree src, int only_value) HOST_WIDE_INT offset; int max; const char *ptr; + location_t loc; STRIP_NOPS (src); if (TREE_CODE (src) == COND_EXPR @@ -450,6 +451,11 @@ c_strlen (tree src, int only_value) && (only_value || !TREE_SIDE_EFFECTS (TREE_OPERAND (src, 0)))) return c_strlen (TREE_OPERAND (src, 1), only_value); + if (EXPR_HAS_LOCATION (src)) + loc = EXPR_LOCATION (src); + else + loc = input_location; + src = string_constant (src, &offset_node); if (src == 0) return NULL_TREE; @@ -475,7 +481,7 @@ c_strlen (tree src, int only_value) and return that. This would perhaps not be valid if we were dealing with named arrays in addition to literal string constants. */ - return size_diffop_loc (input_location, size_int (max), offset_node); + return size_diffop_loc (loc, size_int (max), offset_node); } /* We have a known offset into the string. Start searching there for @@ -494,7 +500,7 @@ c_strlen (tree src, int only_value) /* Suppress multiple warnings for propagated constant strings. */ if (! TREE_NO_WARNING (src)) { - warning (0, "offset outside bounds of constant string"); + warning_at (loc, 0, "offset outside bounds of constant string"); TREE_NO_WARNING (src) = 1; } return NULL_TREE; |