diff options
author | David Malcolm <dmalcolm@redhat.com> | 2017-07-07 18:49:09 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2017-07-07 18:49:09 +0000 |
commit | 738f7c2e12de922b91024717429a048b877492ee (patch) | |
tree | 1b954335f19a816878f1e5806bb1ecff2760223b /libcpp | |
parent | 57f49e990f52ebdd3cb4a5be4e87a2301fed1a1a (diff) | |
download | gcc-738f7c2e12de922b91024717429a048b877492ee.tar.gz |
libcpp: preserve ranges within macro expansions (PR c++/79300)
gcc/testsuite/ChangeLog:
PR c++/79300
* g++.dg/diagnostic/pr79300.C: New test case.
libcpp/ChangeLog:
PR c++/79300
* line-map.c (linemap_macro_loc_to_def_point): Preserve range
information for macro expansions by delaying resolving ad-hoc
locations until within the loop.
From-SVN: r250058
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/ChangeLog | 7 | ||||
-rw-r--r-- | libcpp/line-map.c | 14 |
2 files changed, 15 insertions, 6 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index d080b016876..cf6f924ac95 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,10 @@ +2017-07-07 David Malcolm <dmalcolm@redhat.com> + + PR c++/79300 + * line-map.c (linemap_macro_loc_to_def_point): Preserve range + information for macro expansions by delaying resolving ad-hoc + locations until within the loop. + 2017-07-06 David Malcolm <dmalcolm@redhat.com> PR c++/79300 diff --git a/libcpp/line-map.c b/libcpp/line-map.c index 3b65a464647..0e5804b65bc 100644 --- a/libcpp/line-map.c +++ b/libcpp/line-map.c @@ -1440,21 +1440,23 @@ linemap_macro_loc_to_def_point (struct line_maps *set, { struct line_map *map; - if (IS_ADHOC_LOC (location)) - location = set->location_adhoc_data_map.data[location - & MAX_SOURCE_LOCATION].locus; - linemap_assert (set && location >= RESERVED_LOCATION_COUNT); while (true) { - map = const_cast <line_map *> (linemap_lookup (set, location)); + source_location caret_loc; + if (IS_ADHOC_LOC (location)) + caret_loc = get_location_from_adhoc_loc (set, location); + else + caret_loc = location; + + map = const_cast <line_map *> (linemap_lookup (set, caret_loc)); if (!linemap_macro_expansion_map_p (map)) break; location = linemap_macro_map_loc_to_def_point (linemap_check_macro (map), - location); + caret_loc); } if (original_map) |