]> Savannah Git Hosting - gnulib.git/commitdiff
verify: work around xlclang 16.1 compiler bug
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 13 Jan 2023 22:32:11 +0000 (14:32 -0800)
committerBruno Haible <bruno@clisp.org>
Sat, 14 Jan 2023 20:30:20 +0000 (21:30 +0100)
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/grep-devel/2023-01/msg00003.html
* lib/verify.h (_GL_HAS_BUILTIN_TRAP, _GL_HAS_BUILTIN_UNREACHABLE):
Define to 0 if compiler advertises itself as clang before version 5.
xlclang 16.1 advertises itself as 4.0.1 and this patch works
around what appears to be a compiler bug when compiling dfa.c in
bleeding-edge grep.

ChangeLog
lib/verify.h

index 4ad7ed97d667a8f16cb143e8e0d28c0fc84d9338..05c0d3db0b21ea09bc3c6c2e4cd456bfa52a0506 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2023-01-13  Paul Eggert  <eggert@cs.ucla.edu>
+
+       verify: work around xlclang 16.1 compiler bug
+       Problem reported by Bruno Haible in:
+       https://lists.gnu.org/r/grep-devel/2023-01/msg00003.html
+       * lib/verify.h (_GL_HAS_BUILTIN_TRAP, _GL_HAS_BUILTIN_UNREACHABLE):
+       Define to 0 if compiler advertises itself as clang before version 5.
+       xlclang 16.1 advertises itself as 4.0.1 and this patch works
+       around what appears to be a compiler bug when compiling dfa.c in
+       bleeding-edge grep.
+
 2023-01-13  Paul Eggert  <eggert@cs.ucla.edu>
 
        assert-h: fix configure comment-out
index 17d6e78c816a1738e91dea8bc06b2c2c674396a4..b63cb264321f142958980326dbca9f8436de1505 100644 (file)
@@ -258,7 +258,9 @@ template <int w>
 
 /* @assert.h omit start@  */
 
-#if 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__))
+#if defined __clang_major__ && __clang_major__ < 5
+# define _GL_HAS_BUILTIN_TRAP 0
+#elif 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__))
 # define _GL_HAS_BUILTIN_TRAP 1
 #elif defined __has_builtin
 # define _GL_HAS_BUILTIN_TRAP __has_builtin (__builtin_trap)
@@ -266,7 +268,9 @@ template <int w>
 # define _GL_HAS_BUILTIN_TRAP 0
 #endif
 
-#if 4 < __GNUC__ + (5 <= __GNUC_MINOR__)
+#if defined __clang_major__ && __clang_major__ < 5
+# define _GL_HAS_BUILTIN_UNREACHABLE 0
+#elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__)
 # define _GL_HAS_BUILTIN_UNREACHABLE 1
 #elif defined __has_builtin
 # define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable)