From: Bruno Haible Date: Wed, 14 Sep 2022 20:21:47 +0000 (+0200) Subject: verify: Avoid syntax error due to static_assert with clang in C++ mode. X-Git-Tag: v1.0~2018 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=d6f25832c0a02500602e44153e265e10a1d67ce4;p=gnulib.git verify: Avoid syntax error due to static_assert with clang in C++ mode. * lib/verify.h (static_assert): Don't define in clang C++ 6 or newer. * m4/assert_h.m4 (gl_ASSERT_H): If we don't need to define static_assert with clang in C++ mode, don't include . --- diff --git a/ChangeLog b/ChangeLog index 199b088200..37d3ff7aa2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2022-09-14 Bruno Haible + + verify: Avoid syntax error due to static_assert with clang in C++ mode. + * lib/verify.h (static_assert): Don't define in clang C++ 6 or newer. + * m4/assert_h.m4 (gl_ASSERT_H): If we don't need to define static_assert + with clang in C++ mode, don't include . + 2022-09-14 Paul Eggert assert-h: work around include confusion diff --git a/lib/verify.h b/lib/verify.h index 0f5f0edc86..99af802993 100644 --- a/lib/verify.h +++ b/lib/verify.h @@ -228,7 +228,9 @@ template # endif # if (!defined static_assert \ && __STDC_VERSION__ < 202311 \ - && __cpp_static_assert < 201411 && __GNUG__ < 6) + && (!defined __cplusplus \ + || (__cpp_static_assert < 201411 \ + && __GNUG__ < 6 && __clang_major__ < 6))) # if defined __cplusplus && _MSC_VER >= 1900 && !defined __clang__ /* MSVC 14 in C++ mode supports the two-arguments static_assert but not the one-argument static_assert, and it does not support _Static_assert. diff --git a/m4/assert_h.m4 b/m4/assert_h.m4 index 43937869ec..d61572113c 100644 --- a/m4/assert_h.m4 +++ b/m4/assert_h.m4 @@ -48,7 +48,9 @@ AC_DEFUN([gl_ASSERT_H], dnl so that 'configure' does not comment it out. AH_VERBATIM([zzstatic_assert], [#if (!defined HAVE_C_STATIC_ASSERT && !defined assert \ - && __cpp_static_assert < 201411 && __GNUG__ < 6) + && (!defined __cplusplus \ + || (__cpp_static_assert < 201411 \ + && __GNUG__ < 6 && __clang_major__ < 6))) #include #undef/**/assert #endif])