https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91669
Lewis Hyatt <lhyatt at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lhyatt at gcc dot gnu.org --- Comment #4 from Lewis Hyatt <lhyatt at gcc dot gnu.org> --- This is already fixed on the latest GCC 10, 11, and 12 branches and on trunk for GCC 13. There were two separate issues contributing to this problem. The first one was common to both C and C++, and it was fixed by r10-325 for PR90382. (That PR was primarily about something else so was not focused on _Pragma locations, but the fix resolved this PR too.) The second issue made it stay broken longer for C only, not C++. In that sense it's partially a dupe of PR97498 and this aspect was fixed by r13-1596. (Issue was that in C, input_location used to be always the start of the line.) That fix has been backported to 10, 11, and 12 branches already. The testcase I added in r13-1596 provides partial coverage for this issue as well, but it does not quite cover the issue with adhoc locations addressed by r10-325. Here is a reduced testcase for this PR: ======================= #define ENDFUNC \ _Pragma("GCC diagnostic push") \ _Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \ } \ _Pragma("GCC diagnostic pop") int f () { ENDFUNC ======================= I will submit a patch to add this testcase and then close this one once that's applied.