[Bug driver/85153] _Pragma to disable -Wswitch-unreachable diagnostic not properly working when used within preprocessor macro
falemagn at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sun Apr 1 16:03:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85153
--- Comment #2 from Fabio Alemagna <falemagn at gmail dot com> ---
And removing the exclamation mark from the if condition actually makes it work
again, but only if the B and E macro are wrapped within the Y() macro,
otherwise it still complains, now indicating the parenthesis as the problem:
#define X6() B if (x) E
int test9(int val) {
switch (val) {
X6() {
case 1: return 10;
}
}
return 0;
}
pragmatest.cpp: In function ‘int test9(int)’:
pragmatest.cpp:96:25: warning: statement will never be executed
[-Wswitch-unreachable]
#define X6() B if (x) E
^
pragmatest.cpp:99:21: note: in expansion of macro ‘X6’
X6() {
^~
More information about the Gcc-bugs
mailing list