]> Savannah Git Hosting - gnulib.git/commitdiff
Port FALLTHROUGH to clang 3.4 and earlier
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 21 Jan 2021 21:40:16 +0000 (13:40 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 22 Jan 2021 01:09:58 +0000 (17:09 -0800)
Problem reported by Akim Demaille in:
https://lists.gnu.org/r/bug-gnulib/2021-01/msg00241.html
* lib/cdefs.h (__glibc_has_attribute):
* m4/gnulib-common.m4 (gl_COMMON_BODY):
Do not trust __has_attribute in clang 3.4 and earlier, as
<https://releases.llvm.org/3.5.0/tools/clang/docs/ReleaseNotes.html>
says that __has_attribute is unreliable in these old versions.

ChangeLog
lib/cdefs.h
m4/gnulib-common.m4

index 8c5a0a7579e168313db69b9ab8ec856182c525e9..8fa2e1535f7e3fb000f750e6e57154d0c50b7e9c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2021-01-21  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Port FALLTHROUGH to clang 3.4 and earlier
+       Problem reported by Akim Demaille in:
+       https://lists.gnu.org/r/bug-gnulib/2021-01/msg00241.html
+       * lib/cdefs.h (__glibc_has_attribute):
+       * m4/gnulib-common.m4 (gl_COMMON_BODY):
+       Do not trust __has_attribute in clang 3.4 and earlier, as
+       <https://releases.llvm.org/3.5.0/tools/clang/docs/ReleaseNotes.html>
+       says that __has_attribute is unreliable in these old versions.
+
 2021-01-20  Bruno Haible  <bruno@clisp.org>
 
        gc-random: Fix link error in tests.
index a22ae6db26f3f1185460c3e13a4c2fc2625af247..060a3d068915c034cdf84b3f230e0110feb0f947 100644 (file)
@@ -38,7 +38,9 @@
        #if defined __has_attribute && __has_attribute (...)
    even though they do not need to evaluate the right-hand side of the &&.
    Similarly for __has_builtin, etc.  */
-#ifdef __has_attribute
+#if (defined __has_attribute \
+     && (!defined __clang_minor__ \
+         || 3 < __clang_major__ + (5 <= __clang_minor__)))
 # define __glibc_has_attribute(attr) __has_attribute (attr)
 #else
 # define __glibc_has_attribute(attr) 0
index 3d87fd840a4c9d5c63348df0f4637e56d6fcfad0..f2eff10de6dbb9deb19ca1f0e9526ff1713c1290 100644 (file)
@@ -67,7 +67,9 @@ AC_DEFUN([gl_COMMON_BODY], [
 #endif])
   AH_VERBATIM([attribute],
 [/* Attributes.  */
-#ifdef __has_attribute
+#if (defined __has_attribute \
+     && (!defined __clang_minor__ \
+         || 3 < __clang_major__ + (5 <= __clang_minor__)))
 # define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__)
 #else
 # define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr