]> Savannah Git Hosting - gnulib.git/commitdiff
assert-h: suppress clang false alarms
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 21 Sep 2022 23:37:37 +0000 (16:37 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 21 Sep 2022 23:38:50 +0000 (16:38 -0700)
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
m4/assert_h.m4

index 29cea3c545e43020c56b7d4bd68e5b13116cf99c..a6399f10484bd351c48b24f52d0433dd496f7ebc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2022-09-21  Paul Eggert  <eggert@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  <bruno@clisp.org>
 
        Add another helper script for creating testdirs.
index d61572113c76dac3c50e8f0217031937ba8e287f..c411a34aa7bd2dc6fa8f250b17a00badbb6ed328 100644 (file)
@@ -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");