diagnostic: Save/restore diagnostic context history and push/pop state for PCH [PR116847]
The following patch on top of the just posted cleanup patch
saves/restores the m_classification_history and m_push_list
vectors for PCH. Without that as the testcase shows during parsing
of the templates we don't report ignored diagnostics, but after loading
PCH header when instantiating those templates those warnings can be
emitted. This doesn't show up on x86_64-linux build because configure
injects there -fcf-protection -mshstk flags during library build (and so
also during PCH header creation), but make check doesn't use those flags
and so the PCH header is ignored.
2024-09-26 Jakub Jelinek <jakub@redhat.com>
PR libstdc++/116847
gcc/
* diagnostic.h (diagnostic_option_classifier): Add pch_save and
pch_restore method declarations.
(diagnostic_context): Add pch_save and pch_restore inline method
definitions.
* diagnostic.cc (diagnostic_option_classifier::pch_save): New method.
(diagnostic_option_classifier::pch_restore): Likewise.
gcc/c-family/
* c-pch.cc: Include diagnostic.h.
(c_common_write_pch): Call global_dc->pch_save.
(c_common_read_pch): Call global_dc->pch_restore.
gcc/testsuite/
* g++.dg/pch/pr116847.C: New test.
* g++.dg/pch/pr116847.Hs: New test.