]> Savannah Git Hosting - gnulib.git/commitdiff
verify: Avoid syntax error due to static_assert with clang in C++ mode.
authorBruno Haible <bruno@clisp.org>
Wed, 14 Sep 2022 20:21:47 +0000 (22:21 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 14 Sep 2022 20:21:47 +0000 (22:21 +0200)
* 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 <assert.h>.

ChangeLog
lib/verify.h
m4/assert_h.m4

index 199b088200795dc68fac9d7fed159f9ef2b42f4a..37d3ff7aa267469693fe03ec1f5a02b4372975cb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-09-14  Bruno Haible  <bruno@clisp.org>
+
+       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 <assert.h>.
+
 2022-09-14  Paul Eggert  <eggert@cs.ucla.edu>
 
        assert-h: work around include confusion
index 0f5f0edc86bea0110986e1b3ea348b9e1b8c6b14..99af802993e9af843a7c280fd1e9ce03d75b05fc 100644 (file)
@@ -228,7 +228,9 @@ template <int w>
 # 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.
index 43937869ecda953fd11e0ceda6ad1e79473b8d26..d61572113c76dac3c50e8f0217031937ba8e287f 100644 (file)
@@ -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 <assert.h>
  #undef/**/assert
 #endif])