Created attachment 48573 [details] Test case I'm trying to create a macro which evaluates an expression while ignoring warnings generated by the warning attribute. Basically, a slightly simplified version of what I want is: #define IGNORE_WARNING_ATTR(expr) (__extension__({ \ _Pragma("GCC diagnostic push") \ _Pragma("GCC diagnostic ignored \"-Wattribute-warning\"") \ int tmp = expr; \ _Pragma("GCC diagnostic pop") \ tmp; \ })) However, when I use it I still see the warning. If I don't use a macro, but instead just do int c = (__extension__({ _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wattribute-warning\"") int tmp = foo(argc); _Pragma("GCC diagnostic pop") tmp; })); It works as intended; no warning. If I use the macro version and preprocess the source file first, then compile the preprocessed file separately, it works. If I compile with g++ it works. Using the attached test case, I get: $ gcc -E -o warn-pp.c warn.c && gcc -o warn warn-pp.c $ g++ -o warn warn.c $ gcc -o warn warn.c warn.c: In function ‘main’: warn.c:23:31: warning: call to ‘foo’ declared with attribute warning: Calling foo [-Wattribute-warning] 23 | int b = IGNORE_WARNING_ATTR(foo(argc)); | ^~~~~~~~~ warn.c:4:15: note: in definition of macro ‘IGNORE_WARNING_ATTR’ 4 | int tmp = expr; \ | ^~~~
Same issue as PR97498. *** This bug has been marked as a duplicate of bug 97498 ***