https://bugs.llvm.org/show_bug.cgi?id=43584
Bug ID: 43584
Summary: clang-cl preprocesses variadic macros differently than
clang and msvc
Product: clang
Version: 9.0
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected]
For all version of clang I've tested (7.0.0, 8.0.0 and 9.0.0),
#define THIRD(ARG_1, ARG_2, ARG_3, ...) ARG_3
#define DEMO(...) THIRD(__VA_ARGS__, 3, 4, 5)
int main() {
return DEMO(,);
}
turns into
int main() {
return 3;
}
when preprocessed with `clang -E demo.cpp`, but turns into
int main() {
return 4;
}
when preprocessed with `clang-cl /E demo.cpp`, regardless of whether clang-cl
is run on Linux or on Windows.
My first assumption was that clang-cl is using some kind of MSVC compatibility
mode for the preprocessor, but as it turns out it isn't doing the same thing as
msvc either: DEMO(1, 2) expands to 4 with MSVC, but to 3 with clang-cl.
Note in particular that DEMO(,) and DEMO(1, 2) expand to different results with
clang-cl, while that does not happen with MSVC.
This bug currently breaks googletest's MOCK_METHOD macro with clang-cl (see
https://github.com/google/googletest/issues/2490)
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs