summaryrefslogtreecommitdiffstats
path: root/gl/m4/assert_h.m4
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-12-28 12:13:40 +0100
committerLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-12-28 12:13:40 +0100
commitb0afb8fe0ff1d87165af9df61501197a06240dda (patch)
tree274ac6a96c53ef4c19ab4974ce24a06a233128c5 /gl/m4/assert_h.m4
parent68fc05381ee5fa0aee1413118fbb3d81ca888b09 (diff)
downloadmonitoring-plugins-b0afb8fe0ff1d87165af9df61501197a06240dda.tar.gz
Sync with Gnulib stable-202507 code (a8ac9f9ce5)
Diffstat (limited to 'gl/m4/assert_h.m4')
-rw-r--r--gl/m4/assert_h.m476
1 files changed, 47 insertions, 29 deletions
diff --git a/gl/m4/assert_h.m4 b/gl/m4/assert_h.m4
index b90d0f19..e77524ca 100644
--- a/gl/m4/assert_h.m4
+++ b/gl/m4/assert_h.m4
@@ -1,9 +1,10 @@
1# assert_h.m4 1# assert_h.m4
2# serial 1 2# serial 5
3dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. 3dnl Copyright (C) 2011-2025 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
7 8
8dnl From Paul Eggert. 9dnl From Paul Eggert.
9 10
@@ -12,30 +13,31 @@ AC_DEFUN([gl_ASSERT_H],
12 AC_CACHE_CHECK([for static_assert], [gl_cv_static_assert], 13 AC_CACHE_CHECK([for static_assert], [gl_cv_static_assert],
13 [gl_saved_CFLAGS=$CFLAGS 14 [gl_saved_CFLAGS=$CFLAGS
14 for gl_working in "yes, a keyword" "yes, an <assert.h> macro"; do 15 for gl_working in "yes, a keyword" "yes, an <assert.h> macro"; do
15 AS_CASE([$gl_working], 16 AS_CASE([$gl_working],
16 [*assert.h*], [CFLAGS="$gl_saved_CFLAGS -DINCLUDE_ASSERT_H"]) 17 [*assert.h*], [CFLAGS="$gl_saved_CFLAGS -DINCLUDE_ASSERT_H"])
17 18 AC_COMPILE_IFELSE(
18 AC_COMPILE_IFELSE( 19 [AC_LANG_PROGRAM(
19 [AC_LANG_PROGRAM( 20 [[#if defined __clang__ && __STDC_VERSION__ < 202311
20 [[#if defined __clang__ && __STDC_VERSION__ < 202311 21 #pragma clang diagnostic error "-Wc2x-extensions"
21 #pragma clang diagnostic error "-Wc2x-extensions" 22 #pragma clang diagnostic error "-Wc++1z-extensions"
22 #pragma clang diagnostic error "-Wc++1z-extensions" 23 #endif
23 #endif 24 #ifdef INCLUDE_ASSERT_H
24 #ifdef INCLUDE_ASSERT_H 25 #include <assert.h>
25 #include <assert.h> 26 #endif
26 #endif 27 static_assert (2 + 2 == 4, "arithmetic does not work");
27 static_assert (2 + 2 == 4, "arithmetic does not work"); 28 static_assert (2 + 2 == 4);
28 static_assert (2 + 2 == 4); 29 ]],
29 ]], 30 [[
30 [[ 31 static_assert (sizeof (char) == 1, "sizeof does not work");
31 static_assert (sizeof (char) == 1, "sizeof does not work"); 32 static_assert (sizeof (char) == 1);
32 static_assert (sizeof (char) == 1); 33 ]])
33 ]])], 34 ],
34 [gl_cv_static_assert=$gl_working], 35 [gl_cv_static_assert=$gl_working],
35 [gl_cv_static_assert=no]) 36 [gl_cv_static_assert=no])
36 CFLAGS=$gl_saved_CFLAGS 37 CFLAGS=$gl_saved_CFLAGS
37 test "$gl_cv_static_assert" != no && break 38 test "$gl_cv_static_assert" != no && break
38 done]) 39 done
40 ])
39 41
40 GL_GENERATE_ASSERT_H=false 42 GL_GENERATE_ASSERT_H=false
41 AS_CASE([$gl_cv_static_assert], 43 AS_CASE([$gl_cv_static_assert],
@@ -48,6 +50,10 @@ AC_DEFUN([gl_ASSERT_H],
48 50
49 dnl The "zz" puts this toward config.h's end, to avoid potential 51 dnl The "zz" puts this toward config.h's end, to avoid potential
50 dnl collisions with other definitions. 52 dnl collisions with other definitions.
53 dnl Hardcode the known configuration results for GCC and clang, so that
54 dnl a configuration made with the C compiler works also with the C++ compiler
55 dnl and vice versa.
56 dnl The seemingly redundant parentheses are necessary for MSVC 14.
51 dnl #undef assert so that programs are not tempted to use it without 57 dnl #undef assert so that programs are not tempted to use it without
52 dnl specifically including assert.h. 58 dnl specifically including assert.h.
53 dnl #undef __ASSERT_H__ so that on IRIX, when programs later include 59 dnl #undef __ASSERT_H__ so that on IRIX, when programs later include
@@ -55,7 +61,18 @@ AC_DEFUN([gl_ASSERT_H],
55 dnl Break the #undef_s apart with a comment so that 'configure' does 61 dnl Break the #undef_s apart with a comment so that 'configure' does
56 dnl not comment them out. 62 dnl not comment them out.
57 AH_VERBATIM([zzstatic_assert], 63 AH_VERBATIM([zzstatic_assert],
58[#if (!defined HAVE_C_STATIC_ASSERT && !defined assert \ 64[#if (!(defined __clang__ \
65 ? (defined __cplusplus \
66 ? __cplusplus >= 201703L \
67 : __STDC_VERSION__ >= 202000L && __clang_major__ >= 16 \
68 && !defined __sun) \
69 : (defined __GNUC__ \
70 ? (defined __cplusplus \
71 ? __cplusplus >= 201103L && __GNUG__ >= 6 \
72 : __STDC_VERSION__ >= 202000L && __GNUC__ >= 13 \
73 && !defined __sun) \
74 : defined HAVE_C_STATIC_ASSERT)) \
75 && !defined assert \
59 && (!defined __cplusplus \ 76 && (!defined __cplusplus \
60 || (__cpp_static_assert < 201411 \ 77 || (__cpp_static_assert < 201411 \
61 && __GNUG__ < 6 && __clang_major__ < 6))) 78 && __GNUG__ < 6 && __clang_major__ < 6)))
@@ -65,8 +82,9 @@ AC_DEFUN([gl_ASSERT_H],
65 #undef/**/__ASSERT_H__ 82 #undef/**/__ASSERT_H__
66 #endif 83 #endif
67 /* Solaris 11.4 <assert.h> defines static_assert as a macro with 2 arguments. 84 /* Solaris 11.4 <assert.h> defines static_assert as a macro with 2 arguments.
68 We need it also to be invocable with a single argument. */ 85 We need it also to be invocable with a single argument.
69 #if defined __sun && (__STDC_VERSION__ - 0 >= 201112L) && !defined __cplusplus 86 Haiku 2022 <assert.h> does not define static_assert at all. */
87 #if (__STDC_VERSION__ - 0 >= 201112L) && !defined __cplusplus
70 #undef/**/static_assert 88 #undef/**/static_assert
71 #define static_assert _Static_assert 89 #define static_assert _Static_assert
72 #endif 90 #endif