diff options
Diffstat (limited to 'gl/verify.h')
| -rw-r--r-- | gl/verify.h | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/gl/verify.h b/gl/verify.h index 08268c24..3b01d7c2 100644 --- a/gl/verify.h +++ b/gl/verify.h | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* Compile-time assert-like macros. | 1 | /* Compile-time assert-like macros. |
| 2 | 2 | ||
| 3 | Copyright (C) 2005-2006, 2009-2024 Free Software Foundation, Inc. | 3 | Copyright (C) 2005-2006, 2009-2025 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is free software: you can redistribute it and/or modify | 5 | This file is free software: you can redistribute it and/or modify |
| 6 | it under the terms of the GNU Lesser General Public License as | 6 | it under the terms of the GNU Lesser General Public License as |
| @@ -34,11 +34,12 @@ | |||
| 34 | #ifndef __cplusplus | 34 | #ifndef __cplusplus |
| 35 | # if (201112 <= __STDC_VERSION__ \ | 35 | # if (201112 <= __STDC_VERSION__ \ |
| 36 | || (!defined __STRICT_ANSI__ \ | 36 | || (!defined __STRICT_ANSI__ \ |
| 37 | && (4 < __GNUC__ + (6 <= __GNUC_MINOR__) || 5 <= __clang_major__))) | 37 | && ((4 < __GNUC__ + (6 <= __GNUC_MINOR__) && !defined __clang__) \ |
| 38 | || 5 <= __clang_major__))) | ||
| 38 | # define _GL_HAVE__STATIC_ASSERT 1 | 39 | # define _GL_HAVE__STATIC_ASSERT 1 |
| 39 | # endif | 40 | # endif |
| 40 | # if (202311 <= __STDC_VERSION__ \ | 41 | # if (202311 <= __STDC_VERSION__ \ |
| 41 | || (!defined __STRICT_ANSI__ && 9 <= __GNUC__)) | 42 | || (!defined __STRICT_ANSI__ && 9 <= __GNUC__ && !defined __clang__)) |
| 42 | # define _GL_HAVE__STATIC_ASSERT1 1 | 43 | # define _GL_HAVE__STATIC_ASSERT1 1 |
| 43 | # endif | 44 | # endif |
| 44 | #endif | 45 | #endif |
| @@ -156,9 +157,10 @@ | |||
| 156 | #define _GL_CONCAT0(x, y) x##y | 157 | #define _GL_CONCAT0(x, y) x##y |
| 157 | 158 | ||
| 158 | /* _GL_COUNTER is an integer, preferably one that changes each time we | 159 | /* _GL_COUNTER is an integer, preferably one that changes each time we |
| 159 | use it. Use __COUNTER__ if it works, falling back on __LINE__ | 160 | use it. Use __COUNTER__ if it works (it does so with most compilers, |
| 160 | otherwise. __LINE__ isn't perfect, but it's better than a | 161 | see <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3457.htm>), |
| 161 | constant. */ | 162 | falling back on __LINE__ otherwise. __LINE__ isn't perfect, but it's |
| 163 | better than a constant. */ | ||
| 162 | #if defined __COUNTER__ && __COUNTER__ != __COUNTER__ | 164 | #if defined __COUNTER__ && __COUNTER__ != __COUNTER__ |
| 163 | # define _GL_COUNTER __COUNTER__ | 165 | # define _GL_COUNTER __COUNTER__ |
| 164 | #else | 166 | #else |
| @@ -215,7 +217,7 @@ template <int w> | |||
| 215 | # define _GL_VERIFY(R, DIAGNOSTIC, ...) \ | 217 | # define _GL_VERIFY(R, DIAGNOSTIC, ...) \ |
| 216 | extern int (*_GL_GENSYM (_gl_verify_function) (void)) \ | 218 | extern int (*_GL_GENSYM (_gl_verify_function) (void)) \ |
| 217 | [_GL_VERIFY_TRUE (R, DIAGNOSTIC)] | 219 | [_GL_VERIFY_TRUE (R, DIAGNOSTIC)] |
| 218 | # if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) | 220 | # if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) && !defined __clang__ |
| 219 | # pragma GCC diagnostic ignored "-Wnested-externs" | 221 | # pragma GCC diagnostic ignored "-Wnested-externs" |
| 220 | # endif | 222 | # endif |
| 221 | #endif | 223 | #endif |
| @@ -254,16 +256,32 @@ template <int w> | |||
| 254 | # endif | 256 | # endif |
| 255 | # endif | 257 | # endif |
| 256 | /* Define static_assert if needed. */ | 258 | /* Define static_assert if needed. */ |
| 259 | # if defined __cplusplus && defined __clang__ && __clang_major__ < 9 | ||
| 260 | /* clang++ before commit 5c739665a8721228cf6143fd4ef95870a59f55ae had a | ||
| 261 | two-arguments static_assert but not the one-argument static_assert. */ | ||
| 262 | # undef static_assert | ||
| 263 | # endif | ||
| 257 | # if (!defined static_assert \ | 264 | # if (!defined static_assert \ |
| 258 | && __STDC_VERSION__ < 202311 \ | 265 | && __STDC_VERSION__ < 202311 \ |
| 259 | && (!defined __cplusplus \ | 266 | && (!defined __cplusplus \ |
| 260 | || (__cpp_static_assert < 201411 \ | 267 | || (__cpp_static_assert < 201411 \ |
| 261 | && __GNUG__ < 6 && __clang_major__ < 6 && _MSC_VER < 1910))) | 268 | && __GNUG__ < 6 && __clang_major__ < 6 && _MSC_VER < 1910))) |
| 262 | # if defined __cplusplus && _MSC_VER >= 1900 && !defined __clang__ | 269 | # if (defined __cplusplus && defined __GNUG__ && __GNUG__ < 6 \ |
| 270 | && __cplusplus == 201103L && !defined __clang__) | ||
| 271 | /* g++ >= 4.7, < 6 with option -std=c++11 or -std=gnu++11 supports the | ||
| 272 | two-arguments static_assert but not the one-argument static_assert, and | ||
| 273 | it does not support _Static_assert. | ||
| 274 | We have to play preprocessor tricks to distinguish the two cases. */ | ||
| 275 | # define _GL_SA1(a1) static_assert ((a1), "static assertion failed") | ||
| 276 | # define _GL_SA2 static_assert | ||
| 277 | # define _GL_SA3 static_assert | ||
| 278 | # define _GL_SA_PICK(x1,x2,x3,x4,...) x4 | ||
| 279 | # define static_assert(...) _GL_SA_PICK(__VA_ARGS__,_GL_SA3,_GL_SA2,_GL_SA1) (__VA_ARGS__) | ||
| 280 | # elif defined __cplusplus && _MSC_VER >= 1900 && !defined __clang__ | ||
| 263 | /* MSVC 14 in C++ mode supports the two-arguments static_assert but not | 281 | /* MSVC 14 in C++ mode supports the two-arguments static_assert but not |
| 264 | the one-argument static_assert, and it does not support _Static_assert. | 282 | the one-argument static_assert, and it does not support _Static_assert. |
| 265 | We have to play preprocessor tricks to distinguish the two cases. | 283 | We have to play preprocessor tricks to distinguish the two cases. |
| 266 | Since the MSVC preprocessor is not ISO C compliant (see above),. | 284 | Since the MSVC preprocessor is not ISO C compliant (see above), |
| 267 | the solution is specific to MSVC. */ | 285 | the solution is specific to MSVC. */ |
| 268 | # define _GL_EXPAND(x) x | 286 | # define _GL_EXPAND(x) x |
| 269 | # define _GL_SA1(a1) static_assert ((a1), "static assertion failed") | 287 | # define _GL_SA1(a1) static_assert ((a1), "static assertion failed") |
| @@ -294,7 +312,7 @@ template <int w> | |||
| 294 | #ifndef _GL_HAS_BUILTIN_UNREACHABLE | 312 | #ifndef _GL_HAS_BUILTIN_UNREACHABLE |
| 295 | # if defined __clang_major__ && __clang_major__ < 5 | 313 | # if defined __clang_major__ && __clang_major__ < 5 |
| 296 | # define _GL_HAS_BUILTIN_UNREACHABLE 0 | 314 | # define _GL_HAS_BUILTIN_UNREACHABLE 0 |
| 297 | # elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) | 315 | # elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) && !defined __clang__ |
| 298 | # define _GL_HAS_BUILTIN_UNREACHABLE 1 | 316 | # define _GL_HAS_BUILTIN_UNREACHABLE 1 |
| 299 | # elif defined __has_builtin | 317 | # elif defined __has_builtin |
| 300 | # define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable) | 318 | # define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable) |
