]> Savannah Git Hosting - gnulib.git/commitdiff
limits-h: Work around a clang 15 bug.
authorBruno Haible <bruno@clisp.org>
Thu, 9 Feb 2023 15:08:00 +0000 (16:08 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 9 Feb 2023 15:08:00 +0000 (16:08 +0100)
* m4/limits-h.m4 (gl_LIMITS_H): Test also for BOOL_MAX.
* lib/limits.in.h: Handle the case where BOOL_WIDTH is present and
BOOL_MAX is missing.
* doc/posix-headers/limits.texi: Mention the clang bug.

ChangeLog
lib/limits.in.h

index fc3663eedc273d4e76d35e7bbd316bd8787b6830..f0d757837e45666529922cdf432e8f5d8e5960ef 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
 
        limits-h: Work around a clang 15 bug.
        * m4/limits-h.m4 (gl_LIMITS_H): Test also for BOOL_MAX.
+       * lib/limits.in.h: Handle the case where BOOL_WIDTH is present and
+       BOOL_MAX is missing.
        * doc/posix-headers/limits.texi: Mention the clang bug.
 
 2023-02-09  Bruno Haible  <bruno@clisp.org>
index eaeac472299f1ec1f24487e8f989295a46b6658c..a01b4c6a28042c2486dd4bb1f317f2aa16076ea0 100644 (file)
 
 /* Macros specified by C23.  */
 
-#if (! defined BOOL_WIDTH \
-     && (defined _GNU_SOURCE \
-         || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__)))
-# define BOOL_MAX 1
-# define BOOL_WIDTH 1
+#if (defined _GNU_SOURCE \
+     || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__))
+# if ! defined BOOL_WIDTH
+#  define BOOL_WIDTH 1
+#  define BOOL_MAX 1
+# elif ! defined BOOL_MAX
+#  define BOOL_MAX ((((1U << (BOOL_WIDTH - 1)) - 1) << 1) + 1)
+# endif
 #endif
 
 #endif /* _@GUARD_PREFIX@_LIMITS_H */