[Bug c++/84127] pragmas to disable -Wexpansion-to-defined compiler warnings seems to be broken since 7.x
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jan 30 18:25:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84127
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|UNCONFIRMED |NEW
Last reconfirmed| |2018-01-30
CC| |msebor at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
I can confirm that diagnostic pragmas that affect the preprocessor have no
effect in C++. I can reproduce the same behavior with GCC 6.x as well as 7.x
and 8.0 so it doesn't seem like a recent regression.
Here's an expanded test case. When compiled in C mode all warnings are
suppressed. In C++ mode none is.
$ cat pr84127.c && gcc -S -Wall -Wdate-time -Wempty-body -Wexpansion-to-defined
-trigraphs -o/dev/null -xc++ pr84127.c
_Pragma ("GCC diagnostic ignored \"-Wcomment\"")
/* /* */ // -Wcomment not suppressed
_Pragma ("GCC diagnostic ignored \"-Wtrigraphs\"")
int a??(1??); // -Wtrigraphs not suppressed
_Pragma ("GCC diagnostic ignored \"-Wdate-time\"")
const char date[] = __DATE__; // -Wdate-time not suppressed
_Pragma ("GCC diagnostic ignored \"-Wendif-labels\"")
_Pragma ("GCC diagnostic ignored \"-Wexpansion-to-defined\"")
#define BLA defined(FOO)
#if BLA // -Wexpansion-to-defined not suppressed
#endif BLA // -Wendif-labels not suppressed
void f (void)
{
_Pragma ("GCC diagnostic ignored \"-Wempty-body\"")
if (0) { } // -Wempty-body suppressed (good)
}
pr84127.c:2:4: warning: "/*" within comment [-Wcomment]
/* /* */ // -Wcomment not suppressed
pr84127.c:5:6: warning: trigraph ??( converted to [ [-Wtrigraphs]
int a??(1??); // -Wtrigraphs not suppressed
pr84127.c:5:8: warning: trigraph ??) converted to ] [-Wtrigraphs]
pr84127.c:8:22: warning: macro "__DATE__" might prevent reproducible builds
[-Wdate-time]
const char date[] = __DATE__; // -Wdate-time not suppressed
^~~~~~~~
pr84127.c:14:5: warning: this use of "defined" may not be portable
[-Wexpansion-to-defined]
#if BLA // -Wexpansion-to-defined not suppressed
^~~
pr84127.c:15:8: warning: extra tokens at end of #endif directive
[-Wendif-labels]
#endif BLA // -Wendif-labels not suppressed
^~~
More information about the Gcc-bugs
mailing list