Ping: https://gcc.gnu.org/ml/gcc-patches/2018-07/msg00197.html
On 07/04/18 12:53, Bernd Edlinger wrote: > Hi, > > currently _Pragma("GCC diagnostic ...") does not properly > work in macro expansions. > > Consider the following code: > > #define B _Pragma("GCC diagnostic push") \ > _Pragma("GCC diagnostic ignored \"-Wattributes\"") > #define E _Pragma("GCC diagnostic pop") > > #define X() B int __attribute((unknown_attr)) x; E /* { dg-bogus "attribute > directive ignored" } */ > > void test1(void) > { > X() /* { dg-bogus "in expansion of macro" } */ > } > > > Warnings happen in C++ despite the _Pragma, while C happens to suppress the > warnings > more or less by accident. > > This is connected to the fact that GCC uses the location of the closing > parenthesis of the > function-like macro expansion in the _Pragma, while the rest of the locations > are relative > to the macro expansion point, which is the letter X in this case. > > This patch changes the location of builtin macros and _Pragma to use the > macro expansion > point instead of the closing parenthesis. > > A few test cases had to be adjusted, most changes were necessary because the > __LINE__ > location moved to the macro expansion point, which looks like a straight > improvement. > > In pr61817-2.c the location of __LINE__ depends on -ftrack-macro-expansion, > when enabled the location of the macro argument is the spelling location, > while all other > locations change to the macro expansion point. > > The C++ pagma plugin.c is also affected by the change, because the > input_location is now > the spelling location of _Pragma in DO_PRAGMA and has to be converted to the > expansion > point of the macro to get the expected result. > > > Bootstrapped and reg-tested on x86_64-pc-linux-gnu. > Is it OK for trunk? > > > Thanks > Bernd. >