https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80922
--- Comment #15 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Lewis Hyatt <[email protected]>: https://gcc.gnu.org/g:4c85f7cf587f0f62a5eb1884998d4ed30a39552a commit r17-2493-g4c85f7cf587f0f62a5eb1884998d4ed30a39552a Author: Lewis Hyatt <[email protected]> Date: Sat Jul 11 14:21:12 2026 -0400 lto: Support #pragma GCC diagnostic [PR80922] [PR106823] [PR107936] After the previous changes in this series, the LTO front end always has an appropriate linemap structure for interpreting diagnostic pragmas, so it is straightforward to implement them, as is done here. The pragmas are streamed out in each linemap section; since all locations from a given linemap section will be contiguous in the reconstructed linemap, they are automatically ordered properly for the existing diagnostic pragma infrastructure to work as-is. One wrinkle is that a single function may have been streamed out in multiple sections. (For example, an inline function will be streamed out in all partitions that need it.) In this case, when merging them, LTO keeps only one of the sections, as directed by the linker resolution, so the diagnostic pragmas that will be in force (in case they were not the same for the different translation units) will be whichever were applicable to the section LTO decided to keep. gcc/ChangeLog: PR middle-end/80922 PR middle-end/106823 PR lto/107936 * lto-streamer-in.cc (lto_create_loc_map): Process diagnostic pragmas from the linemap sections. * lto-streamer-out.cc (location_output::produce_linemap_section): Stream diagnostic pragmas into the linemap section. gcc/testsuite/ChangeLog: PR middle-end/80922 PR middle-end/106823 PR lto/107936 * gcc.dg/lto/pr106823_0.c: New test. * gcc.dg/lto/pr107936_0.c: New test. * gcc.dg/lto/pr107936_1.c: New test. * gcc.dg/lto/pr80922-1_0.c: New test. * gcc.dg/lto/pr80922-1_1.c: New test. * gcc.dg/lto/pr80922-2_0.c: New test. * gcc.dg/lto/pr80922-2_1.c: New test. * gcc.dg/lto/pr80922-2_2.c: New test.
