aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorNathaniel Shead <nathanieloshead@gmail.com>2026-03-13 17:31:52 +1100
committerNathaniel Shead <nathanieloshead@gmail.com>2026-03-19 22:11:54 +1100
commita7135aaa4e6faae357b5997260d64208d67a7c3b (patch)
tree275d4fd07e15776d1cf5ccb7b3327f9e5c206bb0 /libcpp
parenta0d6c3f23ccf75b587c923f40faf815ac263bc99 (diff)
downloadgcc-a7135aaa4e6faae357b5997260d64208d67a7c3b.tar.gz
gcc-a7135aaa4e6faae357b5997260d64208d67a7c3b.tar.bz2
gcc-a7135aaa4e6faae357b5997260d64208d67a7c3b.zip
libcpp: Handle macro locations in linemap_location_from_module_p [PR124466]
The testcase crashed because in warn-spec-5_b.C we were writing diagnostic classifications for pops but not for the things they were ignoring. We should have been writing neither, as they all came from an imported location, but linemap_location_from_module_p was returning false for locations that originated from macros in a module. PR c++/124466 libcpp/ChangeLog: * line-map.cc (linemap_location_from_module_p): Resolve loc in case it's a macro location. gcc/testsuite/ChangeLog: * g++.dg/modules/warn-spec-5_a.C: New test. * g++.dg/modules/warn-spec-5_b.C: New test. * g++.dg/modules/warn-spec-5_c.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/line-map.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/libcpp/line-map.cc b/libcpp/line-map.cc
index 3dd73a93b988..34f3642258d6 100644
--- a/libcpp/line-map.cc
+++ b/libcpp/line-map.cc
@@ -772,7 +772,9 @@ linemap_module_restore (line_maps *set, line_map_uint_t lwm)
bool
linemap_location_from_module_p (const line_maps *set, location_t loc)
{
- const line_map_ordinary *map = linemap_ordinary_map_lookup (set, loc);
+ const line_map_ordinary *map = nullptr;
+ linemap_resolve_location (set, loc, LRK_SPELLING_LOCATION, &map);
+
while (map && map->reason != LC_MODULE)
map = linemap_included_from_linemap (set, map);
return !!map;