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 <bruno@clisp.org>
+
+ 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 <bruno@clisp.org>
readutmp: In systemd mode, show sessions of type "web".
# 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__))))))
#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
# 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
/* 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
#include <idx.h>
/* 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
#include <idx.h>
/* 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
#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))
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)
_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))
# 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 *,
_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));
# 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 *,
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))
__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))
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
#include <limits.h>
/* 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
#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. */
: "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.
_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 *,
_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 *,
/* 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
/* 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
# 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
#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)
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
# 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)
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)
# 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 *,
# 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 *,
_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)
_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)
_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)
# 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)
_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)
_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)
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)
_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 *,
_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 *,
_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 *,
_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 *,
_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)
# 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
_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 *,
_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 *,
_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 *,
_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 *,
maximum object size 9223372036854775807", caused by insufficient data flow
analysis and value propagation of the 'width_add' expansion when GCC is not
optimizing. Cf. <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443>. */
-#if __GNUC__ >= 7 && !__OPTIMIZE__
+#if _GL_GNUC_PREREQ (7, 0) && !__OPTIMIZE__
# pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
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)
/* 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)
# 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 *,
_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)
# 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 *,
#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
# 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
#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)
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)
/* 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)
# 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 *,
#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) \
# 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,
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
-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
#include <config.h>
/* Work around GCC bug 44511. */
-#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__)
+#if _GL_GNUC_PREREQ (4, 3)
# pragma GCC diagnostic ignored "-Wreturn-type"
#endif
#include <config.h>
/* Work around GCC bug 44511. */
-#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__)
+#if _GL_GNUC_PREREQ (4, 3)
# pragma GCC diagnostic ignored "-Wreturn-type"
#endif
#include <config.h>
/* Work around GCC bug 44511. */
-#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__)
+#if _GL_GNUC_PREREQ (4, 3)
# pragma GCC diagnostic ignored "-Wreturn-type"
#endif
#include <config.h>
/* Work around GCC bug 44511. */
-#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__)
+#if _GL_GNUC_PREREQ (4, 3)
# pragma GCC diagnostic ignored "-Wreturn-type"
#endif
#include <config.h>
/* Work around GCC bug 44511. */
-#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__)
+#if _GL_GNUC_PREREQ (4, 3)
# pragma GCC diagnostic ignored "-Wreturn-type"
#endif
#include <config.h>
/* Work around GCC bug 44511. */
-#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__)
+#if _GL_GNUC_PREREQ (4, 3)
# pragma GCC diagnostic ignored "-Wreturn-type"
#endif
/* Written by Paul Eggert. */
+#include <config.h>
+
+#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"
#endif
-#include <config.h>
-
#ifdef TEST_STDCKDINT
# include <stdckdint.h>
#else
#include <limits.h>
-#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__)
+#if _GL_GNUC_PREREQ (4, 3)
# pragma GCC diagnostic ignored "-Woverlength-strings"
#endif
#include <config.h>
/* Work around GCC bug 44511. */
-#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__)
+#if _GL_GNUC_PREREQ (4, 3)
# pragma GCC diagnostic ignored "-Wreturn-type"
#endif
#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
#include <config.h>
/* Work around GCC bug 44511. */
-#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__)
+#if _GL_GNUC_PREREQ (4, 3)
# pragma GCC diagnostic ignored "-Wreturn-type"
#endif
#include <config.h>
/* Work around GCC bug 44511. */
-#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__)
+#if _GL_GNUC_PREREQ (4, 3)
# pragma GCC diagnostic ignored "-Wreturn-type"
#endif
#include <config.h>
/* Work around GCC bug 44511. */
-#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__)
+#if _GL_GNUC_PREREQ (4, 3)
# pragma GCC diagnostic ignored "-Wreturn-type"
#endif
#include "openat.h"
-#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__)
+#if _GL_GNUC_PREREQ (4, 3)
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+#include <config.h>
+
/* 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 <config.h>
-
#include "xvasprintf.h"
#include <stdarg.h>