bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

improve clang support (13)


From: Bruno Haible
Subject: improve clang support (13)
Date: Sun, 09 Aug 2020 15:03:10 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-186-generic; KDE/5.18.0; x86_64; ; )

clang has __typeof__, like GCC.


2020-08-09  Bruno Haible  <bruno@clisp.org>

        Use __typeof__ with clang.
        * m4/stdint.m4 (gl_STDINT_H): Check for SIZE_MAX also on
        "clang -std=gnu99".
        * lib/intprops.h (_GL_HAVE___TYPEOF__): Define to 1 also on clang.
        * tests/test-stdint.c (verify_same_types): Enable the check also on
        clang.

diff --git a/lib/intprops.h b/lib/intprops.h
index c0bfecd..2ab1b6f 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -86,6 +86,7 @@
 /* Does the __typeof__ keyword work?  This could be done by
    'configure', but for now it's easier to do it by hand.  */
 #if (2 <= __GNUC__ \
+     || (4 <= __clang_major__) \
      || (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \
      || (0x5110 <= __SUNPRO_C && !__STDC__))
 # define _GL_HAVE___TYPEOF__ 1
diff --git a/m4/stdint.m4 b/m4/stdint.m4
index 29ad826..e0fa8a5 100644
--- a/m4/stdint.m4
+++ b/m4/stdint.m4
@@ -1,4 +1,4 @@
-# stdint.m4 serial 54
+# stdint.m4 serial 55
 dnl Copyright (C) 2001-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -152,7 +152,7 @@ uintmax_t j = UINTMAX_MAX;
 /* Check that SIZE_MAX has the correct type, if possible.  */
 #if 201112 <= __STDC_VERSION__
 int k = _Generic (SIZE_MAX, size_t: 0);
-#elif (2 <= __GNUC__ || defined __IBM__TYPEOF__ \
+#elif (2 <= __GNUC__ || 4 <= __clang_major__ || defined __IBM__TYPEOF__ \
        || (0x5110 <= __SUNPRO_C && !__STDC__))
 extern size_t k;
 extern __typeof__ (SIZE_MAX) k;
diff --git a/tests/test-stdint.c b/tests/test-stdint.c
index 6da84b2..5e4f30c 100644
--- a/tests/test-stdint.c
+++ b/tests/test-stdint.c
@@ -26,7 +26,7 @@
 #include "verify.h"
 #include "intprops.h"
 
-#if __GNUC__ >= 2 && DO_PEDANTIC
+#if ((__GNUC__ >= 2) || (__clang_major__ >= 4)) && DO_PEDANTIC
 # define verify_same_types(expr1,expr2)  \
     extern void _verify_func(__LINE__) (__typeof__ (expr1) *); \
     extern void _verify_func(__LINE__) (__typeof__ (expr2) *);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]