diff options
author | dmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-12-16 17:25:45 +0000 |
---|---|---|
committer | dmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-12-16 17:25:45 +0000 |
commit | b49f1fbb79e540b892774b94d442603bc891a7a4 (patch) | |
tree | 1ee547d74e7d3d0c1c961fb845833707dd113d75 /gcc/c | |
parent | 6fb10557280fd8b0b614816f12bedad18590d487 (diff) | |
download | gcc-b49f1fbb79e540b892774b94d442603bc891a7a4.tar.gz |
C FE: use correct location range for static assertions
gcc/c/ChangeLog:
* c-parser.c (c_parser_static_assert_declaration_no_semi): Use the
expression location, falling back on the first token location,
rather than always using the latter.
gcc/testsuite/ChangeLog:
* gcc.dg/diagnostic-range-static-assert.c: New test case.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@231704 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c/c-parser.c | 3 |
2 files changed, 8 insertions, 1 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index fd1c707f46b..3ed1326fd05 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2015-12-16 David Malcolm <dmalcolm@redhat.com> + + * c-parser.c (c_parser_static_assert_declaration_no_semi): Use the + expression location, falling back on the first token location, + rather than always using the latter. + 2015-12-16 Marek Polacek <polacek@redhat.com> PR c/64637 diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 124c30b9939..5c32f45e21e 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -2097,8 +2097,9 @@ c_parser_static_assert_declaration_no_semi (c_parser *parser) c_parser_consume_token (parser); if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) return; - value_loc = c_parser_peek_token (parser)->location; + location_t value_tok_loc = c_parser_peek_token (parser)->location; value = c_parser_expr_no_commas (parser, NULL).value; + value_loc = EXPR_LOC_OR_LOC (value, value_tok_loc); parser->lex_untranslated_string = true; if (!c_parser_require (parser, CPP_COMMA, "expected %<,%>")) { |