summaryrefslogtreecommitdiffstats
path: root/gl/intprops-internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'gl/intprops-internal.h')
-rw-r--r--gl/intprops-internal.h34
1 files changed, 21 insertions, 13 deletions
diff --git a/gl/intprops-internal.h b/gl/intprops-internal.h
index 0467a9ca..7ace0cdd 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-2023 Free Software Foundation, Inc. 3 Copyright (C) 2001-2025 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
@@ -20,6 +20,11 @@
20 20
21#include <limits.h> 21#include <limits.h>
22 22
23/* Pacify GCC 13.2 in some calls to _GL_EXPR_SIGNED. */
24#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) && !defined __clang__
25# pragma GCC diagnostic ignored "-Wtype-limits"
26#endif
27
23/* Return a value with the common real type of E and V and the value of V. 28/* Return a value with the common real type of E and V and the value of V.
24 Do not evaluate E. */ 29 Do not evaluate E. */
25#define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v)) 30#define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v))
@@ -72,10 +77,11 @@
72 77
73/* Does the __typeof__ keyword work? This could be done by 78/* Does the __typeof__ keyword work? This could be done by
74 'configure', but for now it's easier to do it by hand. */ 79 'configure', but for now it's easier to do it by hand. */
75#if (2 <= __GNUC__ \ 80#if ((defined __GNUC__ && 2 <= __GNUC__) \
76 || (4 <= __clang_major__) \ 81 || (defined __clang_major__ && 4 <= __clang_major__) \
77 || (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \ 82 || (defined __IBMC__ && 1210 <= __IBMC__ && defined __IBM__TYPEOF__) \
78 || (0x5110 <= __SUNPRO_C && !__STDC__)) 83 || (defined __SUNPRO_C && 0x5110 <= __SUNPRO_C && !__STDC__) \
84 || (defined _MSC_VER && 1939 <= _MSC_VER))
79# define _GL_HAVE___TYPEOF__ 1 85# define _GL_HAVE___TYPEOF__ 1
80#else 86#else
81# define _GL_HAVE___TYPEOF__ 0 87# define _GL_HAVE___TYPEOF__ 0
@@ -114,8 +120,8 @@
114#endif 120#endif
115 121
116/* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */ 122/* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */
117#if defined __clang_major__ && __clang_major__ < 14 123#if defined __clang_major__ && __clang_major__ < 21
118/* Work around Clang bug <https://bugs.llvm.org/show_bug.cgi?id=16404>. */ 124/* Work around Clang bug <https://github.com/llvm/llvm-project/issues/16778>. */
119# define _GL_HAS_BUILTIN_MUL_OVERFLOW 0 125# define _GL_HAS_BUILTIN_MUL_OVERFLOW 0
120#else 126#else
121# define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW 127# define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW
@@ -158,13 +164,15 @@
158#if _GL_HAS_BUILTIN_MUL_OVERFLOW 164#if _GL_HAS_BUILTIN_MUL_OVERFLOW
159# if ((9 < __GNUC__ + (3 <= __GNUC_MINOR__) \ 165# if ((9 < __GNUC__ + (3 <= __GNUC_MINOR__) \
160 || (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) \ 166 || (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) \
161 && !defined __EDG__) 167 && !defined __clang__ && !defined __EDG__)
162# define _GL_INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r) 168# define _GL_INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r)
163# else 169# else
164 /* Work around GCC bug 91450. */ 170 /* Work around GCC bug 91450. */
165# define _GL_INT_MULTIPLY_WRAPV(a, b, r) \ 171# define _GL_INT_MULTIPLY_WRAPV(a, b, r) \
166 ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && _GL_EXPR_SIGNED (a) && _GL_EXPR_SIGNED (b) \ 172 ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && _GL_EXPR_SIGNED (a) && _GL_EXPR_SIGNED (b) \
167 && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \ 173 && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, \
174 (__typeof__ (*(r))) 0, \
175 (__typeof__ (*(r))) -1)) \
168 ? ((void) __builtin_mul_overflow (a, b, r), 1) \ 176 ? ((void) __builtin_mul_overflow (a, b, r), 1) \
169 : __builtin_mul_overflow (a, b, r)) 177 : __builtin_mul_overflow (a, b, r))
170# endif 178# endif
@@ -175,13 +183,13 @@
175 _GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW) 183 _GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW)
176#endif 184#endif
177 185
178/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See: 186/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25764. See:
179 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193 187 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193
180 https://llvm.org/bugs/show_bug.cgi?id=25390 188 https://github.com/llvm/llvm-project/issues/25764
181 For now, assume all versions of GCC-like compilers generate bogus 189 For now, assume GCC < 14 and all Clang versions generate bogus
182 warnings for _Generic. This matters only for compilers that 190 warnings for _Generic. This matters only for compilers that
183 lack relevant builtins. */ 191 lack relevant builtins. */
184#if __GNUC__ || defined __clang__ 192#if (__GNUC__ && __GNUC__ < 14) || defined __clang__
185# define _GL__GENERIC_BOGUS 1 193# define _GL__GENERIC_BOGUS 1
186#else 194#else
187# define _GL__GENERIC_BOGUS 0 195# define _GL__GENERIC_BOGUS 0