Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

clang-cl: ignore /Zc:preprocessor #47189

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR48220
Status NEW
Importance P enhancement
Reported by Lev Rumyantsev (lev.rumyantsev@gmail.com)
Reported on 2020-11-18 14:09:22 -0800
Last modified on 2021-01-10 09:58:44 -0800
Version unspecified
Hardware PC All
CC llvm-bugs@lists.llvm.org, neeilans@live.com, patrick.pelissier@gmail.com, richard-llvm@metafoo.co.uk
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Visual C++ 2019 has new compiler option /Zc:preprocessor for ISO C++
conformance. As clang should be conforming by default, it should ignore them
instead of issuing a warning "argument unused during compilation".
https://devblogs.microsoft.com/cppblog/announcing-full-support-for-a-c-c-conformant-preprocessor-in-msvc/
https://docs.microsoft.com/en-us/cpp/build/reference/zc-conformance?view=msvc-160
Quuxplusone commented 3 years ago
It seems that there is more to do than just ignoring the warning.

The following code :

#define M_RETI_ARG76(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13,
_14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29,
_30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45,
_46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61,
_62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, ...)
_76

#define M_COMMA_P(...)              M_RETI_ARG76(__VA_ARGS__, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, useless)

M_COMMA_P( , )
M_COMMA_P( a )

produces when preprocessed (-E) :
1
0
on GCC (all), CLANG (Linux & MacOs), TCC, MSVC CL (/Zc:preprocessor)

whereas it produces :
0
0
on CLANG (Windows), MSVS CL (no /Zc:preprocessor)