aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2020-08-11 10:58:35 -0700
committerPaul Eggert2020-08-11 11:07:28 -0700
commit124a7951f495b916cf38f0e1e1fe85e22bc08aba (patch)
tree7da6fb7a3ae571652acb36418706654fd54d7dc0
parent669aeafbd14b0ebb824bacba0a6b3daad30847a9 (diff)
downloademacs-124a7951f495b916cf38f0e1e1fe85e22bc08aba.tar.gz
emacs-124a7951f495b916cf38f0e1e1fe85e22bc08aba.zip
Update from Gnulib
This incorporates: 2020-08-11 Use expression statements also on clang 2020-08-10 Use many __attribute__s with clang 2020-08-09 Use attribute __aligned__ with clang 2020-08-09 Use __alignof__ with clang 2020-08-09 ignore-value: Simplify on clang 2020-08-09 Use __typeof__ with clang 2020-08-09 intprops: Fix typo in comment 2020-08-09 Silence warnings from clang 10 with -Wimplicit-fallthrough 2020-08-09 count-one-bits: Use __builtin_popcount{,l,ll} on clang 2020-08-09 string: Fix build error in C++ mode with clang 2020-08-09 Add ability to emit user-defined diagnostics with clang 2020-08-07 alloca: No need to compile alloca.c with clang 2020-08-06 Use __builtin_assume with clang * lib/alloca.in.h, lib/arg-nonnull.h, lib/c++defs.h, lib/cdefs.h: * lib/count-one-bits.h, lib/dirent.in.h, lib/ignore-value.h: * lib/intprops.h, lib/malloca.h, lib/regex_internal.h: * lib/stdalign.in.h, lib/stddef.in.h, lib/stdio.in.h: * lib/stdlib.in.h, lib/string.in.h, lib/verify.h, lib/warn-on-use.h: * m4/gnulib-common.m4, m4/stddef_h.m4, m4/stdint.m4: Copy from Gnulib.
-rw-r--r--lib/alloca.in.h2
-rw-r--r--lib/arg-nonnull.h2
-rw-r--r--lib/c++defs.h2
-rw-r--r--lib/cdefs.h88
-rw-r--r--lib/count-one-bits.h3
-rw-r--r--lib/dirent.in.h2
-rw-r--r--lib/ignore-value.h5
-rw-r--r--lib/intprops.h3
-rw-r--r--lib/malloca.h2
-rw-r--r--lib/regex_internal.h6
-rw-r--r--lib/stdalign.in.h19
-rw-r--r--lib/stddef.in.h2
-rw-r--r--lib/stdio.in.h2
-rw-r--r--lib/stdlib.in.h2
-rw-r--r--lib/string.in.h14
-rw-r--r--lib/verify.h11
-rw-r--r--lib/warn-on-use.h31
-rw-r--r--m4/gnulib-common.m48
-rw-r--r--m4/stddef_h.m44
-rw-r--r--m4/stdint.m44
20 files changed, 137 insertions, 75 deletions
diff --git a/lib/alloca.in.h b/lib/alloca.in.h
index 5686b082bbe..c71e9bfed9e 100644
--- a/lib/alloca.in.h
+++ b/lib/alloca.in.h
@@ -44,7 +44,7 @@
44# endif 44# endif
45#endif 45#endif
46#ifndef alloca 46#ifndef alloca
47# ifdef __GNUC__ 47# if defined __GNUC__ || (__clang_major__ >= 4)
48# define alloca __builtin_alloca 48# define alloca __builtin_alloca
49# elif defined _AIX 49# elif defined _AIX
50# define alloca __alloca 50# define alloca __alloca
diff --git a/lib/arg-nonnull.h b/lib/arg-nonnull.h
index ac26ca8cfed..db9d9ae116a 100644
--- a/lib/arg-nonnull.h
+++ b/lib/arg-nonnull.h
@@ -18,7 +18,7 @@
18 that the values passed as arguments n, ..., m must be non-NULL pointers. 18 that the values passed as arguments n, ..., m must be non-NULL pointers.
19 n = 1 stands for the first argument, n = 2 for the second argument etc. */ 19 n = 1 stands for the first argument, n = 2 for the second argument etc. */
20#ifndef _GL_ARG_NONNULL 20#ifndef _GL_ARG_NONNULL
21# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 21# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__
22# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) 22# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
23# else 23# else
24# define _GL_ARG_NONNULL(params) 24# define _GL_ARG_NONNULL(params)
diff --git a/lib/c++defs.h b/lib/c++defs.h
index 182c2b3a88d..90e6fd62e6d 100644
--- a/lib/c++defs.h
+++ b/lib/c++defs.h
@@ -298,7 +298,7 @@
298 we enable the warning only when not optimizing. */ 298 we enable the warning only when not optimizing. */
299# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) 299# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
300# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 300# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
301 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ 301 _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
302 "The symbol ::" #func " refers to the system function. " \ 302 "The symbol ::" #func " refers to the system function. " \
303 "Use " #namespace "::" #func " instead.") 303 "Use " #namespace "::" #func " instead.")
304# else 304# else
diff --git a/lib/cdefs.h b/lib/cdefs.h
index f6c447ad377..beedd891fb8 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -34,7 +34,34 @@
34#undef __P 34#undef __P
35#undef __PMT 35#undef __PMT
36 36
37#ifdef __GNUC__ 37/* Compilers that are not clang may object to
38 #if defined __clang__ && __has_attribute(...)
39 even though they do not need to evaluate the right-hand side of the &&. */
40#if defined __clang__ && defined __has_attribute
41# define __glibc_clang_has_attribute(name) __has_attribute (name)
42#else
43# define __glibc_clang_has_attribute(name) 0
44#endif
45
46/* Compilers that are not clang may object to
47 #if defined __clang__ && __has_builtin(...)
48 even though they do not need to evaluate the right-hand side of the &&. */
49#if defined __clang__ && defined __has_builtin
50# define __glibc_clang_has_builtin(name) __has_builtin (name)
51#else
52# define __glibc_clang_has_builtin(name) 0
53#endif
54
55/* Compilers that are not clang may object to
56 #if defined __clang__ && __has_extension(...)
57 even though they do not need to evaluate the right-hand side of the &&. */
58#if defined __clang__ && defined __has_extension
59# define __glibc_clang_has_extension(ext) __has_extension (ext)
60#else
61# define __glibc_clang_has_extension(ext) 0
62#endif
63
64#if defined __GNUC__ || defined __clang__
38 65
39/* All functions, except those with callbacks or those that 66/* All functions, except those with callbacks or those that
40 synchronize memory, are leaf functions. */ 67 synchronize memory, are leaf functions. */
@@ -51,7 +78,8 @@
51 gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions 78 gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions
52 as non-throwing using a function attribute since programs can use 79 as non-throwing using a function attribute since programs can use
53 the -fexceptions options for C code as well. */ 80 the -fexceptions options for C code as well. */
54# if !defined __cplusplus && __GNUC_PREREQ (3, 3) 81# if !defined __cplusplus \
82 && (__GNUC_PREREQ (3, 3) || __glibc_clang_has_attribute (__nothrow__))
55# define __THROW __attribute__ ((__nothrow__ __LEAF)) 83# define __THROW __attribute__ ((__nothrow__ __LEAF))
56# define __THROWNL __attribute__ ((__nothrow__)) 84# define __THROWNL __attribute__ ((__nothrow__))
57# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct 85# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
@@ -70,7 +98,7 @@
70# endif 98# endif
71# endif 99# endif
72 100
73#else /* Not GCC. */ 101#else /* Not GCC or clang. */
74 102
75# if (defined __cplusplus \ 103# if (defined __cplusplus \
76 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)) 104 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
@@ -83,16 +111,7 @@
83# define __THROWNL 111# define __THROWNL
84# define __NTH(fct) fct 112# define __NTH(fct) fct
85 113
86#endif /* GCC. */ 114#endif /* GCC || clang. */
87
88/* Compilers that are not clang may object to
89 #if defined __clang__ && __has_extension(...)
90 even though they do not need to evaluate the right-hand side of the &&. */
91#if defined __clang__ && defined __has_extension
92# define __glibc_clang_has_extension(ext) __has_extension (ext)
93#else
94# define __glibc_clang_has_extension(ext) 0
95#endif
96 115
97/* These two macros are not used in glibc anymore. They are kept here 116/* These two macros are not used in glibc anymore. They are kept here
98 only because some other projects expect the macros to be defined. */ 117 only because some other projects expect the macros to be defined. */
@@ -129,6 +148,12 @@
129# define __warnattr(msg) __attribute__((__warning__ (msg))) 148# define __warnattr(msg) __attribute__((__warning__ (msg)))
130# define __errordecl(name, msg) \ 149# define __errordecl(name, msg) \
131 extern void name (void) __attribute__((__error__ (msg))) 150 extern void name (void) __attribute__((__error__ (msg)))
151#elif __glibc_clang_has_attribute (__diagnose_if__)
152# define __warndecl(name, msg) \
153 extern void name (void) __attribute__((__diagnose_if__ (1, msg, "warning")))
154# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
155# define __errordecl(name, msg) \
156 extern void name (void) __attribute__((__diagnose_if__ (1, msg, "error")))
132#else 157#else
133# define __warndecl(name, msg) extern void name (void) 158# define __warndecl(name, msg) extern void name (void)
134# define __warnattr(msg) 159# define __warnattr(msg)
@@ -194,17 +219,17 @@
194*/ 219*/
195#endif 220#endif
196 221
197/* GCC has various useful declarations that can be made with the 222/* GCC and clang have various useful declarations that can be made with
198 `__attribute__' syntax. All of the ways we use this do fine if 223 the '__attribute__' syntax. All of the ways we use this do fine if
199 they are omitted for compilers that don't understand it. */ 224 they are omitted for compilers that don't understand it. */
200#if !defined __GNUC__ || __GNUC__ < 2 225#if !(defined __GNUC__ || defined __clang__)
201# define __attribute__(xyz) /* Ignore */ 226# define __attribute__(xyz) /* Ignore */
202#endif 227#endif
203 228
204/* At some point during the gcc 2.96 development the `malloc' attribute 229/* At some point during the gcc 2.96 development the `malloc' attribute
205 for functions was introduced. We don't want to use it unconditionally 230 for functions was introduced. We don't want to use it unconditionally
206 (although this would be possible) since it generates warnings. */ 231 (although this would be possible) since it generates warnings. */
207#if __GNUC_PREREQ (2,96) 232#if __GNUC_PREREQ (2,96) || __glibc_clang_has_attribute (__malloc__)
208# define __attribute_malloc__ __attribute__ ((__malloc__)) 233# define __attribute_malloc__ __attribute__ ((__malloc__))
209#else 234#else
210# define __attribute_malloc__ /* Ignore */ 235# define __attribute_malloc__ /* Ignore */
@@ -222,14 +247,14 @@
222/* At some point during the gcc 2.96 development the `pure' attribute 247/* At some point during the gcc 2.96 development the `pure' attribute
223 for functions was introduced. We don't want to use it unconditionally 248 for functions was introduced. We don't want to use it unconditionally
224 (although this would be possible) since it generates warnings. */ 249 (although this would be possible) since it generates warnings. */
225#if __GNUC_PREREQ (2,96) 250#if __GNUC_PREREQ (2,96) || __glibc_clang_has_attribute (__pure__)
226# define __attribute_pure__ __attribute__ ((__pure__)) 251# define __attribute_pure__ __attribute__ ((__pure__))
227#else 252#else
228# define __attribute_pure__ /* Ignore */ 253# define __attribute_pure__ /* Ignore */
229#endif 254#endif
230 255
231/* This declaration tells the compiler that the value is constant. */ 256/* This declaration tells the compiler that the value is constant. */
232#if __GNUC_PREREQ (2,5) 257#if __GNUC_PREREQ (2,5) || __glibc_clang_has_attribute (__const__)
233# define __attribute_const__ __attribute__ ((__const__)) 258# define __attribute_const__ __attribute__ ((__const__))
234#else 259#else
235# define __attribute_const__ /* Ignore */ 260# define __attribute_const__ /* Ignore */
@@ -238,7 +263,7 @@
238/* At some point during the gcc 3.1 development the `used' attribute 263/* At some point during the gcc 3.1 development the `used' attribute
239 for functions was introduced. We don't want to use it unconditionally 264 for functions was introduced. We don't want to use it unconditionally
240 (although this would be possible) since it generates warnings. */ 265 (although this would be possible) since it generates warnings. */
241#if __GNUC_PREREQ (3,1) 266#if __GNUC_PREREQ (3,1) || __glibc_clang_has_attribute (__used__)
242# define __attribute_used__ __attribute__ ((__used__)) 267# define __attribute_used__ __attribute__ ((__used__))
243# define __attribute_noinline__ __attribute__ ((__noinline__)) 268# define __attribute_noinline__ __attribute__ ((__noinline__))
244#else 269#else
@@ -247,7 +272,7 @@
247#endif 272#endif
248 273
249/* Since version 3.2, gcc allows marking deprecated functions. */ 274/* Since version 3.2, gcc allows marking deprecated functions. */
250#if __GNUC_PREREQ (3,2) 275#if __GNUC_PREREQ (3,2) || __glibc_clang_has_attribute (__deprecated__)
251# define __attribute_deprecated__ __attribute__ ((__deprecated__)) 276# define __attribute_deprecated__ __attribute__ ((__deprecated__))
252#else 277#else
253# define __attribute_deprecated__ /* Ignore */ 278# define __attribute_deprecated__ /* Ignore */
@@ -270,7 +295,7 @@
270 If several `format_arg' attributes are given for the same function, in 295 If several `format_arg' attributes are given for the same function, in
271 gcc-3.0 and older, all but the last one are ignored. In newer gccs, 296 gcc-3.0 and older, all but the last one are ignored. In newer gccs,
272 all designated arguments are considered. */ 297 all designated arguments are considered. */
273#if __GNUC_PREREQ (2,8) 298#if __GNUC_PREREQ (2,8) || __glibc_clang_has_attribute (__format_arg__)
274# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x))) 299# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
275#else 300#else
276# define __attribute_format_arg__(x) /* Ignore */ 301# define __attribute_format_arg__(x) /* Ignore */
@@ -280,7 +305,7 @@
280 attribute for functions was introduced. We don't want to use it 305 attribute for functions was introduced. We don't want to use it
281 unconditionally (although this would be possible) since it 306 unconditionally (although this would be possible) since it
282 generates warnings. */ 307 generates warnings. */
283#if __GNUC_PREREQ (2,97) 308#if __GNUC_PREREQ (2,97) || __glibc_clang_has_attribute (__format__)
284# define __attribute_format_strfmon__(a,b) \ 309# define __attribute_format_strfmon__(a,b) \
285 __attribute__ ((__format__ (__strfmon__, a, b))) 310 __attribute__ ((__format__ (__strfmon__, a, b)))
286#else 311#else
@@ -291,7 +316,7 @@
291 must not be NULL. Do not define __nonnull if it is already defined, 316 must not be NULL. Do not define __nonnull if it is already defined,
292 for portability when this file is used in Gnulib. */ 317 for portability when this file is used in Gnulib. */
293#ifndef __nonnull 318#ifndef __nonnull
294# if __GNUC_PREREQ (3,3) 319# if __GNUC_PREREQ (3,3) || __glibc_clang_has_attribute (__nonnull__)
295# define __nonnull(params) __attribute__ ((__nonnull__ params)) 320# define __nonnull(params) __attribute__ ((__nonnull__ params))
296# else 321# else
297# define __nonnull(params) 322# define __nonnull(params)
@@ -300,7 +325,7 @@
300 325
301/* If fortification mode, we warn about unused results of certain 326/* If fortification mode, we warn about unused results of certain
302 function calls which can lead to problems. */ 327 function calls which can lead to problems. */
303#if __GNUC_PREREQ (3,4) 328#if __GNUC_PREREQ (3,4) || __glibc_clang_has_attribute (__warn_unused_result__)
304# define __attribute_warn_unused_result__ \ 329# define __attribute_warn_unused_result__ \
305 __attribute__ ((__warn_unused_result__)) 330 __attribute__ ((__warn_unused_result__))
306# if defined __USE_FORTIFY_LEVEL && __USE_FORTIFY_LEVEL > 0 331# if defined __USE_FORTIFY_LEVEL && __USE_FORTIFY_LEVEL > 0
@@ -314,7 +339,7 @@
314#endif 339#endif
315 340
316/* Forces a function to be always inlined. */ 341/* Forces a function to be always inlined. */
317#if __GNUC_PREREQ (3,2) 342#if __GNUC_PREREQ (3,2) || __glibc_clang_has_attribute (__always_inline__)
318/* The Linux kernel defines __always_inline in stddef.h (283d7573), and 343/* The Linux kernel defines __always_inline in stddef.h (283d7573), and
319 it conflicts with this definition. Therefore undefine it first to 344 it conflicts with this definition. Therefore undefine it first to
320 allow either header to be included first. */ 345 allow either header to be included first. */
@@ -327,7 +352,7 @@
327 352
328/* Associate error messages with the source location of the call site rather 353/* Associate error messages with the source location of the call site rather
329 than with the source location inside the function. */ 354 than with the source location inside the function. */
330#if __GNUC_PREREQ (4,3) 355#if __GNUC_PREREQ (4,3) || __glibc_clang_has_attribute (__artificial__)
331# define __attribute_artificial__ __attribute__ ((__artificial__)) 356# define __attribute_artificial__ __attribute__ ((__artificial__))
332#else 357#else
333# define __attribute_artificial__ /* Ignore */ 358# define __attribute_artificial__ /* Ignore */
@@ -370,7 +395,7 @@
370 run in pedantic mode if the uses are carefully marked using the 395 run in pedantic mode if the uses are carefully marked using the
371 `__extension__' keyword. But this is not generally available before 396 `__extension__' keyword. But this is not generally available before
372 version 2.8. */ 397 version 2.8. */
373#if !__GNUC_PREREQ (2,8) 398#if !(__GNUC_PREREQ (2,8) || defined __clang__)
374# define __extension__ /* Ignore */ 399# define __extension__ /* Ignore */
375#endif 400#endif
376 401
@@ -401,7 +426,7 @@
401# endif 426# endif
402#endif 427#endif
403 428
404#if (__GNUC__ >= 3) || (__clang_major__ >= 4) 429#if (__GNUC__ >= 3) || __glibc_clang_has_builtin (__builtin_expect)
405# define __glibc_unlikely(cond) __builtin_expect ((cond), 0) 430# define __glibc_unlikely(cond) __builtin_expect ((cond), 0)
406# define __glibc_likely(cond) __builtin_expect ((cond), 1) 431# define __glibc_likely(cond) __builtin_expect ((cond), 1)
407#else 432#else
@@ -417,7 +442,8 @@
417 442
418#if (!defined _Noreturn \ 443#if (!defined _Noreturn \
419 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \ 444 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
420 && !__GNUC_PREREQ (4,7)) 445 && !(__GNUC_PREREQ (4,7) \
446 || (3 < __clang_major__ + (5 <= __clang_minor__))))
421# if __GNUC_PREREQ (2,8) 447# if __GNUC_PREREQ (2,8)
422# define _Noreturn __attribute__ ((__noreturn__)) 448# define _Noreturn __attribute__ ((__noreturn__))
423# else 449# else
diff --git a/lib/count-one-bits.h b/lib/count-one-bits.h
index 6c5b75708cf..a9e166aed8c 100644
--- a/lib/count-one-bits.h
+++ b/lib/count-one-bits.h
@@ -38,7 +38,8 @@ extern "C" {
38 expand to code that computes the number of 1-bits of the local 38 expand to code that computes the number of 1-bits of the local
39 variable 'x' of type TYPE (an unsigned integer type) and return it 39 variable 'x' of type TYPE (an unsigned integer type) and return it
40 from the current function. */ 40 from the current function. */
41#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) 41#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) \
42 || (__clang_major__ >= 4)
42# define COUNT_ONE_BITS(GCC_BUILTIN, MSC_BUILTIN, TYPE) \ 43# define COUNT_ONE_BITS(GCC_BUILTIN, MSC_BUILTIN, TYPE) \
43 return GCC_BUILTIN (x) 44 return GCC_BUILTIN (x)
44#else 45#else
diff --git a/lib/dirent.in.h b/lib/dirent.in.h
index 6fa44f0d28d..23c4e055774 100644
--- a/lib/dirent.in.h
+++ b/lib/dirent.in.h
@@ -58,7 +58,7 @@ typedef struct gl_directory DIR;
58/* The __attribute__ feature is available in gcc versions 2.5 and later. 58/* The __attribute__ feature is available in gcc versions 2.5 and later.
59 The attribute __pure__ was added in gcc 2.96. */ 59 The attribute __pure__ was added in gcc 2.96. */
60#ifndef _GL_ATTRIBUTE_PURE 60#ifndef _GL_ATTRIBUTE_PURE
61# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) 61# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
62# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) 62# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
63# else 63# else
64# define _GL_ATTRIBUTE_PURE /* empty */ 64# define _GL_ATTRIBUTE_PURE /* empty */
diff --git a/lib/ignore-value.h b/lib/ignore-value.h
index 7a922268431..ec3288f0dfc 100644
--- a/lib/ignore-value.h
+++ b/lib/ignore-value.h
@@ -39,8 +39,9 @@
39 versions 3.4 and newer have __attribute__ ((__warn_unused_result__)) 39 versions 3.4 and newer have __attribute__ ((__warn_unused_result__))
40 which may cause unwanted diagnostics in that case. Use __typeof__ 40 which may cause unwanted diagnostics in that case. Use __typeof__
41 and __extension__ to work around the problem, if the workaround is 41 and __extension__ to work around the problem, if the workaround is
42 known to be needed. */ 42 known to be needed.
43#if 3 < __GNUC__ + (4 <= __GNUC_MINOR__) 43 The workaround is not needed with clang. */
44#if (3 < __GNUC__ + (4 <= __GNUC_MINOR__)) && !defined __clang__
44# define ignore_value(x) \ 45# define ignore_value(x) \
45 (__extension__ ({ __typeof__ (x) __x = (x); (void) __x; })) 46 (__extension__ ({ __typeof__ (x) __x = (x); (void) __x; }))
46#else 47#else
diff --git a/lib/intprops.h b/lib/intprops.h
index dfbcaae73e3..220f532e499 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -86,6 +86,7 @@
86/* Does the __typeof__ keyword work? This could be done by 86/* Does the __typeof__ keyword work? This could be done by
87 'configure', but for now it's easier to do it by hand. */ 87 'configure', but for now it's easier to do it by hand. */
88#if (2 <= __GNUC__ \ 88#if (2 <= __GNUC__ \
89 || (4 <= __clang_major__) \
89 || (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \ 90 || (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \
90 || (0x5110 <= __SUNPRO_C && !__STDC__)) 91 || (0x5110 <= __SUNPRO_C && !__STDC__))
91# define _GL_HAVE___TYPEOF__ 1 92# define _GL_HAVE___TYPEOF__ 1
@@ -239,7 +240,7 @@
239#endif 240#endif
240 241
241/* True if __builtin_add_overflow_p (A, B, C) works, and similarly for 242/* True if __builtin_add_overflow_p (A, B, C) works, and similarly for
242 __builtin_mul_overflow_p and __builtin_mul_overflow_p. */ 243 __builtin_sub_overflow_p and __builtin_mul_overflow_p. */
243#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__) 244#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
244 245
245/* The _GL*_OVERFLOW macros have the same restrictions as the 246/* The _GL*_OVERFLOW macros have the same restrictions as the
diff --git a/lib/malloca.h b/lib/malloca.h
index cfcd4de4ad8..ccc485a6a4d 100644
--- a/lib/malloca.h
+++ b/lib/malloca.h
@@ -89,7 +89,7 @@ extern void freea (void *p);
89/* ------------------- Auxiliary, non-public definitions ------------------- */ 89/* ------------------- Auxiliary, non-public definitions ------------------- */
90 90
91/* Determine the alignment of a type at compile time. */ 91/* Determine the alignment of a type at compile time. */
92#if defined __GNUC__ || defined __IBM__ALIGNOF__ 92#if defined __GNUC__ || defined __clang__ || defined __IBM__ALIGNOF__
93# define sa_alignof __alignof__ 93# define sa_alignof __alignof__
94#elif defined __cplusplus 94#elif defined __cplusplus
95 template <class type> struct sa_alignof_helper { char __slot1; type __slot2; }; 95 template <class type> struct sa_alignof_helper { char __slot1; type __slot2; };
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index f6ebfb003e8..9a0c2ed97c8 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -841,10 +841,10 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx)
841#endif /* RE_ENABLE_I18N */ 841#endif /* RE_ENABLE_I18N */
842 842
843#ifndef FALLTHROUGH 843#ifndef FALLTHROUGH
844# if __GNUC__ < 7 844# if (__GNUC__ >= 7) || (__clang_major__ >= 10)
845# define FALLTHROUGH ((void) 0)
846# else
847# define FALLTHROUGH __attribute__ ((__fallthrough__)) 845# define FALLTHROUGH __attribute__ ((__fallthrough__))
846# else
847# define FALLTHROUGH ((void) 0)
848# endif 848# endif
849#endif 849#endif
850 850
diff --git a/lib/stdalign.in.h b/lib/stdalign.in.h
index cd786bed2cd..e4809b401f7 100644
--- a/lib/stdalign.in.h
+++ b/lib/stdalign.in.h
@@ -34,11 +34,12 @@
34 requirement of a structure member (i.e., slot or field) that is of 34 requirement of a structure member (i.e., slot or field) that is of
35 type TYPE, as an integer constant expression. 35 type TYPE, as an integer constant expression.
36 36
37 This differs from GCC's __alignof__ operator, which can yield a 37 This differs from GCC's and clang's __alignof__ operator, which can
38 better-performing alignment for an object of that type. For 38 yield a better-performing alignment for an object of that type. For
39 example, on x86 with GCC, __alignof__ (double) and __alignof__ 39 example, on x86 with GCC and on Linux/x86 with clang,
40 (long long) are 8, whereas alignof (double) and alignof (long long) 40 __alignof__ (double) and __alignof__ (long long) are 8, whereas
41 are 4 unless the option '-malign-double' is used. 41 alignof (double) and alignof (long long) are 4 unless the option
42 '-malign-double' is used.
42 43
43 The result cannot be used as a value for an 'enum' constant, if you 44 The result cannot be used as a value for an 'enum' constant, if you
44 want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. 45 want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc.
@@ -55,7 +56,8 @@
55/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023 56/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023
56 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. */ 57 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. */
57#if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \ 58#if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \
58 || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9))) 59 || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \
60 && !defined __clang__))
59# ifdef __cplusplus 61# ifdef __cplusplus
60# if 201103 <= __cplusplus 62# if 201103 <= __cplusplus
61# define _Alignof(type) alignof (type) 63# define _Alignof(type) alignof (type)
@@ -102,8 +104,9 @@
102# define _Alignas(a) alignas (a) 104# define _Alignas(a) alignas (a)
103# elif ((defined __APPLE__ && defined __MACH__ \ 105# elif ((defined __APPLE__ && defined __MACH__ \
104 ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \ 106 ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \
105 : __GNUC__ && !defined __ibmxl__) \ 107 : __GNUC__ && !defined __ibmxl__) \
106 || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \ 108 || (4 <= __clang_major__) \
109 || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \
107 || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__) 110 || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__)
108# define _Alignas(a) __attribute__ ((__aligned__ (a))) 111# define _Alignas(a) __attribute__ ((__aligned__ (a)))
109# elif 1300 <= _MSC_VER 112# elif 1300 <= _MSC_VER
diff --git a/lib/stddef.in.h b/lib/stddef.in.h
index 2e50a1f01e8..87b46d53204 100644
--- a/lib/stddef.in.h
+++ b/lib/stddef.in.h
@@ -97,7 +97,7 @@
97 and the C11 standard allows this. Work around this problem by 97 and the C11 standard allows this. Work around this problem by
98 using __alignof__ (which returns 8 for double) rather than _Alignof 98 using __alignof__ (which returns 8 for double) rather than _Alignof
99 (which returns 4), and align each union member accordingly. */ 99 (which returns 4), and align each union member accordingly. */
100# ifdef __GNUC__ 100# if defined __GNUC__ || (__clang_major__ >= 4)
101# define _GL_STDDEF_ALIGNAS(type) \ 101# define _GL_STDDEF_ALIGNAS(type) \
102 __attribute__ ((__aligned__ (__alignof__ (type)))) 102 __attribute__ ((__aligned__ (__alignof__ (type))))
103# else 103# else
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index 6c338dd6c0b..cbebc8462fd 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -63,7 +63,7 @@
63 gnulib and libintl do '#define printf __printf__' when they override 63 gnulib and libintl do '#define printf __printf__' when they override
64 the 'printf' function. */ 64 the 'printf' function. */
65#ifndef _GL_ATTRIBUTE_FORMAT 65#ifndef _GL_ATTRIBUTE_FORMAT
66# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) 66# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || defined __clang__
67# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) 67# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
68# else 68# else
69# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ 69# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index 59f9e6c71d1..5c598a275d1 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -102,7 +102,7 @@ struct random_data
102/* The __attribute__ feature is available in gcc versions 2.5 and later. 102/* The __attribute__ feature is available in gcc versions 2.5 and later.
103 The attribute __pure__ was added in gcc 2.96. */ 103 The attribute __pure__ was added in gcc 2.96. */
104#ifndef _GL_ATTRIBUTE_PURE 104#ifndef _GL_ATTRIBUTE_PURE
105# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) 105# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
106# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) 106# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
107# else 107# else
108# define _GL_ATTRIBUTE_PURE /* empty */ 108# define _GL_ATTRIBUTE_PURE /* empty */
diff --git a/lib/string.in.h b/lib/string.in.h
index aa9802791ee..c0c1a54f39d 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -55,7 +55,7 @@
55/* The __attribute__ feature is available in gcc versions 2.5 and later. 55/* The __attribute__ feature is available in gcc versions 2.5 and later.
56 The attribute __pure__ was added in gcc 2.96. */ 56 The attribute __pure__ was added in gcc 2.96. */
57#ifndef _GL_ATTRIBUTE_PURE 57#ifndef _GL_ATTRIBUTE_PURE
58# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) 58# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
59# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) 59# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
60# else 60# else
61# define _GL_ATTRIBUTE_PURE /* empty */ 61# define _GL_ATTRIBUTE_PURE /* empty */
@@ -329,7 +329,8 @@ _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
329 GB18030 and the character to be searched is a digit. */ 329 GB18030 and the character to be searched is a digit. */
330# undef strchr 330# undef strchr
331/* Assume strchr is always declared. */ 331/* Assume strchr is always declared. */
332_GL_WARN_ON_USE_CXX (strchr, const char *, (const char *, int), 332_GL_WARN_ON_USE_CXX (strchr,
333 const char *, char *, (const char *, int),
333 "strchr cannot work correctly on character strings " 334 "strchr cannot work correctly on character strings "
334 "in some multibyte locales - " 335 "in some multibyte locales - "
335 "use mbschr if you care about internationalization"); 336 "use mbschr if you care about internationalization");
@@ -524,7 +525,8 @@ _GL_CXXALIASWARN (strpbrk);
524 locale encoding is GB18030 and one of the characters to be searched is a 525 locale encoding is GB18030 and one of the characters to be searched is a
525 digit. */ 526 digit. */
526# undef strpbrk 527# undef strpbrk
527_GL_WARN_ON_USE_CXX (strpbrk, const char *, (const char *, const char *), 528_GL_WARN_ON_USE_CXX (strpbrk,
529 const char *, char *, (const char *, const char *),
528 "strpbrk cannot work correctly on character strings " 530 "strpbrk cannot work correctly on character strings "
529 "in multibyte locales - " 531 "in multibyte locales - "
530 "use mbspbrk if you care about internationalization"); 532 "use mbspbrk if you care about internationalization");
@@ -532,7 +534,8 @@ _GL_WARN_ON_USE_CXX (strpbrk, const char *, (const char *, const char *),
532#elif defined GNULIB_POSIXCHECK 534#elif defined GNULIB_POSIXCHECK
533# undef strpbrk 535# undef strpbrk
534# if HAVE_RAW_DECL_STRPBRK 536# if HAVE_RAW_DECL_STRPBRK
535_GL_WARN_ON_USE_CXX (strpbrk, const char *, (const char *, const char *), 537_GL_WARN_ON_USE_CXX (strpbrk,
538 const char *, char *, (const char *, const char *),
536 "strpbrk is unportable - " 539 "strpbrk is unportable - "
537 "use gnulib module strpbrk for portability"); 540 "use gnulib module strpbrk for portability");
538# endif 541# endif
@@ -553,7 +556,8 @@ _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
553 GB18030 and the character to be searched is a digit. */ 556 GB18030 and the character to be searched is a digit. */
554# undef strrchr 557# undef strrchr
555/* Assume strrchr is always declared. */ 558/* Assume strrchr is always declared. */
556_GL_WARN_ON_USE_CXX (strrchr, const char *, (const char *, int), 559_GL_WARN_ON_USE_CXX (strrchr,
560 const char *, char *, (const char *, int),
557 "strrchr cannot work correctly on character strings " 561 "strrchr cannot work correctly on character strings "
558 "in some multibyte locales - " 562 "in some multibyte locales - "
559 "use mbsrchr if you care about internationalization"); 563 "use mbsrchr if you care about internationalization");
diff --git a/lib/verify.h b/lib/verify.h
index f1097612704..58172f3cb7f 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -233,6 +233,13 @@ template <int w>
233 233
234/* @assert.h omit start@ */ 234/* @assert.h omit start@ */
235 235
236#if defined __has_builtin
237/* <https://clang.llvm.org/docs/LanguageExtensions.html#builtin-functions> */
238# define _GL_HAS_BUILTIN_ASSUME __has_builtin (__builtin_assume)
239#else
240# define _GL_HAS_BUILTIN_ASSUME 0
241#endif
242
236#if 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__)) 243#if 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__))
237# define _GL_HAS_BUILTIN_TRAP 1 244# define _GL_HAS_BUILTIN_TRAP 1
238#elif defined __has_builtin 245#elif defined __has_builtin
@@ -294,7 +301,9 @@ template <int w>
294 diagnostics, performance can suffer if R uses hard-to-optimize 301 diagnostics, performance can suffer if R uses hard-to-optimize
295 features such as function calls not inlined by the compiler. */ 302 features such as function calls not inlined by the compiler. */
296 303
297#if _GL_HAS_BUILTIN_UNREACHABLE 304#if _GL_HAS_BUILTIN_ASSUME
305# define assume(R) __builtin_assume (R)
306#elif _GL_HAS_BUILTIN_UNREACHABLE
298# define assume(R) ((R) ? (void) 0 : __builtin_unreachable ()) 307# define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())
299#elif 1200 <= _MSC_VER 308#elif 1200 <= _MSC_VER
300# define assume(R) __assume (R) 309# define assume(R) __assume (R)
diff --git a/lib/warn-on-use.h b/lib/warn-on-use.h
index 23c10fdd122..3f728d1a9dc 100644
--- a/lib/warn-on-use.h
+++ b/lib/warn-on-use.h
@@ -87,6 +87,13 @@
87extern __typeof__ (function) function __attribute__ ((__warning__ (message))) 87extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
88# define _GL_WARN_ON_USE_ATTRIBUTE(message) \ 88# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
89 __attribute__ ((__warning__ (message))) 89 __attribute__ ((__warning__ (message)))
90# elif __clang_major__ >= 4
91/* Another compiler attribute is available in clang. */
92# define _GL_WARN_ON_USE(function, message) \
93extern __typeof__ (function) function \
94 __attribute__ ((__diagnose_if__ (1, message, "warning")))
95# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
96 __attribute__ ((__diagnose_if__ (1, message, "warning")))
90# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 97# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
91/* Verify the existence of the function. */ 98/* Verify the existence of the function. */
92# define _GL_WARN_ON_USE(function, message) \ 99# define _GL_WARN_ON_USE(function, message) \
@@ -99,27 +106,33 @@ _GL_WARN_EXTERN_C int _gl_warn_on_use
99# endif 106# endif
100#endif 107#endif
101 108
102/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") 109/* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message")
103 is like _GL_WARN_ON_USE (function, "string"), except that in C++ mode the 110 is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the
104 function is declared with the given prototype, consisting of return type, 111 function is declared with the given prototype, consisting of return type,
105 parameters, and attributes. 112 parameters, and attributes.
106 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does 113 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
107 not work in this case. */ 114 not work in this case. */
108#ifndef _GL_WARN_ON_USE_CXX 115#ifndef _GL_WARN_ON_USE_CXX
109# if !defined __cplusplus 116# if !defined __cplusplus
110# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 117# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
111 _GL_WARN_ON_USE (function, msg) 118 _GL_WARN_ON_USE (function, msg)
112# else 119# else
113# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 120# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
114# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 121/* A compiler attribute is available in gcc versions 4.3.0 and later. */
115extern rettype function parameters_and_attributes \ 122# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
116 __attribute__ ((__warning__ (msg))) 123extern rettype_gcc function parameters_and_attributes \
124 __attribute__ ((__warning__ (msg)))
125# elif __clang_major__ >= 4
126/* Another compiler attribute is available in clang. */
127# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
128extern rettype_clang function parameters_and_attributes \
129 __attribute__ ((__diagnose_if__ (1, msg, "warning")))
117# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 130# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
118/* Verify the existence of the function. */ 131/* Verify the existence of the function. */
119# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 132# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
120extern rettype function parameters_and_attributes 133extern rettype_gcc function parameters_and_attributes
121# else /* Unsupported. */ 134# else /* Unsupported. */
122# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 135# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
123_GL_WARN_EXTERN_C int _gl_warn_on_use 136_GL_WARN_EXTERN_C int _gl_warn_on_use
124# endif 137# endif
125# endif 138# endif
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index 50acc0a474b..03da2287d48 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -1,4 +1,4 @@
1# gnulib-common.m4 serial 53 1# gnulib-common.m4 serial 55
2dnl Copyright (C) 2007-2020 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2020 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
@@ -45,7 +45,7 @@ AC_DEFUN([gl_COMMON_BODY], [
45 ? 6000000 <= __apple_build_version__ \ 45 ? 6000000 <= __apple_build_version__ \
46 : 3 < __clang_major__ + (5 <= __clang_minor__)))) 46 : 3 < __clang_major__ + (5 <= __clang_minor__))))
47 /* _Noreturn works as-is. */ 47 /* _Noreturn works as-is. */
48# elif _GL_GNUC_PREREQ (2, 8) || 0x5110 <= __SUNPRO_C 48# elif _GL_GNUC_PREREQ (2, 8) || defined __clang__ || 0x5110 <= __SUNPRO_C
49# define _Noreturn __attribute__ ((__noreturn__)) 49# define _Noreturn __attribute__ ((__noreturn__))
50# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0) 50# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
51# define _Noreturn __declspec (noreturn) 51# define _Noreturn __declspec (noreturn)
@@ -76,6 +76,7 @@ AC_DEFUN([gl_COMMON_BODY], [
76# define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3) 76# define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3)
77# define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95) 77# define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95)
78# define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1) 78# define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1)
79# define _GL_ATTR_diagnose_if 0
79# define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3) 80# define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3)
80# define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1) 81# define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1)
81# define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0) 82# define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0)
@@ -149,6 +150,9 @@ AC_DEFUN([gl_COMMON_BODY], [
149#if _GL_HAS_ATTRIBUTE (error) 150#if _GL_HAS_ATTRIBUTE (error)
150# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__error__ (msg))) 151# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__error__ (msg)))
151# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__warning__ (msg))) 152# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__warning__ (msg)))
153#elif _GL_HAS_ATTRIBUTE (diagnose_if)
154# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__diagnose_if__ (1, msg, "error")))
155# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__diagnose_if__ (1, msg, "warning")))
152#else 156#else
153# define _GL_ATTRIBUTE_ERROR(msg) 157# define _GL_ATTRIBUTE_ERROR(msg)
154# define _GL_ATTRIBUTE_WARNING(msg) 158# define _GL_ATTRIBUTE_WARNING(msg)
diff --git a/m4/stddef_h.m4 b/m4/stddef_h.m4
index 6bcfadb74ef..d8bc8ff64e4 100644
--- a/m4/stddef_h.m4
+++ b/m4/stddef_h.m4
@@ -1,5 +1,5 @@
1dnl A placeholder for <stddef.h>, for platforms that have issues. 1dnl A placeholder for <stddef.h>, for platforms that have issues.
2# stddef_h.m4 serial 6 2# stddef_h.m4 serial 7
3dnl Copyright (C) 2009-2020 Free Software Foundation, Inc. 3dnl Copyright (C) 2009-2020 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -19,7 +19,7 @@ AC_DEFUN([gl_STDDEF_H],
19 [AC_LANG_PROGRAM( 19 [AC_LANG_PROGRAM(
20 [[#include <stddef.h> 20 [[#include <stddef.h>
21 unsigned int s = sizeof (max_align_t); 21 unsigned int s = sizeof (max_align_t);
22 #if defined __GNUC__ || defined __IBM__ALIGNOF__ 22 #if defined __GNUC__ || defined __clang__ || defined __IBM__ALIGNOF__
23 int check1[2 * (__alignof__ (double) <= __alignof__ (max_align_t)) - 1]; 23 int check1[2 * (__alignof__ (double) <= __alignof__ (max_align_t)) - 1];
24 int check2[2 * (__alignof__ (long double) <= __alignof__ (max_align_t)) - 1]; 24 int check2[2 * (__alignof__ (long double) <= __alignof__ (max_align_t)) - 1];
25 #endif 25 #endif
diff --git a/m4/stdint.m4 b/m4/stdint.m4
index 29ad826d8ea..e0fa8a51fb3 100644
--- a/m4/stdint.m4
+++ b/m4/stdint.m4
@@ -1,4 +1,4 @@
1# stdint.m4 serial 54 1# stdint.m4 serial 55
2dnl Copyright (C) 2001-2020 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2020 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
@@ -152,7 +152,7 @@ uintmax_t j = UINTMAX_MAX;
152/* Check that SIZE_MAX has the correct type, if possible. */ 152/* Check that SIZE_MAX has the correct type, if possible. */
153#if 201112 <= __STDC_VERSION__ 153#if 201112 <= __STDC_VERSION__
154int k = _Generic (SIZE_MAX, size_t: 0); 154int k = _Generic (SIZE_MAX, size_t: 0);
155#elif (2 <= __GNUC__ || defined __IBM__TYPEOF__ \ 155#elif (2 <= __GNUC__ || 4 <= __clang_major__ || defined __IBM__TYPEOF__ \
156 || (0x5110 <= __SUNPRO_C && !__STDC__)) 156 || (0x5110 <= __SUNPRO_C && !__STDC__))
157extern size_t k; 157extern size_t k;
158extern __typeof__ (SIZE_MAX) k; 158extern __typeof__ (SIZE_MAX) k;