C: use full locations within c_parser_expr_list's vec<location_t>
commit43f0de1772a3f48d6541463a18318f5b20d9fe24
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 21 Aug 2017 17:03:15 +0000 (21 17:03 +0000)
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 21 Aug 2017 17:03:15 +0000 (21 17:03 +0000)
treedffd9f4456e124fd12725644bce859641cf32996
parenta115c319104ea5f4133b3b2e4b30da97aa8d18d8
C: use full locations within c_parser_expr_list's vec<location_t>

The previous patch uncovered a bug in how c_parser_expr_list builds the
vec<location_t>: it was only using the location of the first token
within each assignment-expression in the expr-list.

This shows up in e.g. this -Wformat warning, where only part of the
2nd param is underlined:

   printf("hello %i", (long)0);
                 ~^   ~
                 %li

This patch fixes c_parser_expr_list to use the full range of
each assignment-expression in the list for the vec<location_t>, so
that for the above we print:

   printf("hello %i", (long)0);
                 ~^   ~~~~~~~
                 %li

gcc/c/ChangeLog:
* c-parser.c (c_parser_expr_list): Use c_expr::get_location ()
rather than peeking the location of the first token.
* c-tree.h (c_expr::get_location): New method.

gcc/testsuite/ChangeLog:
* gcc.dg/format/diagnostic-ranges.c (test_mismatching_types):
Update expected result to show all of "(long)0" being underlined.
* gcc.dg/plugin/diagnostic-test-string-literals-1.c
(test_multitoken_macro): Update expected underlining.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@251239 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/c/ChangeLog
gcc/c/c-parser.c
gcc/c/c-tree.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
gcc/testsuite/gcc.dg/plugin/diagnostic-test-string-literals-1.c