[llvm-bugs] [Bug 43584] New: clang-cl preprocesses variadic macros differently than clang and msvc
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Oct 7 02:32:29 PDT 2019
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: unassignedclangbugs at nondot.org
Reporter: berglerma at gmail.com
CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191007/dc5df390/attachment.html>
More information about the llvm-bugs
mailing list