]> Savannah Git Hosting - gnulib.git/commitdiff
Use __typeof__ with clang.
authorBruno Haible <bruno@clisp.org>
Sun, 9 Aug 2020 13:01:23 +0000 (15:01 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 9 Aug 2020 13:01:23 +0000 (15:01 +0200)
* 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.

ChangeLog
lib/intprops.h
m4/stdint.m4
tests/test-stdint.c

index e1c48b21538c5bfc9ff32569f15fb025c01b0d01..77fb9636138ca7f2dcb26ab6e2d636cd413b357d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+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.
+
 2020-08-09  Bruno Haible  <bruno@clisp.org>
 
        Add ability to emit user-defined warnings and errors with clang.
index c0bfecd908713dee1a9460c96f3db85bd32fd734..2ab1b6ff6a9aa390ea749f4b00e4336d71d97e44 100644 (file)
@@ -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
index 29ad826d8ea9290691719c432059f48ebafa0ef6..e0fa8a51fb35cdf37c9f206300dab3b41b7b7b7e 100644 (file)
@@ -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;
index 6da84b274fc1e7fd89c5670a21ea0f1d2f74da9b..5e4f30cde19de6b1c34fb63a1c6103383d58efb8 100644 (file)
@@ -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) *);