#include <cstdio>
using namespace std;
int main()
{
#define TEST(v1, v2, v3) \
if( v1 && v2 || v3) \
printf("hello test\n");
bool a=1, b=1, c=1;
if( a && b || c)
printf("hello world\n");
TEST(a, b,c );
return 0;
}
Both clang 17.0.1 and 18.1.0,clang++ test.cpp -o test -Wall only report 1 warning but ignoring the warning within TEST macro。
Case: https://godbolt.org/z/8WjWfv8TY
If separate into preprocess and compile phases, the compiler reports 2 warnings exactly.
clang++ -E test.cpp -o test.ii -Wall and clang++ -c test.ii -o test.o -Wall
Preprocess output: https://godbolt.org/z/hjM4o7q78
Compile output: https://godbolt.org/z/aM65z5j7f
With the following minimum case
Both clang 17.0.1 and 18.1.0,
Case: https://godbolt.org/z/8WjWfv8TY
clang++ test.cpp -o test -Wall
only report 1 warning but ignoring the warning within TEST macro。If separate into preprocess and compile phases, the compiler reports 2 warnings exactly.
Preprocess output: https://godbolt.org/z/hjM4o7q78
Compile output: https://godbolt.org/z/aM65z5j7f
clang++ -E test.cpp -o test.ii -Wall
andclang++ -c test.ii -o test.o -Wall