https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79948
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |rejects-valid Status|UNCONFIRMED |NEW Last reconfirmed| |2017-03-08 CC| |msebor at gcc dot gnu.org Ever confirmed|0 |1 Known to fail| |4.1.3, 4.2.2, 4.3.2, 4.6.0, | |5.4.0, 6.3.0, 7.0 --- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- I'll confirm this as a bug with the test case below which is expected to compile without an error (and does with other compilers I tested, including Clang 5.0, EDG eccp 4.13, IBM XLC 13.1.3, Oracle cc 5.13, and Microsoft Visual C/C++). It seems to me that in 'return Y (E)' GCC first expands the E macro into the _Pragma, then executes the _Pragma, and then expands the Y() macro. I think it should expand all the macros first, i.e., first E, then Y, then X, and then execute any _Pragmas. $ cat t.c && gcc -S t.c #define E _Pragma ("GCC error \"This is an error\"") #define X(a) my##a #define Y(a) X(a) int my_Pragma (const char*); int f (void) { return Y (E); }; t.c: In function ‘f’: t.c:10:11: error: This is an error return Y (E); ^~~~~ t.c:3:14: error: ‘my’ undeclared (first use in this function) #define X(a) my##a ^ t.c:4:14: note: in expansion of macro ‘X’ #define Y(a) X(a) ^ t.c:10:10: note: in expansion of macro ‘Y’ return Y (E); ^ t.c:3:14: note: each undeclared identifier is reported only once for each function it appears in #define X(a) my##a ^ t.c:4:14: note: in expansion of macro ‘X’ #define Y(a) X(a) ^ t.c:10:10: note: in expansion of macro ‘Y’ return Y (E); ^