mirror of
https://forge.sourceware.org/marek/gcc.git
synced 2026-02-22 03:47:02 -05:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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. */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user