diff options
author | dmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-12-07 16:07:00 +0000 |
---|---|---|
committer | dmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-12-07 16:07:00 +0000 |
commit | d0f713f444bd502eaed523b6a26e24922c5fe9f5 (patch) | |
tree | 4276629584cb83bab17864b868f5ecbcc2a63e89 /libcpp/line-map.c | |
parent | bc4c651ed9fc6908554c33d7f3b445a81da83ffb (diff) | |
download | gcc-d0f713f444bd502eaed523b6a26e24922c5fe9f5.tar.gz |
Fix missing range information for "%q+D" format code
gcc/c-family/ChangeLog:
* c-common.c (c_cpp_error): Update for change to
rich_location::set_range.
gcc/fortran/ChangeLog:
* error.c (gfc_format_decoder): Update for change of
text_info::set_range to text_info::set_location.
gcc/ChangeLog:
* pretty-print.c (text_info::set_range): Rename to...
(text_info::set_location): ...this, converting 2nd param
from source_range to a location_t.
* pretty-print.h (text_info::set_location): Convert
from inline function to external definition.
(text_info::set_range): Delete.
gcc/testsuite/ChangeLog:
* gcc.dg/diagnostic-ranges-1.c: New test file.
* gcc.dg/plugin/diagnostic-test-show-locus-bw.c
(test_percent_q_plus_d): New test function.
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c
(test_show_locus): Rewrite test code using
rich_location::set_range. Add code to unit-test the "%q+D"
format code.
libcpp/ChangeLog:
* include/line-map.h (rich_location::set_range): Add line_maps *
param; convert param from source_range to source_location. Drop
"overwrite_loc_p" param.
* line-map.c (rich_location::set_range): Likewise, acting as if
"overwrite_loc_p" were true, and getting range from the location.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@231367 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp/line-map.c')
-rw-r--r-- | libcpp/line-map.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/libcpp/line-map.c b/libcpp/line-map.c index 42843038e3b..209d0fbe656 100644 --- a/libcpp/line-map.c +++ b/libcpp/line-map.c @@ -2064,23 +2064,22 @@ rich_location::add_range (location_range *src_range) m_ranges[m_num_ranges++] = *src_range; } -/* Add or overwrite the range given by IDX. It must either - overwrite an existing range, or add one *exactly* on the end of - the array. +/* Add or overwrite the location given by IDX, setting its location to LOC, + and setting its "should my caret be printed" flag to SHOW_CARET_P. - This is primarily for use by gcc when implementing diagnostic - format decoders e.g. the "+" in the C/C++ frontends, for handling - format codes like "%q+D" (which writes the source location of a - tree back into range 0 of the rich_location). + It must either overwrite an existing location, or add one *exactly* on + the end of the array. - If SHOW_CARET_P is true, then the range should be rendered with - a caret at its starting location. This - is for use by the Fortran frontend, for implementing the - "%C" and "%L" format codes. */ + This is primarily for use by gcc when implementing diagnostic format + decoders e.g. + - the "+" in the C/C++ frontends, for handling format codes like "%q+D" + (which writes the source location of a tree back into location 0 of + the rich_location), and + - the "%C" and "%L" format codes in the Fortran frontend. */ void -rich_location::set_range (unsigned int idx, source_range src_range, - bool show_caret_p, bool overwrite_loc_p) +rich_location::set_range (line_maps *set, unsigned int idx, + source_location loc, bool show_caret_p) { linemap_assert (idx < MAX_RANGES); @@ -2088,6 +2087,8 @@ rich_location::set_range (unsigned int idx, source_range src_range, on the end of the array. */ linemap_assert (idx <= m_num_ranges); + source_range src_range = get_range_from_loc (set, loc); + location_range *locrange = &m_ranges[idx]; locrange->m_start = linemap_client_expand_location_to_spelling_point (src_range.m_start); @@ -2095,16 +2096,16 @@ rich_location::set_range (unsigned int idx, source_range src_range, = linemap_client_expand_location_to_spelling_point (src_range.m_finish); locrange->m_show_caret_p = show_caret_p; - if (overwrite_loc_p) - locrange->m_caret = locrange->m_start; + locrange->m_caret + = linemap_client_expand_location_to_spelling_point (loc); /* Are we adding a range onto the end? */ if (idx == m_num_ranges) m_num_ranges = idx + 1; - if (idx == 0 && overwrite_loc_p) + if (idx == 0) { - m_loc = src_range.m_start; + m_loc = loc; /* Mark any cached value here as dirty. */ m_have_expanded_location = false; } |