From 38a4e22da8851abb97ab592a47d01b267a42ce5e Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 27 Aug 2024 16:20:16 +0200 Subject: [PATCH] Explicitly exclude clang when we test for a GCC version >= 4.3. Rationale: clang can disguise as any possible GCC version. * m4/gnulib-common.m4 (gl_CC_GNULIB_WARNINGS): When testing __GNUC__, exclude clang. * lib/_Noreturn.h (_Noreturn): Likewise. * lib/aligned-malloc.h (aligned_free, aligned_malloc): Likewise. * lib/base32.h: Likewise. * lib/base64.h: Likewise. * lib/dfa.c (FALLTHROUGH): Likewise. * lib/dirent.in.h (_GL_ATTRIBUTE_DEALLOC, opendir, fdopendir): Likewise. * lib/intprops-internal.h: Likewise. * lib/jit/cache.h (clear_cache): Likewise. * lib/malloc.in.h (memalign): Likewise. * lib/mcel.h: Likewise. * lib/regex.h: Likewise. * lib/stddef.in.h (_GL_HAS_BUILTIN_UNREACHABLE): Likewise. * lib/stdio.in.h (_GL_ATTRIBUTE_DEALLOC, fdopen, fopen, popen, tmpfile): Likewise. * lib/stdlib.in.h (_GL_ATTRIBUTE_DEALLOC, aligned_alloc, calloc, canonicalize_file_name, malloc, realloc): Likewise. * lib/string.in.h (_GL_ATTRIBUTE_DEALLOC, strdup, strndup): Likewise. * lib/verify.h: Likewise. * lib/wchar.in.h (_GL_ATTRIBUTE_DEALLOC, wcsdup): Likewise. * lib/xalloc-oversized.h (xalloc_oversized): Likewise. * lib/fenv-private.h (_FPU_GETCW, _FPU_SETCW, _FPU_GETFPSR, _FPU_SETFPSR): When testing __GNUC__, exclude clang. Use different builtins for clang. * lib/hamt.h (GL_HAMT_THREAD_SAFE): When testing __GNUC__, exclude clang. Enable for clang >= 4. * lib/astrxfrm.c: Use _GL_GNUC_PREREQ. * lib/readutmp.c: Likewise. * lib/strftime.c: Likewise. * tests/test-asyncsafe-linked_list-strong.c: Likewise. * tests/test-asyncsafe-linked_list-weak.c: Likewise. * tests/test-c-strtod-mt.c: Likewise. * tests/test-c-strtof-mt.c: Likewise. * tests/test-c-strtold-mt.c: Likewise. * tests/test-gmtime_r-mt.c: Likewise. * tests/test-intprops.c: Likewise. * tests/test-limits-h.c: Likewise. * tests/test-localtime_r-mt.c: Likewise. * tests/test-memrchr.c: Likewise. * tests/test-nl_langinfo-mt.c: Likewise. * tests/test-setlocale_null-mt-all.c: Likewise. * tests/test-setlocale_null-mt-one.c: Likewise. * tests/test-statat.c: Likewise. * tests/test-xvasprintf.c: Likewise. --- ChangeLog | 50 +++++++++++++++++++++++ lib/_Noreturn.h | 2 +- lib/aligned-malloc.h | 4 +- lib/astrxfrm.c | 2 +- lib/base32.h | 2 +- lib/base64.h | 2 +- lib/dfa.c | 2 +- lib/dirent.in.h | 13 +++--- lib/fenv-private.h | 10 ++++- lib/hamt.h | 5 ++- lib/intprops-internal.h | 4 +- lib/jit/cache.h | 2 +- lib/malloc.in.h | 4 +- lib/mcel.h | 2 +- lib/readutmp.c | 2 +- lib/regex.h | 8 ++-- lib/stddef.in.h | 2 +- lib/stdio.in.h | 20 +++++---- lib/stdlib.in.h | 27 +++++++----- lib/strftime.c | 2 +- lib/string.in.h | 12 +++--- lib/verify.h | 9 ++-- lib/wchar.in.h | 7 ++-- lib/xalloc-oversized.h | 3 +- m4/gnulib-common.m4 | 14 +++---- tests/test-asyncsafe-linked_list-strong.c | 2 +- tests/test-asyncsafe-linked_list-weak.c | 2 +- tests/test-c-strtod-mt.c | 2 +- tests/test-c-strtof-mt.c | 2 +- tests/test-c-strtold-mt.c | 2 +- tests/test-gmtime_r-mt.c | 2 +- tests/test-intprops.c | 7 ++-- tests/test-limits-h.c | 2 +- tests/test-localtime_r-mt.c | 2 +- tests/test-memrchr.c | 2 +- tests/test-nl_langinfo-mt.c | 2 +- tests/test-setlocale_null-mt-all.c | 2 +- tests/test-setlocale_null-mt-one.c | 2 +- tests/test-statat.c | 2 +- tests/test-xvasprintf.c | 6 +-- 40 files changed, 162 insertions(+), 87 deletions(-) diff --git a/ChangeLog b/ChangeLog index e67b41fa6b..e84f67b639 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,53 @@ +2024-08-27 Bruno Haible + + Explicitly exclude clang when we test for a GCC version >= 4.3. + Rationale: clang can disguise as any possible GCC version. + * m4/gnulib-common.m4 (gl_CC_GNULIB_WARNINGS): When testing __GNUC__, + exclude clang. + * lib/_Noreturn.h (_Noreturn): Likewise. + * lib/aligned-malloc.h (aligned_free, aligned_malloc): Likewise. + * lib/base32.h: Likewise. + * lib/base64.h: Likewise. + * lib/dfa.c (FALLTHROUGH): Likewise. + * lib/dirent.in.h (_GL_ATTRIBUTE_DEALLOC, opendir, fdopendir): Likewise. + * lib/intprops-internal.h: Likewise. + * lib/jit/cache.h (clear_cache): Likewise. + * lib/malloc.in.h (memalign): Likewise. + * lib/mcel.h: Likewise. + * lib/regex.h: Likewise. + * lib/stddef.in.h (_GL_HAS_BUILTIN_UNREACHABLE): Likewise. + * lib/stdio.in.h (_GL_ATTRIBUTE_DEALLOC, fdopen, fopen, popen, tmpfile): + Likewise. + * lib/stdlib.in.h (_GL_ATTRIBUTE_DEALLOC, aligned_alloc, calloc, + canonicalize_file_name, malloc, realloc): Likewise. + * lib/string.in.h (_GL_ATTRIBUTE_DEALLOC, strdup, strndup): Likewise. + * lib/verify.h: Likewise. + * lib/wchar.in.h (_GL_ATTRIBUTE_DEALLOC, wcsdup): Likewise. + * lib/xalloc-oversized.h (xalloc_oversized): Likewise. + * lib/fenv-private.h (_FPU_GETCW, _FPU_SETCW, _FPU_GETFPSR, + _FPU_SETFPSR): When testing __GNUC__, exclude clang. Use different + builtins for clang. + * lib/hamt.h (GL_HAMT_THREAD_SAFE): When testing __GNUC__, exclude + clang. Enable for clang >= 4. + * lib/astrxfrm.c: Use _GL_GNUC_PREREQ. + * lib/readutmp.c: Likewise. + * lib/strftime.c: Likewise. + * tests/test-asyncsafe-linked_list-strong.c: Likewise. + * tests/test-asyncsafe-linked_list-weak.c: Likewise. + * tests/test-c-strtod-mt.c: Likewise. + * tests/test-c-strtof-mt.c: Likewise. + * tests/test-c-strtold-mt.c: Likewise. + * tests/test-gmtime_r-mt.c: Likewise. + * tests/test-intprops.c: Likewise. + * tests/test-limits-h.c: Likewise. + * tests/test-localtime_r-mt.c: Likewise. + * tests/test-memrchr.c: Likewise. + * tests/test-nl_langinfo-mt.c: Likewise. + * tests/test-setlocale_null-mt-all.c: Likewise. + * tests/test-setlocale_null-mt-one.c: Likewise. + * tests/test-statat.c: Likewise. + * tests/test-xvasprintf.c: Likewise. + 2024-08-27 Bruno Haible readutmp: In systemd mode, show sessions of type "web". diff --git a/lib/_Noreturn.h b/lib/_Noreturn.h index 7326bd4773..9806f2b1a0 100644 --- a/lib/_Noreturn.h +++ b/lib/_Noreturn.h @@ -34,7 +34,7 @@ # elif ((!defined __cplusplus || defined __clang__) \ && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ || (!defined __STRICT_ANSI__ \ - && (4 < __GNUC__ + (7 <= __GNUC_MINOR__) \ + && (4 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __clang__ \ || (defined __apple_build_version__ \ ? 6000000 <= __apple_build_version__ \ : 3 < __clang_major__ + (5 <= __clang_minor__)))))) diff --git a/lib/aligned-malloc.h b/lib/aligned-malloc.h index d7142f5a8c..87d1ec1c67 100644 --- a/lib/aligned-malloc.h +++ b/lib/aligned-malloc.h @@ -64,7 +64,7 @@ extern "C" { #endif #if ((ALIGNMENT) <= MALLOC_ALIGNMENT) || HAVE_POSIX_MEMALIGN || HAVE_ALIGNED_ALLOC || HAVE_MEMALIGN -# if defined aligned_free || __GNUC__ >= 11 +# if defined aligned_free || (__GNUC__ >= 11 && !defined __clang__) /* The caller wants an inline function, not a macro, or we can use GCC's -Wmismatched-dealloc warning. */ static inline void @@ -79,7 +79,7 @@ aligned_free (void *q) # if (ALIGNMENT) <= MALLOC_ALIGNMENT /* Simply use malloc. */ -# if defined aligned_malloc || __GNUC__ >= 11 +# if defined aligned_malloc || (__GNUC__ >= 11 && !defined __clang__) /* The caller wants an inline function, not a macro, or GCC's -Wmismatched-dealloc warning might be in effect. */ static inline diff --git a/lib/astrxfrm.c b/lib/astrxfrm.c index eaedff0a83..f25cf7d493 100644 --- a/lib/astrxfrm.c +++ b/lib/astrxfrm.c @@ -26,7 +26,7 @@ /* Avoid false GCC warning "function may return address of local variable" regarding result and tmpbuf. */ -#if __GNUC__ + (__GNUC_MINOR__ >= 8) > 4 +#if _GL_GNUC_PREREQ (4, 8) # pragma GCC diagnostic ignored "-Wreturn-local-addr" #endif diff --git a/lib/base32.h b/lib/base32.h index eadbeae56c..8c10948c37 100644 --- a/lib/base32.h +++ b/lib/base32.h @@ -27,7 +27,7 @@ #include /* Pacify GCC in isubase32. */ -#if defined __GNUC__ && 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) && !defined __clang__ # pragma GCC diagnostic ignored "-Wtype-limits" #endif diff --git a/lib/base64.h b/lib/base64.h index 7691f6c4ad..562ba97302 100644 --- a/lib/base64.h +++ b/lib/base64.h @@ -27,7 +27,7 @@ #include /* Pacify GCC in isubase64. */ -#if defined __GNUC__ && 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) && !defined __clang__ # pragma GCC diagnostic ignored "-Wtype-limits" #endif diff --git a/lib/dfa.c b/lib/dfa.c index 0ccb167176..a7a969b6ca 100644 --- a/lib/dfa.c +++ b/lib/dfa.c @@ -80,7 +80,7 @@ c_isdigit (char c) #ifndef FALLTHROUGH # if 201710L < __STDC_VERSION__ # define FALLTHROUGH [[__fallthrough__]] -# elif ((__GNUC__ >= 7) \ +# elif ((__GNUC__ >= 7 && !defined __clang__) \ || (defined __apple_build_version__ \ ? __apple_build_version__ >= 12000000 \ : __clang_major__ >= 10)) diff --git a/lib/dirent.in.h b/lib/dirent.in.h index f05b880077..3fe46f2336 100644 --- a/lib/dirent.in.h +++ b/lib/dirent.in.h @@ -78,7 +78,7 @@ typedef struct gl_directory DIR; that can be freed by passing them as the Ith argument to the function F. */ #ifndef _GL_ATTRIBUTE_DEALLOC -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) # else # define _GL_ATTRIBUTE_DEALLOC(f, i) @@ -152,7 +152,7 @@ _GL_FUNCDECL_RPL (opendir, DIR *, _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1)); _GL_CXXALIAS_RPL (opendir, DIR *, (const char *dir_name)); # else -# if !@HAVE_OPENDIR@ || __GNUC__ >= 11 +# if !@HAVE_OPENDIR@ || (__GNUC__ >= 11 && !defined __clang__) _GL_FUNCDECL_SYS (opendir, DIR *, (const char *dir_name) _GL_ARG_NONNULL ((1)) @@ -162,7 +162,8 @@ _GL_CXXALIAS_SYS (opendir, DIR *, (const char *dir_name)); # endif _GL_CXXALIASWARN (opendir); #else -# if @GNULIB_CLOSEDIR@ && !GNULIB_defined_DIR && __GNUC__ >= 11 && !defined opendir +# if @GNULIB_CLOSEDIR@ && !GNULIB_defined_DIR \ + && (__GNUC__ >= 11 && !defined __clang__) && !defined opendir /* For -Wmismatched-dealloc: Associate opendir with closedir or rpl_closedir. */ _GL_FUNCDECL_SYS (opendir, DIR *, @@ -274,7 +275,8 @@ _GL_FUNCDECL_RPL (fdopendir, DIR *, _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1)); _GL_CXXALIAS_RPL (fdopendir, DIR *, (int fd)); # else -# if !@HAVE_FDOPENDIR@ || !@HAVE_DECL_FDOPENDIR@ || __GNUC__ >= 11 +# if !@HAVE_FDOPENDIR@ || !@HAVE_DECL_FDOPENDIR@ \ + || (__GNUC__ >= 11 && !defined __clang__) _GL_FUNCDECL_SYS (fdopendir, DIR *, (int fd) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1)); @@ -283,7 +285,8 @@ _GL_CXXALIAS_SYS (fdopendir, DIR *, (int fd)); # endif _GL_CXXALIASWARN (fdopendir); #else -# if @GNULIB_CLOSEDIR@ && __GNUC__ >= 11 && !defined fdopendir +# if @GNULIB_CLOSEDIR@ \ + && (__GNUC__ >= 11 && !defined __clang__) && !defined fdopendir /* For -Wmismatched-dealloc: Associate fdopendir with closedir or rpl_closedir. */ _GL_FUNCDECL_SYS (fdopendir, DIR *, diff --git a/lib/fenv-private.h b/lib/fenv-private.h index e92c9de228..9571b7b93d 100644 --- a/lib/fenv-private.h +++ b/lib/fenv-private.h @@ -133,9 +133,12 @@ x86_387_fenv_t; occurring, trigger a trap rather than merely set the corresponding bit in the fpsr register. */ -# if __GNUC__ >= 6 +# if __GNUC__ >= 6 && !defined __clang__ # define _FPU_GETCW(fpcr) (fpcr = __builtin_aarch64_get_fpcr ()) # define _FPU_SETCW(fpcr) __builtin_aarch64_set_fpcr (fpcr) +# elif __clang_major__ >= 4 +# define _FPU_GETCW(fpcr) (fpcr = __builtin_arm_rsr ("fpcr")) +# define _FPU_SETCW(fpcr) __builtin_arm_wsr ("fpcr", fpcr) # else # define _FPU_GETCW(fpcr) \ __asm__ __volatile__ ("mrs %0, fpcr" : "=r" (fpcr)) @@ -143,9 +146,12 @@ x86_387_fenv_t; __asm__ __volatile__ ("msr fpcr, %0" : : "r" (fpcr)) # endif -# if __GNUC__ >= 6 +# if __GNUC__ >= 6 && !defined __clang__ # define _FPU_GETFPSR(fpsr) (fpsr = __builtin_aarch64_get_fpsr ()) # define _FPU_SETFPSR(fpsr) __builtin_aarch64_set_fpsr (fpsr) +# elif __clang_major__ >= 4 +# define _FPU_GETFPSR(fpsr) (fpsr = __builtin_arm_rsr ("fpsr")) +# define _FPU_SETFPSR(fpsr) __builtin_arm_wsr ("fpsr", fpsr) # else # define _FPU_GETFPSR(fpsr) \ __asm__ __volatile__ ("mrs %0, fpsr" : "=r" (fpsr)) diff --git a/lib/hamt.h b/lib/hamt.h index a25c612731..b483aa1bbe 100644 --- a/lib/hamt.h +++ b/lib/hamt.h @@ -61,9 +61,10 @@ _GL_INLINE_HEADER_BEGIN the same hamt. This is non-trivial as different hamts may share some structure. We can define it only when the compiler supports _Atomic. For GCC, - it is supported starting with GCC 4.9. */ + it is supported starting with GCC 4.9. For clang, with clang 4. */ -#if (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \ +#if (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4 && !defined __clang \ + || __clang_major__ >= 4) \ && __STDC_VERSION__ >= 201112L && !defined __STD_NO_ATOMICS__ \ && !defined __cplusplus # define GL_HAMT_THREAD_SAFE 1 diff --git a/lib/intprops-internal.h b/lib/intprops-internal.h index 443024c665..c8cc0e2019 100644 --- a/lib/intprops-internal.h +++ b/lib/intprops-internal.h @@ -21,7 +21,7 @@ #include /* Pacify GCC 13.2 in some calls to _GL_EXPR_SIGNED. */ -#if defined __GNUC__ && 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) && !defined __clang__ # pragma GCC diagnostic ignored "-Wtype-limits" #endif @@ -163,7 +163,7 @@ #if _GL_HAS_BUILTIN_MUL_OVERFLOW # if ((9 < __GNUC__ + (3 <= __GNUC_MINOR__) \ || (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) \ - && !defined __EDG__) + && !defined __clang__ && !defined __EDG__) # define _GL_INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r) # else /* Work around GCC bug 91450. */ diff --git a/lib/jit/cache.h b/lib/jit/cache.h index 94aef30526..16835d5e00 100644 --- a/lib/jit/cache.h +++ b/lib/jit/cache.h @@ -167,7 +167,7 @@ clear_cache (void *start, void *end) : "d" (addr), "d" (len) : "%d0", "%d2", "%d3" ); -#elif (__GNUC__ + (__GNUC_MINOR__ >= 3) > 4) \ +#elif (__GNUC__ + (__GNUC_MINOR__ >= 3) > 4 && !defined __clang__) \ || ((__clang_major__ + (__clang_minor__ >= 4) > 3) \ && (defined __aarch64__ /* arm64 */ || defined __arm__)) /* GCC >= 4.3 has a GCC built-in. diff --git a/lib/malloc.in.h b/lib/malloc.in.h index a08f21fb84..59e9c7b2e4 100644 --- a/lib/malloc.in.h +++ b/lib/malloc.in.h @@ -147,7 +147,7 @@ _GL_FUNCDECL_RPL (memalign, void *, _GL_CXXALIAS_RPL (memalign, void *, (size_t alignment, size_t size)); # else # if @HAVE_MEMALIGN@ -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ /* For -Wmismatched-dealloc: Associate memalign with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 _GL_FUNCDECL_SYS (memalign, void *, @@ -167,7 +167,7 @@ _GL_CXXALIAS_SYS (memalign, void *, (size_t alignment, size_t size)); _GL_CXXALIASWARN (memalign); # endif #else -# if __GNUC__ >= 11 && !defined memalign +# if (__GNUC__ >= 11 && !defined __clang__) && !defined memalign /* For -Wmismatched-dealloc: Associate memalign with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 _GL_FUNCDECL_SYS (memalign, void *, diff --git a/lib/mcel.h b/lib/mcel.h index d9f8385155..e5b0765bff 100644 --- a/lib/mcel.h +++ b/lib/mcel.h @@ -109,7 +109,7 @@ extern "C" { /* Pacify GCC re type limits. */ -#if defined __GNUC__ && 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) && !defined __clang__ # pragma GCC diagnostic ignored "-Wtype-limits" #endif diff --git a/lib/readutmp.c b/lib/readutmp.c index 3c4f97b146..0938a094cb 100644 --- a/lib/readutmp.c +++ b/lib/readutmp.c @@ -148,7 +148,7 @@ /* Size of the ut->ut_host member. */ #define UT_HOST_SIZE sizeof (((struct UTMP_STRUCT_NAME *) 0)->ut_host) -#if 8 <= __GNUC__ +#if _GL_GNUC_PREREQ (8, 0) # pragma GCC diagnostic ignored "-Wsizeof-pointer-memaccess" #endif diff --git a/lib/regex.h b/lib/regex.h index ccf40cebc0..71a45f8c27 100644 --- a/lib/regex.h +++ b/lib/regex.h @@ -531,7 +531,8 @@ typedef struct # endif #endif -#if defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__) +#if (defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__) \ + && !defined __clang__) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wvla" #endif @@ -539,7 +540,7 @@ typedef struct #ifndef _Attr_access_ # ifdef __attr_access # define _Attr_access_(arg) __attr_access (arg) -# elif defined __GNUC__ && 10 <= __GNUC__ +# elif defined __GNUC__ && 10 <= __GNUC__ && !defined __clang__ # define _Attr_access_(x) __attribute__ ((__access__ x)) # else # define _Attr_access_(x) @@ -688,7 +689,8 @@ extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg, extern void regfree (regex_t *__preg); -#if defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__) +#if (defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__) \ + && !defined __clang__) # pragma GCC diagnostic pop #endif diff --git a/lib/stddef.in.h b/lib/stddef.in.h index 49449315cf..e39268c60c 100644 --- a/lib/stddef.in.h +++ b/lib/stddef.in.h @@ -194,7 +194,7 @@ typedef union # ifndef _GL_HAS_BUILTIN_UNREACHABLE # if defined __clang_major__ && __clang_major__ < 5 # define _GL_HAS_BUILTIN_UNREACHABLE 0 -# elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) +# elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) && !defined __clang__ # define _GL_HAS_BUILTIN_UNREACHABLE 1 # elif defined __has_builtin # define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable) diff --git a/lib/stdio.in.h b/lib/stdio.in.h index dd9eecac07..08cae187ef 100644 --- a/lib/stdio.in.h +++ b/lib/stdio.in.h @@ -120,7 +120,7 @@ that can be freed by passing them as the Ith argument to the function F. */ #ifndef _GL_ATTRIBUTE_DEALLOC -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) # else # define _GL_ATTRIBUTE_DEALLOC(f, i) @@ -391,7 +391,7 @@ _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); # endif _GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode)); # else -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (fdopen, FILE *, @@ -410,7 +410,7 @@ _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode)); # endif _GL_CXXALIASWARN (fdopen); #else -# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fdopen +# if @GNULIB_FCLOSE@ && (__GNUC__ >= 11 && !defined __clang__) && !defined fdopen /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (fdopen, FILE *, @@ -539,7 +539,7 @@ _GL_FUNCDECL_RPL (fopen, FILE *, _GL_CXXALIAS_RPL (fopen, FILE *, (const char *restrict filename, const char *restrict mode)); # else -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ /* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */ _GL_FUNCDECL_SYS (fopen, FILE *, (const char *restrict filename, const char *restrict mode) @@ -552,7 +552,7 @@ _GL_CXXALIAS_SYS (fopen, FILE *, _GL_CXXALIASWARN (fopen); # endif #else -# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fopen +# if @GNULIB_FCLOSE@ && (__GNUC__ >= 11 && !defined __clang__) && !defined fopen /* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */ _GL_FUNCDECL_SYS (fopen, FILE *, (const char *restrict filename, const char *restrict mode) @@ -1241,7 +1241,7 @@ _GL_FUNCDECL_RPL (popen, FILE *, _GL_ATTRIBUTE_MALLOC); _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); # else -# if !@HAVE_POPEN@ || __GNUC__ >= 11 +# if !@HAVE_POPEN@ || (__GNUC__ >= 11 && !defined __clang__) _GL_FUNCDECL_SYS (popen, FILE *, (const char *cmd, const char *mode) _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) @@ -1251,7 +1251,8 @@ _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); # endif _GL_CXXALIASWARN (popen); #else -# if @GNULIB_PCLOSE@ && __GNUC__ >= 11 && !defined popen +# if @GNULIB_PCLOSE@ \ + && (__GNUC__ >= 11 && !defined __clang__) && !defined popen /* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */ _GL_FUNCDECL_SYS (popen, FILE *, (const char *cmd, const char *mode) @@ -1659,7 +1660,7 @@ _GL_FUNCDECL_RPL (tmpfile, FILE *, (void) _GL_ATTRIBUTE_MALLOC); _GL_CXXALIAS_RPL (tmpfile, FILE *, (void)); # else -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ _GL_FUNCDECL_SYS (tmpfile, FILE *, (void) _GL_ATTRIBUTE_DEALLOC (fclose, 1) @@ -1671,7 +1672,8 @@ _GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); _GL_CXXALIASWARN (tmpfile); # endif #else -# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined tmpfile +# if @GNULIB_FCLOSE@ \ + && (__GNUC__ >= 11 && !defined __clang__) && !defined tmpfile /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ _GL_FUNCDECL_SYS (tmpfile, FILE *, (void) _GL_ATTRIBUTE_DEALLOC (fclose, 1) diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index 96f8eb2f4c..1efdceec4a 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -132,7 +132,7 @@ struct random_data that can be freed by passing them as the Ith argument to the function F. */ #ifndef _GL_ATTRIBUTE_DEALLOC -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) # else # define _GL_ATTRIBUTE_DEALLOC(f, i) @@ -304,7 +304,7 @@ _GL_FUNCDECL_RPL (aligned_alloc, void *, _GL_CXXALIAS_RPL (aligned_alloc, void *, (size_t alignment, size_t size)); # else # if @HAVE_ALIGNED_ALLOC@ -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ /* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2 _GL_FUNCDECL_SYS (aligned_alloc, void *, @@ -324,7 +324,8 @@ _GL_CXXALIAS_SYS (aligned_alloc, void *, (size_t alignment, size_t size)); _GL_CXXALIASWARN (aligned_alloc); # endif #else -# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined aligned_alloc +# if @GNULIB_FREE_POSIX@ \ + && (__GNUC__ >= 11 && !defined __clang__) && !defined aligned_alloc /* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2 _GL_FUNCDECL_SYS (aligned_alloc, void *, @@ -376,7 +377,7 @@ _GL_FUNCDECL_RPL (calloc, void *, _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); _GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size)); # else -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ /* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 _GL_FUNCDECL_SYS (calloc, void *, @@ -395,7 +396,8 @@ _GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size)); _GL_CXXALIASWARN (calloc); # endif #else -# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined calloc +# if @GNULIB_FREE_POSIX@ \ + && (__GNUC__ >= 11 && !defined __clang__) && !defined calloc /* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 _GL_FUNCDECL_SYS (calloc, void *, @@ -427,7 +429,7 @@ _GL_FUNCDECL_RPL (canonicalize_file_name, char *, _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); _GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name)); # else -# if !@HAVE_CANONICALIZE_FILE_NAME@ || __GNUC__ >= 11 +# if !@HAVE_CANONICALIZE_FILE_NAME@ || (__GNUC__ >= 11 && !defined __clang__) # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (canonicalize_file_name, char *, (const char *name) @@ -449,7 +451,8 @@ _GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name)); # endif _GL_CXXALIASWARN (canonicalize_file_name); #else -# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined canonicalize_file_name +# if @GNULIB_FREE_POSIX@ \ + && (__GNUC__ >= 11 && !defined __clang__) && !defined canonicalize_file_name /* For -Wmismatched-dealloc: Associate canonicalize_file_name with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 @@ -683,7 +686,7 @@ _GL_FUNCDECL_RPL (malloc, void *, _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); _GL_CXXALIAS_RPL (malloc, void *, (size_t size)); # else -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ /* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 _GL_FUNCDECL_SYS (malloc, void *, @@ -702,7 +705,8 @@ _GL_CXXALIAS_SYS (malloc, void *, (size_t size)); _GL_CXXALIASWARN (malloc); # endif #else -# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined malloc +# if @GNULIB_FREE_POSIX@ \ + && (__GNUC__ >= 11 && !defined __clang__) && !defined malloc /* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 _GL_FUNCDECL_SYS (malloc, void *, @@ -1445,7 +1449,7 @@ _GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size) _GL_ATTRIBUTE_DEALLOC_FREE); _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size)); # else -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ /* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 _GL_FUNCDECL_SYS (realloc, void *, @@ -1464,7 +1468,8 @@ _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size)); _GL_CXXALIASWARN (realloc); # endif #else -# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined realloc +# if @GNULIB_FREE_POSIX@ \ + && (__GNUC__ >= 11 && !defined __clang__) && !defined realloc /* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 _GL_FUNCDECL_SYS (realloc, void *, diff --git a/lib/strftime.c b/lib/strftime.c index 9b1b27a1fc..4ddbec0426 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -321,7 +321,7 @@ enum pad_style maximum object size 9223372036854775807", caused by insufficient data flow analysis and value propagation of the 'width_add' expansion when GCC is not optimizing. Cf. . */ -#if __GNUC__ >= 7 && !__OPTIMIZE__ +#if _GL_GNUC_PREREQ (7, 0) && !__OPTIMIZE__ # pragma GCC diagnostic ignored "-Wstringop-overflow" #endif diff --git a/lib/string.in.h b/lib/string.in.h index 613d0337d5..903ba6e76e 100644 --- a/lib/string.in.h +++ b/lib/string.in.h @@ -79,7 +79,7 @@ that can be freed by passing them as the Ith argument to the function F. */ #ifndef _GL_ATTRIBUTE_DEALLOC -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) # else # define _GL_ATTRIBUTE_DEALLOC(f, i) @@ -621,7 +621,8 @@ _GL_CXXALIAS_MDA (strdup, char *, (char const *__s)); /* strdup exists as a function and as a macro. Get rid of the macro. */ # undef strdup # endif -# if (!@HAVE_DECL_STRDUP@ || __GNUC__ >= 11) && !defined strdup +# if (!@HAVE_DECL_STRDUP@ || (__GNUC__ >= 11 && !defined __clang__)) \ + && !defined strdup # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (strdup, char *, (char const *__s) @@ -639,7 +640,7 @@ _GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); # endif _GL_CXXALIASWARN (strdup); #else -# if __GNUC__ >= 11 && !defined strdup +# if (__GNUC__ >= 11 && !defined __clang__) && !defined strdup /* For -Wmismatched-dealloc: Associate strdup with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (strdup, char *, @@ -720,7 +721,8 @@ _GL_FUNCDECL_RPL (strndup, char *, _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); _GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n)); # else -# if !@HAVE_DECL_STRNDUP@ || (__GNUC__ >= 11 && !defined strndup) +# if !@HAVE_DECL_STRNDUP@ \ + || ((__GNUC__ >= 11 && !defined __clang__) && !defined strndup) # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (strndup, char *, (char const *__s, size_t __n) @@ -738,7 +740,7 @@ _GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n)); # endif _GL_CXXALIASWARN (strndup); #else -# if __GNUC__ >= 11 && !defined strndup +# if (__GNUC__ >= 11 && !defined __clang__) && !defined strndup /* For -Wmismatched-dealloc: Associate strndup with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (strndup, char *, diff --git a/lib/verify.h b/lib/verify.h index 978926a491..49a73c0508 100644 --- a/lib/verify.h +++ b/lib/verify.h @@ -34,11 +34,12 @@ #ifndef __cplusplus # if (201112 <= __STDC_VERSION__ \ || (!defined __STRICT_ANSI__ \ - && (4 < __GNUC__ + (6 <= __GNUC_MINOR__) || 5 <= __clang_major__))) + && ((4 < __GNUC__ + (6 <= __GNUC_MINOR__) && !defined __clang__) \ + || 5 <= __clang_major__))) # define _GL_HAVE__STATIC_ASSERT 1 # endif # if (202311 <= __STDC_VERSION__ \ - || (!defined __STRICT_ANSI__ && 9 <= __GNUC__)) + || (!defined __STRICT_ANSI__ && 9 <= __GNUC__ && !defined __clang__)) # define _GL_HAVE__STATIC_ASSERT1 1 # endif #endif @@ -215,7 +216,7 @@ template # define _GL_VERIFY(R, DIAGNOSTIC, ...) \ extern int (*_GL_GENSYM (_gl_verify_function) (void)) \ [_GL_VERIFY_TRUE (R, DIAGNOSTIC)] -# if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) +# if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) && !defined __clang__ # pragma GCC diagnostic ignored "-Wnested-externs" # endif #endif @@ -305,7 +306,7 @@ template #ifndef _GL_HAS_BUILTIN_UNREACHABLE # if defined __clang_major__ && __clang_major__ < 5 # define _GL_HAS_BUILTIN_UNREACHABLE 0 -# elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) +# elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) && !defined __clang__ # define _GL_HAS_BUILTIN_UNREACHABLE 1 # elif defined __has_builtin # define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable) diff --git a/lib/wchar.in.h b/lib/wchar.in.h index 4dcc422a92..6bbc31da88 100644 --- a/lib/wchar.in.h +++ b/lib/wchar.in.h @@ -95,7 +95,7 @@ that can be freed by passing them as the Ith argument to the function F. */ #ifndef _GL_ATTRIBUTE_DEALLOC -# if __GNUC__ >= 11 +# if __GNUC__ >= 11 && !defined __clang__ # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) # else # define _GL_ATTRIBUTE_DEALLOC(f, i) @@ -1326,7 +1326,8 @@ _GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s)); /* On Solaris 11.3, the header files declare the function in the std:: namespace, not in the global namespace. So, force a declaration in the global namespace. */ -# if !@HAVE_WCSDUP@ || (defined __sun && defined __cplusplus) || __GNUC__ >= 11 +# if !@HAVE_WCSDUP@ || (defined __sun && defined __cplusplus) \ + || (__GNUC__ >= 11 && !defined __clang__) # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (wcsdup, wchar_t *, (const wchar_t *s) @@ -1342,7 +1343,7 @@ _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s)); # endif _GL_CXXALIASWARN (wcsdup); #else -# if __GNUC__ >= 11 && !defined wcsdup +# if (__GNUC__ >= 11 && !defined __clang__) && !defined wcsdup /* For -Wmismatched-dealloc: Associate wcsdup with free or rpl_free. */ # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (wcsdup, wchar_t *, diff --git a/lib/xalloc-oversized.h b/lib/xalloc-oversized.h index 7f30f83e76..cfa527d38c 100644 --- a/lib/xalloc-oversized.h +++ b/lib/xalloc-oversized.h @@ -47,7 +47,8 @@ #if 7 <= __GNUC__ && !defined __clang__ && PTRDIFF_MAX < SIZE_MAX # define xalloc_oversized(n, s) \ __builtin_mul_overflow_p (n, s, (ptrdiff_t) 1) -#elif 5 <= __GNUC__ && !defined __ICC && PTRDIFF_MAX < SIZE_MAX +#elif 5 <= __GNUC__ && !defined __clang__ && !defined __ICC \ + && PTRDIFF_MAX < SIZE_MAX # define xalloc_oversized(n, s) \ (__builtin_constant_p (n) && __builtin_constant_p (s) \ ? __xalloc_oversized (n, s) \ diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index d29946b349..086e1f5c26 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -1,5 +1,5 @@ # gnulib-common.m4 -# serial 96.1 +# serial 96.2 dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -1168,7 +1168,7 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS], dnl -Wno-unused-parameter >= 3 >= 3.9 dnl cat > conftest.c <<\EOF - #if __GNUC__ >= 3 || (__clang_major__ + (__clang_minor__ >= 9) > 3) + #if (__GNUC__ >= 3 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3) -Wno-cast-qual -Wno-conversion -Wno-float-equal @@ -1177,23 +1177,23 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS], -Wno-unused-function -Wno-unused-parameter #endif - #if __GNUC__ + (__GNUC_MINOR__ >= 9) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) + #if (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3) -Wno-float-conversion #endif - #if __GNUC__ >= 7 || (__clang_major__ + (__clang_minor__ >= 9) > 3) + #if (__GNUC__ >= 7 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3) -Wimplicit-fallthrough #endif - #if __GNUC__ + (__GNUC_MINOR__ >= 8) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) + #if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 4 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3) -Wno-pedantic #endif #if 3 < __clang_major__ + (9 <= __clang_minor__) -Wno-tautological-constant-out-of-range-compare #endif - #if __GNUC__ + (__GNUC_MINOR__ >= 3) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) + #if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 4 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3) -Wno-sign-conversion -Wno-type-limits #endif - #if __GNUC__ + (__GNUC_MINOR__ >= 5) > 4 + #if (__GNUC__ + (__GNUC_MINOR__ >= 5) > 4 && !defined __clang__) -Wno-unsuffixed-float-constants #endif EOF diff --git a/tests/test-asyncsafe-linked_list-strong.c b/tests/test-asyncsafe-linked_list-strong.c index d90f08288f..67ba4f0b4e 100644 --- a/tests/test-asyncsafe-linked_list-strong.c +++ b/tests/test-asyncsafe-linked_list-strong.c @@ -44,7 +44,7 @@ #include /* Work around GCC bug 44511. */ -#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +#if _GL_GNUC_PREREQ (4, 3) # pragma GCC diagnostic ignored "-Wreturn-type" #endif diff --git a/tests/test-asyncsafe-linked_list-weak.c b/tests/test-asyncsafe-linked_list-weak.c index fa2e908707..4d9bcad58a 100644 --- a/tests/test-asyncsafe-linked_list-weak.c +++ b/tests/test-asyncsafe-linked_list-weak.c @@ -44,7 +44,7 @@ #include /* Work around GCC bug 44511. */ -#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +#if _GL_GNUC_PREREQ (4, 3) # pragma GCC diagnostic ignored "-Wreturn-type" #endif diff --git a/tests/test-c-strtod-mt.c b/tests/test-c-strtod-mt.c index f900014a20..a21cd37993 100644 --- a/tests/test-c-strtod-mt.c +++ b/tests/test-c-strtod-mt.c @@ -19,7 +19,7 @@ #include /* Work around GCC bug 44511. */ -#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +#if _GL_GNUC_PREREQ (4, 3) # pragma GCC diagnostic ignored "-Wreturn-type" #endif diff --git a/tests/test-c-strtof-mt.c b/tests/test-c-strtof-mt.c index fc797f9a52..5f18c917d2 100644 --- a/tests/test-c-strtof-mt.c +++ b/tests/test-c-strtof-mt.c @@ -19,7 +19,7 @@ #include /* Work around GCC bug 44511. */ -#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +#if _GL_GNUC_PREREQ (4, 3) # pragma GCC diagnostic ignored "-Wreturn-type" #endif diff --git a/tests/test-c-strtold-mt.c b/tests/test-c-strtold-mt.c index 0b48eb8bfc..6468b470f4 100644 --- a/tests/test-c-strtold-mt.c +++ b/tests/test-c-strtold-mt.c @@ -19,7 +19,7 @@ #include /* Work around GCC bug 44511. */ -#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +#if _GL_GNUC_PREREQ (4, 3) # pragma GCC diagnostic ignored "-Wreturn-type" #endif diff --git a/tests/test-gmtime_r-mt.c b/tests/test-gmtime_r-mt.c index 95a36ac682..87a5e7cc59 100644 --- a/tests/test-gmtime_r-mt.c +++ b/tests/test-gmtime_r-mt.c @@ -19,7 +19,7 @@ #include /* Work around GCC bug 44511. */ -#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +#if _GL_GNUC_PREREQ (4, 3) # pragma GCC diagnostic ignored "-Wreturn-type" #endif diff --git a/tests/test-intprops.c b/tests/test-intprops.c index 8d3b8c37e6..3bffc3f5a4 100644 --- a/tests/test-intprops.c +++ b/tests/test-intprops.c @@ -16,9 +16,12 @@ /* Written by Paul Eggert. */ +#include + +#if _GL_GNUC_PREREQ (4, 3) + /* Tell gcc not to warn about the long expressions that the overflow macros expand to, or about the (X < 0) expressions. */ -#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) # pragma GCC diagnostic ignored "-Woverlength-strings" # pragma GCC diagnostic ignored "-Wtype-limits" @@ -28,8 +31,6 @@ #endif -#include - #ifdef TEST_STDCKDINT # include #else diff --git a/tests/test-limits-h.c b/tests/test-limits-h.c index 6f574c88a0..885fe1f017 100644 --- a/tests/test-limits-h.c +++ b/tests/test-limits-h.c @@ -20,7 +20,7 @@ #include -#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +#if _GL_GNUC_PREREQ (4, 3) # pragma GCC diagnostic ignored "-Woverlength-strings" #endif diff --git a/tests/test-localtime_r-mt.c b/tests/test-localtime_r-mt.c index 096c83eb70..d7baeff414 100644 --- a/tests/test-localtime_r-mt.c +++ b/tests/test-localtime_r-mt.c @@ -19,7 +19,7 @@ #include /* Work around GCC bug 44511. */ -#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +#if _GL_GNUC_PREREQ (4, 3) # pragma GCC diagnostic ignored "-Wreturn-type" #endif diff --git a/tests/test-memrchr.c b/tests/test-memrchr.c index a6f15ceff7..836ed6f25d 100644 --- a/tests/test-memrchr.c +++ b/tests/test-memrchr.c @@ -28,7 +28,7 @@ SIGNATURE_CHECK (memrchr, void *, (void const *, int, size_t)); #include "macros.h" /* Work around GCC bug 101494. */ -#if 4 < __GNUC__ + (7 <= __GNUC_MINOR__) && __GNUC__ < 12 +#if _GL_GNUC_PREREQ (4, 7) && __GNUC__ < 12 # pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #endif diff --git a/tests/test-nl_langinfo-mt.c b/tests/test-nl_langinfo-mt.c index b7e16fccce..2325ee91d6 100644 --- a/tests/test-nl_langinfo-mt.c +++ b/tests/test-nl_langinfo-mt.c @@ -19,7 +19,7 @@ #include /* Work around GCC bug 44511. */ -#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +#if _GL_GNUC_PREREQ (4, 3) # pragma GCC diagnostic ignored "-Wreturn-type" #endif diff --git a/tests/test-setlocale_null-mt-all.c b/tests/test-setlocale_null-mt-all.c index d565aa0382..567a289fa9 100644 --- a/tests/test-setlocale_null-mt-all.c +++ b/tests/test-setlocale_null-mt-all.c @@ -19,7 +19,7 @@ #include /* Work around GCC bug 44511. */ -#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +#if _GL_GNUC_PREREQ (4, 3) # pragma GCC diagnostic ignored "-Wreturn-type" #endif diff --git a/tests/test-setlocale_null-mt-one.c b/tests/test-setlocale_null-mt-one.c index cbd057f94f..cc504812d6 100644 --- a/tests/test-setlocale_null-mt-one.c +++ b/tests/test-setlocale_null-mt-one.c @@ -19,7 +19,7 @@ #include /* Work around GCC bug 44511. */ -#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +#if _GL_GNUC_PREREQ (4, 3) # pragma GCC diagnostic ignored "-Wreturn-type" #endif diff --git a/tests/test-statat.c b/tests/test-statat.c index a093caeeb3..0576f8f204 100644 --- a/tests/test-statat.c +++ b/tests/test-statat.c @@ -18,7 +18,7 @@ #include "openat.h" -#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +#if _GL_GNUC_PREREQ (4, 3) # pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif diff --git a/tests/test-xvasprintf.c b/tests/test-xvasprintf.c index 038b0c242b..32b82cbb72 100644 --- a/tests/test-xvasprintf.c +++ b/tests/test-xvasprintf.c @@ -16,15 +16,15 @@ /* Written by Bruno Haible , 2007. */ +#include + /* Tell GCC not to warn about the specific edge cases tested here. */ -#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__ +#if _GL_GNUC_PREREQ (4, 3) # pragma GCC diagnostic ignored "-Wformat-zero-length" # pragma GCC diagnostic ignored "-Wformat-nonliteral" # pragma GCC diagnostic ignored "-Wformat-security" #endif -#include - #include "xvasprintf.h" #include -- 2.39.5