Closed
Description
See https://godbolt.org/z/szcWh6Mqa
For this small program which uses macros,
#define ODD_NUMBERS \
1 \
case 3: \
case 5
#define EVEN_NUMBERS \
0: \
case 2: \
case 4
int classify(int x) {
switch (x) {
case 1:
//case 1
case 3:
case 5: return 0;
case 0:
case 2:
case 4: return 1;
default: return 2;
}
}
int classify1(int x) {
switch (x) {
case ODD_NUMBERS: return 0;
case EVEN_NUMBERS: return 1;
default: return 2;
}
}
int main() {
return classify(0) + classify1(1);
}
The missing :
after case 1 in the non-macro version is reported with proper location:
<source>:15:9: error: expected ':' after 'case'
15 | case 1
| ^
| :
However, the missing :
for the case in macro is just reported as:
error: expected ':' after 'case'
with no line information.