Suppress scads of annoying warnings from clang version 14.0.5 (Fedora 14.0.5-1.fc36) of the form "warning: '_Static_assert' with no message is a C2x extension [-Wc2x-extensions]", by refusing to use single-arg static_assert with older clang. * m4/assert_h.m4 (gl_ASSERT_H): Turn -Wc2x-extensions from a warning into an error when testing static_assert, so that the annoying diagnostic causes the test to fail, which causes assert.h to be replaced in a way that suppresses the diagnostic during the real build. --- ChangeLog | 13 +++++++++++++ m4/assert_h.m4 | 5 ++++- 2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog index 29cea3c545..a6399f1048 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2022-09-21 Paul Eggert <egg...@cs.ucla.edu> + + assert-h: suppress clang false alarms + Suppress scads of annoying warnings from clang version 14.0.5 + (Fedora 14.0.5-1.fc36) of the form "warning: '_Static_assert' with + no message is a C2x extension [-Wc2x-extensions]", + by refusing to use single-arg static_assert with older clang. + * m4/assert_h.m4 (gl_ASSERT_H): Turn -Wc2x-extensions from a + warning into an error when testing static_assert, so that the + annoying diagnostic causes the test to fail, which causes assert.h + to be replaced in a way that suppresses the diagnostic during + the real build. + 2022-09-20 Bruno Haible <br...@clisp.org> Add another helper script for creating testdirs. diff --git a/m4/assert_h.m4 b/m4/assert_h.m4 index d61572113c..c411a34aa7 100644 --- a/m4/assert_h.m4 +++ b/m4/assert_h.m4 @@ -16,7 +16,10 @@ AC_DEFUN([gl_ASSERT_H], AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( - [[#ifdef INCLUDE_ASSERT_H + [[#if defined __clang__ && __STDC_VERSION__ < 202311 + #pragma clang diagnostic error "-Wc2x-extensions" + #endif + #ifdef INCLUDE_ASSERT_H #include <assert.h> #endif static_assert (2 + 2 == 4, "arithmetic does not work"); -- 2.37.3