diff options
| author | Jason Merrill <jason@redhat.com> | 2024-11-20 16:20:52 +0100 |
|---|---|---|
| committer | Jason Merrill <jason@redhat.com> | 2025-06-17 08:04:18 -0400 |
| commit | a5933118f34a97463ffa765744eedf27b9c2c68f (patch) | |
| tree | ca0939a872f397acab0560ea1bd387a1d0fedf7a /libcpp | |
| parent | 75ffef5c6fa4e6e9576285e0403c06728309ae3e (diff) | |
c++: modules and #pragma diagnostic
To respect the #pragma diagnostic lines in libstdc++ headers when compiling
with module std, we need to represent them in the module.
I think it's reasonable to give serializers direct access to the underlying
data, as here with get_classification_history. This is a different approach
from how Jakub made PCH streaming members of diagnostic_option_classifier,
but it seems to me that modules handling belongs in module.cc.
libcpp/ChangeLog:
* line-map.cc (linemap_location_from_module_p): Add.
* include/line-map.h: Declare it.
gcc/ChangeLog:
* diagnostic.h (diagnostic_option_classifier): Friend
diagnostic_context.
(diagnostic_context::get_classification_history): New.
gcc/cp/ChangeLog:
* module.cc (module_state::write_diagnostic_classification): New.
(module_state::write_begin): Call it.
(module_state::read_diagnostic_classification): New.
(module_state::read_initial): Call it.
(dk_string, dump_dc_change): New.
gcc/testsuite/ChangeLog:
* g++.dg/modules/warn-spec-3_a.C: New test.
* g++.dg/modules/warn-spec-3_b.C: New test.
* g++.dg/modules/warn-spec-3_c.C: New test.
Diffstat (limited to 'libcpp')
| -rw-r--r-- | libcpp/include/line-map.h | 4 | ||||
| -rw-r--r-- | libcpp/line-map.cc | 11 |
2 files changed, 15 insertions, 0 deletions
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index 83ebbde474d..21a59af2236 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -1111,6 +1111,10 @@ extern location_t linemap_module_loc extern void linemap_module_reparent (line_maps *, location_t loc, location_t new_parent); +/* TRUE iff the location comes from a module import. */ +extern bool linemap_location_from_module_p + (const line_maps *, location_t); + /* Restore the linemap state such that the map at LWM-1 continues. Return start location of the new map. */ extern location_t linemap_module_restore diff --git a/libcpp/line-map.cc b/libcpp/line-map.cc index 284af5781dc..33701b519e1 100644 --- a/libcpp/line-map.cc +++ b/libcpp/line-map.cc @@ -767,6 +767,17 @@ linemap_module_restore (line_maps *set, line_map_uint_t lwm) return 0; } +/* TRUE iff the location comes from a module import. */ + +bool +linemap_location_from_module_p (const line_maps *set, location_t loc) +{ + const line_map_ordinary *map = linemap_ordinary_map_lookup (set, loc); + while (map && map->reason != LC_MODULE) + map = linemap_included_from_linemap (set, map); + return !!map; +} + /* Returns TRUE if the line table set tracks token locations across macro expansion, FALSE otherwise. */ |
