https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69543
--- Comment #21 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Lewis Hyatt <lhy...@gcc.gnu.org>: https://gcc.gnu.org/g:b52b99b62df8fc9b3a3010cb0a8cf49bc35037f0 commit r13-2994-gb52b99b62df8fc9b3a3010cb0a8cf49bc35037f0 Author: Lewis Hyatt <lhy...@gmail.com> Date: Fri Sep 30 14:10:00 2022 -0400 diagnostics: Fix virtual location for -Wuninitialized [PR69543] Warnings issued for -Wuninitialized have been using the spelling location of the problematic usage, discarding any information on the location of the macro expansion point if such usage was in a macro. This makes the warnings impossible to control reliably with #pragma GCC diagnostic, and also discards useful context in the diagnostic output. There seems to be no need to discard the virtual location information, so this patch fixes that. PR69543 was mostly about _Pragma issues which have been fixed for many years now. The PR remains open because two of the testcases added in response to it still have xfails, but those xfails have nothing to do with _Pragma and rather just with the issue fixed by this patch, so the PR can be closed now as well. The other testcase modified here, pragma-diagnostic-2.c, was explicitly testing for the undesirable behavior that was xfailed in pr69543-3.c. I have adjusted that and also added a new testcase verifying all 3 types of warning that come from tree-ssa-uninit.cc get the proper location information now. gcc/ChangeLog: PR preprocessor/69543 * tree-ssa-uninit.cc (warn_uninit): Stop stripping macro tracking information away from the diagnostic location. (maybe_warn_read_write_only): Likewise. (maybe_warn_operand): Likewise. gcc/testsuite/ChangeLog: PR preprocessor/69543 * c-c++-common/pr69543-3.c: Remove xfail. * c-c++-common/pr69543-4.c: Likewise. * gcc.dg/cpp/pragma-diagnostic-2.c: Adjust test for new behavior. * c-c++-common/pragma-diag-16.c: New test.