Fixes #26916 by disabling the warning -Wgnu-zero-variadic-macro-arguments when clang is used as the compiler.
Also see the comments
- Proposed changes in the bug #26916 (comment)
- Proposed changes when moving to a variadic maro: #26593 (review)
Fixes #26916 by disabling the warning -Wgnu-zero-variadic-macro-arguments when clang is used as the compiler.
Also see the comments
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--021abf342d371248e50ceaed478a90ca-->
See the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
<!--174a7506f384e20aa4161008e828411d-->
No conflicts as of last run.
Fixes #26916 by disabling the warning `-Wgnu-zero-variadic-macro-arguments` when clang is used as the compiler.
Maybe add a check to configure.ac whether ignoring of -Wgnu-zero-variadic-macro-arguments is #26916 (comment) required?
Sounds good, but I have no idea how to do this with configure.ac... But it's also possible to do this in code level, I've now added a __cplusplus < 202002L so disabling the warning only happens when compiling below c++20
Concept ACK and thank you for looking into this!
I would include this in #26593 (e.g. with #26593 (review)) too. If #26916 is blocking something (e.g. switching to a newer clang) I think merging this PR here first should be preferred as #26593 is a bigger change that might take a bit longer.
Maybe add a check to configure.ac whether ignoring of -Wgnu-zero-variadic-macro-arguments is #26916 (comment) required?
Sounds good, but I have no idea how to do this with
configure.ac...
Something like in this branch:
--- a/configure.ac
+++ b/configure.ac
@@ -470,6 +470,19 @@ if test "$CXXFLAGS_overridden" = "no"; then
if test "$suppress_external_warnings" != "yes" ; then
AX_CHECK_COMPILE_FLAG([-Wdeprecated-copy], [NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-deprecated-copy"], [], [$CXXFLAG_WERROR])
fi
+
+ AX_CHECK_COMPILE_FLAG([-Wgnu-zero-variadic-macro-arguments],
+ [
+ TEMP_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="-Wgnu-zero-variadic-macro-arguments $CXXFLAG_WERROR $CXXFLAGS"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+ #define VARIADIC_MACRO(a, ...) f(__VA_ARGS__)
+ void f() {}
+ int main() { VARIADIC_MACRO(42); }
+ ]])], [],
+ [NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-gnu-zero-variadic-macro-arguments"])
+ CXXFLAGS="$TEMP_CXXFLAGS"
+ ], [], [$CXXFLAG_WERROR])
fi
dnl Don't allow extended (non-ASCII) symbols in identifiers. This is easier for code review.
utACK
Manually setting that flag by overriding CXXFLAGS disables a whole bunch of debugging warnings, so handling it directly seems very helpful.
21 | -#define TRACE9(context, event, a, b, c, d, e, f, g, h, i) DTRACE_PROBE9(context, event, a, b, c, d, e, f, g, h, i) 22 | -#define TRACE10(context, event, a, b, c, d, e, f, g, h, i, j) DTRACE_PROBE10(context, event, a, b, c, d, e, f, g, h, i, j) 23 | -#define TRACE11(context, event, a, b, c, d, e, f, g, h, i, j, k) DTRACE_PROBE11(context, event, a, b, c, d, e, f, g, h, i, j, k) 24 | -#define TRACE12(context, event, a, b, c, d, e, f, g, h, i, j, k, l) DTRACE_PROBE12(context, event, a, b, c, d, e, f, g, h, i, j, k, l) 25 | +// Disabling this warning can be removed once we switch to C++20 26 | +#if defined(__clang__) && __cplusplus < 202002L
Generally not a huge fan of (in code) compiler and c++ version specific work arounds, but I think this is use-specific enough, with a clear (future) time for removal.
ACK 5197660e947435e510ef3ef72be8be8dee3ffa41 - checked that this fixes the warnings under Clang.