[Patch] libcpp: Fix _Pragma in #__VA_ARGS__ [PR103165]

Tobias Burnus tobias@codesourcery.com
Wed Nov 10 20:12:57 GMT 2021

This patch fixes a pseudo regression of my previous _Pragma patch.

The issue was that a tokenized '_Pragma' (-> CPP_PRAGMA) could end
up as to-be quoted argument ('#__VA_ARG__') and that wasn't never
handled and gave an ICE for a GCC after my previous patch and before
this patch.

The expected 'gcc -E' output is in the '#if 0' block in the testcase.

Before my previous patch, "gcc -E" yielded the following, which is
obviously wrong:
   const char *str =
#pragma omp error severity(warning) message ("Test") at(compilation)
   "\"1,2\" ;" ;
#pragma omp error severity(warning) message ("Test") at(compilation)

Build on x86-64-gnu-linux, the "make -k check" is running.
OK when it passes?

  * * *

Disclaimer: While this patch does a step into the right direction,
it probably does help with any of the other _Pragma issues. Neither
with 'gcc -E' when the pragma wasn't registered (still expanded too
early) nor with the 'GCC diagnostic' issues in general as there the
input_location is used to decide when to pop - and depending on the
column numbers, this may or may not work.

See https://gcc.gnu.org/pipermail/gcc-patches/2021-October/582927.html
for some more details and links to PRs.

Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pragma2-fix.diff
Type: text/x-patch
Size: 7118 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20211110/5ae37e27/attachment.bin>

More information about the Gcc-patches mailing list