diff options
Diffstat (limited to 'gl/intprops-internal.h')
| -rw-r--r-- | gl/intprops-internal.h | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/gl/intprops-internal.h b/gl/intprops-internal.h index b5ba8d7c..0df385b9 100644 --- a/gl/intprops-internal.h +++ b/gl/intprops-internal.h | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* intprops-internal.h -- properties of integer types not visible to users | 1 | /* intprops-internal.h -- properties of integer types not visible to users |
| 2 | 2 | ||
| 3 | Copyright (C) 2001-2024 Free Software Foundation, Inc. | 3 | Copyright (C) 2001-2026 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This program is free software: you can redistribute it and/or modify it | 5 | This program is free software: you can redistribute it and/or modify it |
| 6 | under the terms of the GNU Lesser General Public License as published | 6 | under the terms of the GNU Lesser General Public License as published |
| @@ -21,7 +21,7 @@ | |||
| 21 | #include <limits.h> | 21 | #include <limits.h> |
| 22 | 22 | ||
| 23 | /* Pacify GCC 13.2 in some calls to _GL_EXPR_SIGNED. */ | 23 | /* Pacify GCC 13.2 in some calls to _GL_EXPR_SIGNED. */ |
| 24 | #if defined __GNUC__ && 4 < __GNUC__ + (3 <= __GNUC_MINOR__) | 24 | #if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) && !defined __clang__ |
| 25 | # pragma GCC diagnostic ignored "-Wtype-limits" | 25 | # pragma GCC diagnostic ignored "-Wtype-limits" |
| 26 | #endif | 26 | #endif |
| 27 | 27 | ||
| @@ -29,10 +29,6 @@ | |||
| 29 | Do not evaluate E. */ | 29 | Do not evaluate E. */ |
| 30 | #define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v)) | 30 | #define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v)) |
| 31 | 31 | ||
| 32 | /* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see | ||
| 33 | <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00406.html>. */ | ||
| 34 | #define _GL_INT_NEGATE_CONVERT(e, v) ((1 ? 0 : (e)) - (v)) | ||
| 35 | |||
| 36 | /* The extra casts in the following macros work around compiler bugs, | 32 | /* The extra casts in the following macros work around compiler bugs, |
| 37 | e.g., in Cray C 5.0.3.0. */ | 33 | e.g., in Cray C 5.0.3.0. */ |
| 38 | 34 | ||
| @@ -41,7 +37,7 @@ | |||
| 41 | 37 | ||
| 42 | /* Return 1 if the real expression E, after promotion, has a | 38 | /* Return 1 if the real expression E, after promotion, has a |
| 43 | signed or floating type. Do not evaluate E. */ | 39 | signed or floating type. Do not evaluate E. */ |
| 44 | #define _GL_EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0) | 40 | #define _GL_EXPR_SIGNED(e) (_GL_INT_CONVERT (e, -1) < 0) |
| 45 | 41 | ||
| 46 | 42 | ||
| 47 | /* Minimum and maximum values for integer types and expressions. */ | 43 | /* Minimum and maximum values for integer types and expressions. */ |
| @@ -60,7 +56,7 @@ | |||
| 60 | #define _GL_INT_MAXIMUM(e) \ | 56 | #define _GL_INT_MAXIMUM(e) \ |
| 61 | (_GL_EXPR_SIGNED (e) \ | 57 | (_GL_EXPR_SIGNED (e) \ |
| 62 | ? _GL_SIGNED_INT_MAXIMUM (e) \ | 58 | ? _GL_SIGNED_INT_MAXIMUM (e) \ |
| 63 | : _GL_INT_NEGATE_CONVERT (e, 1)) | 59 | : _GL_INT_CONVERT (e, -1)) |
| 64 | #define _GL_SIGNED_INT_MAXIMUM(e) \ | 60 | #define _GL_SIGNED_INT_MAXIMUM(e) \ |
| 65 | (((_GL_INT_CONVERT (e, 1) << (_GL_TYPE_WIDTH (+ (e)) - 2)) - 1) * 2 + 1) | 61 | (((_GL_INT_CONVERT (e, 1) << (_GL_TYPE_WIDTH (+ (e)) - 2)) - 1) * 2 + 1) |
| 66 | 62 | ||
| @@ -77,10 +73,11 @@ | |||
| 77 | 73 | ||
| 78 | /* Does the __typeof__ keyword work? This could be done by | 74 | /* Does the __typeof__ keyword work? This could be done by |
| 79 | 'configure', but for now it's easier to do it by hand. */ | 75 | 'configure', but for now it's easier to do it by hand. */ |
| 80 | #if (2 <= __GNUC__ \ | 76 | #if ((defined __GNUC__ && 2 <= __GNUC__) \ |
| 81 | || (4 <= __clang_major__) \ | 77 | || (defined __clang_major__ && 4 <= __clang_major__) \ |
| 82 | || (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \ | 78 | || (defined __IBMC__ && 1210 <= __IBMC__ && defined __IBM__TYPEOF__) \ |
| 83 | || (0x5110 <= __SUNPRO_C && !__STDC__)) | 79 | || (defined __SUNPRO_C && 0x5110 <= __SUNPRO_C && !__STDC__) \ |
| 80 | || (defined _MSC_VER && 1939 <= _MSC_VER)) | ||
| 84 | # define _GL_HAVE___TYPEOF__ 1 | 81 | # define _GL_HAVE___TYPEOF__ 1 |
| 85 | #else | 82 | #else |
| 86 | # define _GL_HAVE___TYPEOF__ 0 | 83 | # define _GL_HAVE___TYPEOF__ 0 |
| @@ -111,7 +108,7 @@ | |||
| 111 | #elif defined __has_builtin | 108 | #elif defined __has_builtin |
| 112 | # define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow) | 109 | # define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow) |
| 113 | /* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x, | 110 | /* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x, |
| 114 | see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269>. */ | 111 | see <https://gcc.gnu.org/PR98269>. */ |
| 115 | #elif 7 <= __GNUC__ | 112 | #elif 7 <= __GNUC__ |
| 116 | # define _GL_HAS_BUILTIN_ADD_OVERFLOW 1 | 113 | # define _GL_HAS_BUILTIN_ADD_OVERFLOW 1 |
| 117 | #else | 114 | #else |
| @@ -119,8 +116,8 @@ | |||
| 119 | #endif | 116 | #endif |
| 120 | 117 | ||
| 121 | /* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */ | 118 | /* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */ |
| 122 | #if defined __clang_major__ && __clang_major__ < 14 | 119 | #if defined __clang_major__ && __clang_major__ < 21 |
| 123 | /* Work around Clang bug <https://bugs.llvm.org/show_bug.cgi?id=16404>. */ | 120 | /* Work around Clang bug <https://github.com/llvm/llvm-project/issues/16778>. */ |
| 124 | # define _GL_HAS_BUILTIN_MUL_OVERFLOW 0 | 121 | # define _GL_HAS_BUILTIN_MUL_OVERFLOW 0 |
| 125 | #else | 122 | #else |
| 126 | # define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW | 123 | # define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW |
| @@ -163,7 +160,7 @@ | |||
| 163 | #if _GL_HAS_BUILTIN_MUL_OVERFLOW | 160 | #if _GL_HAS_BUILTIN_MUL_OVERFLOW |
| 164 | # if ((9 < __GNUC__ + (3 <= __GNUC_MINOR__) \ | 161 | # if ((9 < __GNUC__ + (3 <= __GNUC_MINOR__) \ |
| 165 | || (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) \ | 162 | || (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) \ |
| 166 | && !defined __EDG__) | 163 | && !defined __clang__ && !defined __EDG__) |
| 167 | # define _GL_INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r) | 164 | # define _GL_INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r) |
| 168 | # else | 165 | # else |
| 169 | /* Work around GCC bug 91450. */ | 166 | /* Work around GCC bug 91450. */ |
| @@ -182,13 +179,13 @@ | |||
| 182 | _GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW) | 179 | _GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW) |
| 183 | #endif | 180 | #endif |
| 184 | 181 | ||
| 185 | /* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See: | 182 | /* Nonzero if this compiler has GCC bug 68193 or Clang bug 25764. See: |
| 186 | https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193 | 183 | https://gcc.gnu.org/PR68193 |
| 187 | https://llvm.org/bugs/show_bug.cgi?id=25390 | 184 | https://github.com/llvm/llvm-project/issues/25764 |
| 188 | For now, assume all versions of GCC-like compilers generate bogus | 185 | For now, assume GCC < 14 and all Clang versions generate bogus |
| 189 | warnings for _Generic. This matters only for compilers that | 186 | warnings for _Generic. This matters only for compilers that |
| 190 | lack relevant builtins. */ | 187 | lack relevant builtins. */ |
| 191 | #if __GNUC__ || defined __clang__ | 188 | #if (__GNUC__ && __GNUC__ < 14) || defined __clang__ |
| 192 | # define _GL__GENERIC_BOGUS 1 | 189 | # define _GL__GENERIC_BOGUS 1 |
| 193 | #else | 190 | #else |
| 194 | # define _GL__GENERIC_BOGUS 0 | 191 | # define _GL__GENERIC_BOGUS 0 |
