aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2015-12-07 16:07:00 +0000
committerDavid Malcolm <dmalcolm@redhat.com>2015-12-07 16:07:00 +0000
commitc67a7d2ad7b4da5899dd7ea204dd6947c05e92c9 (patch)
tree4276629584cb83bab17864b868f5ecbcc2a63e89 /libcpp
parentab62ec81201852b6fe6d8f267dc200e4f360d626 (diff)
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: https://gcc.gnu.org/svn/gcc/trunk@231367 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog8
-rw-r--r--libcpp/include/line-map.h4
-rw-r--r--libcpp/line-map.c35
3 files changed, 28 insertions, 19 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 78a0d7cb373..9b296fd836a 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,11 @@
+2015-12-07 David Malcolm <dmalcolm@redhat.com>
+
+ * 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.
+
2015-11-20 David Malcolm <dmalcolm@redhat.com>
PR 62314
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
index 4f440fa5e51..73c583e6160 100644
--- a/libcpp/include/line-map.h
+++ b/libcpp/include/line-map.h
@@ -1376,8 +1376,8 @@ class rich_location
add_range (location_range *src_range);
void
- set_range (unsigned int idx, source_range src_range,
- bool show_caret_p, bool overwrite_loc_p);
+ set_range (line_maps *set, unsigned int idx, source_location loc,
+ bool show_caret_p);
unsigned int get_num_locations () const { return m_num_ranges; }
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;
}