From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 79D311F47C for ; Wed, 25 Jan 2023 14:06:39 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=clisp.org header.i=@clisp.org header.a=rsa-sha256 header.s=strato-dkim-0002 header.b=l2PGXZYp; dkim-atps=neutral Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKgPv-0005M4-Qj; Wed, 25 Jan 2023 09:06:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKgPi-0005L5-BM; Wed, 25 Jan 2023 09:06:10 -0500 Received: from mo4-p00-ob.smtp.rzone.de ([85.215.255.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKgPd-0003cY-Cu; Wed, 25 Jan 2023 09:06:10 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1674655560; cv=none; d=strato.com; s=strato-dkim-0002; b=mo3Tb6neTgGwkW9OBtWLjFPNMKn41qhBY2oM43V+kCXgloMW/Ium+rtpOHXN10wjSf PVhzaQ0LIumCalhzMBYPSezZCb6Q7iokr2fecIJOlzfGTuPwPbulmIATR9807qzkNXyF jvHRCAyfY9/zZPQLweEZWon556cLLF1PtVbsw11mxu0A2np1SEJVb/nEAE/1AnNt6JXC 0BMQm1Ydh6Kk0PgVG+Sq6izORanMRFQq0J5QiQmz367gSmWjyUnNhyXn+3+UzPQL3Yzw rfI0d1rli00HOhU0yQR6wfyxPU1UNwhF34O6kO6fNQEYQGN++pRYbxKsDFTUJ88fVtk+ IfDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1674655560; s=strato-dkim-0002; d=strato.com; h=Message-ID:Date:Subject:Cc:To:From:Cc:Date:From:Subject:Sender; bh=j381ULYD+eCyreqhhDJX6aHBVhH/MoO9INtd0ZKqn6g=; b=QOWQZhAy0RkuLMoEbq49boV/t7OG0Z7DVCH/ZGUQZWsrj2yXF81dKhsQMO3px8Ry+P 2XqMjmEwLXSDn3GJRjmMXfKyRMEXtE5PvYykd9CMMGRwL2m1TlvKpKaJHgG+Vu+kN0ll Xl7wEAafCqb9xGoEJhjiInKfIsqs6Y5EC5cMvdOrf4wCY049CtO0wJlY2OkphMi8VFyK gKEGTdRQIhHxb8fI8KHBL3owh0pxrYFzpH7XWR4V1oyIXkiPfClJ1aTqO/ixasN+bONJ OWrRV1U8nQWLW23qlV0Kj38BBClr1GKQaArH8PC/c+RemzUL2Shxbyi4qaf5n/8frLrA elrQ== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1674655560; s=strato-dkim-0002; d=clisp.org; h=Message-ID:Date:Subject:Cc:To:From:Cc:Date:From:Subject:Sender; bh=j381ULYD+eCyreqhhDJX6aHBVhH/MoO9INtd0ZKqn6g=; b=l2PGXZYp+p0SJl5j59hM6G1gFrJB+rt+uO9YBA9g5GTeaFPF+6LyxyL7b4DrzBpInH FiSUBIAp9eHAmjxfPoaoBBNJhu5KwV16p07hZSWLFkzupfQOSYBULtoWhtlnmd2nj92m jQ/khrwHDis4ZUsJglv+LTB5Xe75r3O7Vb5UkY5Ns1z6EvzmG7wv2BOxZ+Ke2YGmFV/V f+hfh+fRHUf6lsNas+oCDiNiDSiz725+jlVH44wPxs55ern2MRDJAlU1jIlZ4mHL2uUK XrC+En7p25j3H27Uyhb7o6Khrblc2B1U9/yFInn+0I8FxBaqbC+ILNHYIuS6Te77F4mi umnQ== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH0WWb0LN8XZoH94zq68+3cfpOfjvdojYPtA21VstjeqKl4wVZ9" Received: from nimes.localnet by smtp.strato.de (RZmta 49.2.2 AUTH) with ESMTPSA id 098542z0PE5x90R (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Wed, 25 Jan 2023 15:05:59 +0100 (CET) From: Bruno Haible To: bug-gnulib@gnu.org, epsilon-devel@gnu.org Cc: poke-devel@gnu.org Subject: Keep config.h idempotent Date: Wed, 25 Jan 2023 15:05:59 +0100 Message-ID: <2093695.QfOb2KXJ6Q@nimes> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Received-SPF: none client-ip=85.215.255.25; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Compiling GNU poke 2.90.1 on the gcc401.fsffrance.org machine, I get a compilation failure: gcc -DHAVE_CONFIG_H -I. -I../../jitter -I./config-private -I./jitter -I./g= nulib-local -I../../jitter/gnulib-local -DJITTER_WITH_LIBTEXTSTYLE=3D1 -DJ= ITTER_FLAGDIR=3D\"/home/haible/poke-2.90.1/build/jitter/flags\" -DJITTER_TE= MPLATEDIR=3D\"/home/haible/poke-2.90.1/build/jitter/../../jitter/templates\= " -DJITTER_INTERNAL=3D1 -I/home/haible/include -Wall -fvisibility=3Dhidden = =2Dg -O2 -MT jitterc/bin_jitter-jitterc-generate.o -MD -MP -MF jitterc/.dep= s/bin_jitter-jitterc-generate.Tpo -c -o jitterc/bin_jitter-jitterc-generate= =2Eo `test -f 'jitterc/jitterc-generate.c' || echo '../../jitter/'`jitterc/= jitterc-generate.c In file included from ../../jitter/jitterc/jitterc-utility.h:27, from ../../jitter/jitterc/jitterc-generate.c:39: =2E/config-private/config.h:2114:1: error: macro "__has_attribute" requires= an identifier 2114 | #if _GL_HAS_ATTRIBUTE (returns_nonnull) | ^~~~~~~~~~~~~~~~~~~ =2E/config-private/config.h:2117: warning: "_GL_ATTRIBUTE_RETURNS_NONNULL" = redefined 2117 | # define _GL_ATTRIBUTE_RETURNS_NONNULL |=20 In file included from ../../jitter/jitterc/jitterc-vm.h:26, from ../../jitter/jitterc/jitterc-generate.h:33, from ../../jitter/jitterc/jitterc-generate.c:38: =2E/config-private/config.h:2115: note: this is the location of the previou= s definition 2115 | # define _GL_ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_no= nnull__)) |=20 In file included from ../../jitter/jitterc/jitterc-rewrite.h:26, from ../../jitter/jitterc/jitterc-generate.c:41: =2E/config-private/config.h:2114:1: error: macro "__has_attribute" requires= an identifier 2114 | #if _GL_HAS_ATTRIBUTE (returns_nonnull) | ^~~~~~~~~~~~~~~~~~~ make[3]: *** [Makefile:10494: jitterc/bin_jitter-jitterc-generate.o] Error 1 make[3]: Leaving directory '/home/haible/poke-2.90.1/build/jitter' make[2]: *** [Makefile:18650: check-recursive] Error 1 What happens, is that this compilation unit #includes five times, and somewhere between the first and the fifth inclusion, poke's code does #define returns_nonnull This is their particular way of not emitting this particular GCC/clang attribute, and is OK since 'returns_nonnull' is not a keyword and not a token in the reserved namespace. Including several times is OK to do, according to our documentat= ion in https://www.gnu.org/software/gnulib/manual/html_node/Source-changes.html= : - We say "to all your source files and likely also to all your tests sour= ce files you need to add an =E2=80=98#include =E2=80=99 at the t= op." The GNU jitter authors took that literally and added '#include ' not only at the top of the .c files, but also at the top of the .h file= s. - We don't say that #include should not be placed at the top of .h files. Doing so is an optimization, and we don't force (nor even hin= t) our users at this optimization. Hence this sequence #include #define returns_nonnull #include is supposed to work fine. But it produces an error error: macro "__has_attribute" requires an identifier This patch fixes it, by adding double-inclusion guards to all code that uses __has_attribute. Note the we had already done so for _GL_ATTRIBUTE_DEALLOC_= =46REE. 2023-01-25 Bruno Haible Keep config.h idempotent. * m4/gnulib-common.m4 (gl_COMMON_BODY): Add double-inclusion guards to the definitions of the macros _GL_ATTRIBUTE_ALLOC_SIZE, _GL_ATTRIBUTE_ALWAYS_INLINE, _GL_ATTRIBUTE_ARTIFICIAL, _GL_ATTRIBUTE_COLD, _GL_ATTRIBUTE_CONST, _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DEPRECATED, _GL_ATTRIBUTE_ERROR, _GL_ATTRIBUTE_WARNING, _GL_ATTRIBUTE_EXTERNALLY_VISIBLE, _GL_ATTRIBUTE_FALLTHROUGH, _GL_ATTRIBUTE_FORMAT, _GL_ATTRIBUTE_LEAF, _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_MAY_ALIAS, _GL_ATTRIBUTE_MAYBE_UNUSED, _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOINLINE, _GL_ATTRIBUTE_NONNULL, _GL_ATTRIBUTE_NONSTRING, _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PACKED, _GL_ATTRIBUTE_PURE, _GL_ATTRIBUTE_RETURNS_NONNULL, _GL_ATTRIBUTE_SENTINEL, _GL_ATTRIBUTE_UNUSED, _GL_UNUSED_LABEL. diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index d5b2f7c4e5..0f1a6ac1ea 100644 =2D-- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -1,4 +1,4 @@ =2D# gnulib-common.m4 serial 77 +# gnulib-common.m4 serial 78 dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -124,29 +124,35 @@ AC_DEFUN([gl_COMMON_BODY], [ by the Nth argument of the function is the size of the returned memory = block. */ /* Applies to: function, pointer to function, function types. */ =2D#if _GL_HAS_ATTRIBUTE (alloc_size) =2D# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ a= rgs)) =2D#else =2D# define _GL_ATTRIBUTE_ALLOC_SIZE(args) +#ifndef _GL_ATTRIBUTE_ALLOC_SIZE +# if _GL_HAS_ATTRIBUTE (alloc_size) +# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ ar= gs)) +# else +# define _GL_ATTRIBUTE_ALLOC_SIZE(args) +# endif #endif =20 /* _GL_ATTRIBUTE_ALWAYS_INLINE tells that the compiler should always inlin= e the function and report an error if it cannot do so. */ /* Applies to: function. */ =2D#if _GL_HAS_ATTRIBUTE (always_inline) =2D# define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__)) =2D#else =2D# define _GL_ATTRIBUTE_ALWAYS_INLINE +#ifndef _GL_ATTRIBUTE_ALWAYS_INLINE +# if _GL_HAS_ATTRIBUTE (always_inline) +# define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__)) +# else +# define _GL_ATTRIBUTE_ALWAYS_INLINE +# endif #endif =20 /* _GL_ATTRIBUTE_ARTIFICIAL declares that the function is not important to= show in stack traces when debugging. The compiler should omit the function= from stack traces. */ /* Applies to: function. */ =2D#if _GL_HAS_ATTRIBUTE (artificial) =2D# define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__)) =2D#else =2D# define _GL_ATTRIBUTE_ARTIFICIAL +#ifndef _GL_ATTRIBUTE_ARTIFICIAL +# if _GL_HAS_ATTRIBUTE (artificial) +# define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__)) +# else +# define _GL_ATTRIBUTE_ARTIFICIAL +# endif #endif =20 /* _GL_ATTRIBUTE_COLD declares that the function is rarely executed. */ @@ -154,14 +160,16 @@ AC_DEFUN([gl_COMMON_BODY], [ /* Avoid __attribute__ ((cold)) on MinGW; see thread starting at . Also, Oracle Studio 12.6 requires 'cold' not '__cold__'. */ =2D#if _GL_HAS_ATTRIBUTE (cold) && !defined __MINGW32__ =2D# ifndef __SUNPRO_C =2D# define _GL_ATTRIBUTE_COLD __attribute__ ((__cold__)) +#ifndef _GL_ATTRIBUTE_COLD +# if _GL_HAS_ATTRIBUTE (cold) && !defined __MINGW32__ +# ifndef __SUNPRO_C +# define _GL_ATTRIBUTE_COLD __attribute__ ((__cold__)) +# else +# define _GL_ATTRIBUTE_COLD __attribute__ ((cold)) +# endif # else =2D# define _GL_ATTRIBUTE_COLD __attribute__ ((cold)) +# define _GL_ATTRIBUTE_COLD # endif =2D#else =2D# define _GL_ATTRIBUTE_COLD #endif =20 /* _GL_ATTRIBUTE_CONST declares that it is OK for a compiler to omit dupli= cate @@ -171,10 +179,12 @@ AC_DEFUN([gl_COMMON_BODY], [ forever, and does not call longjmp. (This attribute is stricter than _GL_ATTRIBUTE_PURE.) */ /* Applies to: functions. */ =2D#if _GL_HAS_ATTRIBUTE (const) =2D# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) =2D#else =2D# define _GL_ATTRIBUTE_CONST +#ifndef _GL_ATTRIBUTE_CONST +# if _GL_HAS_ATTRIBUTE (const) +# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) +# else +# define _GL_ATTRIBUTE_CONST +# endif #endif =20 /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers @@ -183,10 +193,12 @@ AC_DEFUN([gl_COMMON_BODY], [ _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers = that can be freed via 'free'; it can be used only after declaring 'free'. */ /* Applies to: functions. Cannot be used on inline functions. */ =2D#if _GL_GNUC_PREREQ (11, 0) =2D# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) =2D#else =2D# define _GL_ATTRIBUTE_DEALLOC(f, i) +#ifndef _GL_ATTRIBUTE_DEALLOC +# if _GL_GNUC_PREREQ (11, 0) +# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) +# else +# define _GL_ATTRIBUTE_DEALLOC(f, i) +# endif #endif /* If gnulib's or has already defined this macro, con= tinue to use this earlier definition, since may not have been incl= uded @@ -210,16 +222,18 @@ AC_DEFUN([gl_COMMON_BODY], [ - enumeration, enumeration item, - typedef, in C++ also: namespace, class, template specialization. */ =2D#ifdef __has_c_attribute =2D# if __has_c_attribute (__deprecated__) =2D# define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]] =2D# endif =2D#endif =2D#if !defined _GL_ATTRIBUTE_DEPRECATED && _GL_HAS_ATTRIBUTE (deprecated) =2D# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__)) =2D#endif #ifndef _GL_ATTRIBUTE_DEPRECATED =2D# define _GL_ATTRIBUTE_DEPRECATED +# ifdef __has_c_attribute +# if __has_c_attribute (__deprecated__) +# define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]] +# endif +# endif +# if !defined _GL_ATTRIBUTE_DEPRECATED && _GL_HAS_ATTRIBUTE (deprecated) +# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__)) +# endif +# ifndef _GL_ATTRIBUTE_DEPRECATED +# define _GL_ATTRIBUTE_DEPRECATED +# endif #endif =20 /* _GL_ATTRIBUTE_ERROR(msg) requests an error if a function is called and @@ -227,24 +241,28 @@ AC_DEFUN([gl_COMMON_BODY], [ _GL_ATTRIBUTE_WARNING(msg) requests a warning if a function is called a= nd the function call is not optimized away. */ /* Applies to: functions. */ =2D#if _GL_HAS_ATTRIBUTE (error) =2D# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__error__ (msg))) =2D# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__warning__ (msg))) =2D#elif _GL_HAS_ATTRIBUTE (diagnose_if) =2D# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__diagnose_if__ (1, ms= g, "error"))) =2D# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__diagnose_if__ (1, = msg, "warning"))) =2D#else =2D# define _GL_ATTRIBUTE_ERROR(msg) =2D# define _GL_ATTRIBUTE_WARNING(msg) +#if !(defined _GL_ATTRIBUTE_ERROR && defined _GL_ATTRIBUTE_WARNING) +# if _GL_HAS_ATTRIBUTE (error) +# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__error__ (msg))) +# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__warning__ (msg))) +# elif _GL_HAS_ATTRIBUTE (diagnose_if) +# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__diagnose_if__ (1, msg= , "error"))) +# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__diagnose_if__ (1, m= sg, "warning"))) +# else +# define _GL_ATTRIBUTE_ERROR(msg) +# define _GL_ATTRIBUTE_WARNING(msg) +# endif #endif =20 /* _GL_ATTRIBUTE_EXTERNALLY_VISIBLE declares that the entity should remain visible to debuggers etc., even with '-fwhole-program'. */ /* Applies to: functions, variables. */ =2D#if _GL_HAS_ATTRIBUTE (externally_visible) =2D# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((externally_vis= ible)) =2D#else =2D# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE +#ifndef _GL_ATTRIBUTE_EXTERNALLY_VISIBLE +# if _GL_HAS_ATTRIBUTE (externally_visible) +# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((externally_visi= ble)) +# else +# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE +# endif #endif =20 /* _GL_ATTRIBUTE_FALLTHROUGH declares that it is not a programming mistake= if @@ -252,16 +270,18 @@ AC_DEFUN([gl_COMMON_BODY], [ 'default' label. The compiler should not warn in this case. */ /* Applies to: Empty statement (;), inside a 'switch' statement. */ /* Always expands to something. */ =2D#ifdef __has_c_attribute =2D# if __has_c_attribute (__fallthrough__) =2D# define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]] =2D# endif =2D#endif =2D#if !defined _GL_ATTRIBUTE_FALLTHROUGH && _GL_HAS_ATTRIBUTE (fallthrough) =2D# define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__)) =2D#endif #ifndef _GL_ATTRIBUTE_FALLTHROUGH =2D# define _GL_ATTRIBUTE_FALLTHROUGH ((void) 0) +# ifdef __has_c_attribute +# if __has_c_attribute (__fallthrough__) +# define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]] +# endif +# endif +# if !defined _GL_ATTRIBUTE_FALLTHROUGH && _GL_HAS_ATTRIBUTE (fallthrough) +# define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__)) +# endif +# ifndef _GL_ATTRIBUTE_FALLTHROUGH +# define _GL_ATTRIBUTE_FALLTHROUGH ((void) 0) +# endif #endif =20 /* _GL_ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK)) @@ -275,10 +295,12 @@ AC_DEFUN([gl_COMMON_BODY], [ If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK are suitable for the format string. */ /* Applies to: functions. */ =2D#if _GL_HAS_ATTRIBUTE (format) =2D# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) =2D#else =2D# define _GL_ATTRIBUTE_FORMAT(spec) +#ifndef _GL_ATTRIBUTE_FORMAT +# if _GL_HAS_ATTRIBUTE (format) +# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) +# else +# define _GL_ATTRIBUTE_FORMAT(spec) +# endif #endif =20 /* _GL_ATTRIBUTE_LEAF declares that if the function is called from some ot= her @@ -286,19 +308,23 @@ AC_DEFUN([gl_COMMON_BODY], [ exception handling. This declaration lets the compiler optimize that u= nit more aggressively. */ /* Applies to: functions. */ =2D#if _GL_HAS_ATTRIBUTE (leaf) =2D# define _GL_ATTRIBUTE_LEAF __attribute__ ((__leaf__)) =2D#else =2D# define _GL_ATTRIBUTE_LEAF +#ifndef _GL_ATTRIBUTE_LEAF +# if _GL_HAS_ATTRIBUTE (leaf) +# define _GL_ATTRIBUTE_LEAF __attribute__ ((__leaf__)) +# else +# define _GL_ATTRIBUTE_LEAF +# endif #endif =20 /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to fr= eshly allocated memory. */ /* Applies to: functions. */ =2D#if _GL_HAS_ATTRIBUTE (malloc) =2D# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) =2D#else =2D# define _GL_ATTRIBUTE_MALLOC +#ifndef _GL_ATTRIBUTE_MALLOC +# if _GL_HAS_ATTRIBUTE (malloc) +# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +# else +# define _GL_ATTRIBUTE_MALLOC +# endif #endif =20 /* _GL_ATTRIBUTE_MAY_ALIAS declares that pointers to the type may point to= the @@ -306,10 +332,12 @@ AC_DEFUN([gl_COMMON_BODY], [ strict aliasing optimization. */ /* Applies to: types. */ /* Oracle Studio 12.6 mishandles may_alias despite __has_attribute OK. */ =2D#if _GL_HAS_ATTRIBUTE (may_alias) && !defined __SUNPRO_C =2D# define _GL_ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__)) =2D#else =2D# define _GL_ATTRIBUTE_MAY_ALIAS +#ifndef _GL_ATTRIBUTE_MAY_ALIAS +# if _GL_HAS_ATTRIBUTE (may_alias) && !defined __SUNPRO_C +# define _GL_ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__)) +# else +# define _GL_ATTRIBUTE_MAY_ALIAS +# endif #endif =20 /* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistak= e if @@ -324,13 +352,15 @@ AC_DEFUN([gl_COMMON_BODY], [ /* In C++ and C23, this is spelled [[__maybe_unused__]]. GCC's syntax is __attribute__ ((__unused__)). clang supports both syntaxes. */ =2D#ifdef __has_c_attribute =2D# if __has_c_attribute (__maybe_unused__) =2D# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] =2D# endif =2D#endif #ifndef _GL_ATTRIBUTE_MAYBE_UNUSED =2D# define _GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_UNUSED +# ifdef __has_c_attribute +# if __has_c_attribute (__maybe_unused__) +# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] +# endif +# endif +# ifndef _GL_ATTRIBUTE_MAYBE_UNUSED +# define _GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_UNUSED +# endif #endif /* Alternative spelling of this macro, for convenience and for compatibility with glibc/include/libc-symbols.h. */ @@ -342,25 +372,29 @@ AC_DEFUN([gl_COMMON_BODY], [ discard the return value. The compiler may warn if the caller does not= use the return value, unless the caller uses something like ignore_value. = */ /* Applies to: function, enumeration, class. */ =2D#ifdef __has_c_attribute =2D# if __has_c_attribute (__nodiscard__) =2D# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] =2D# endif =2D#endif =2D#if !defined _GL_ATTRIBUTE_NODISCARD && _GL_HAS_ATTRIBUTE (warn_unused_r= esult) =2D# define _GL_ATTRIBUTE_NODISCARD __attribute__ ((__warn_unused_result__)) =2D#endif #ifndef _GL_ATTRIBUTE_NODISCARD =2D# define _GL_ATTRIBUTE_NODISCARD +# ifdef __has_c_attribute +# if __has_c_attribute (__nodiscard__) +# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] +# endif +# endif +# if !defined _GL_ATTRIBUTE_NODISCARD && _GL_HAS_ATTRIBUTE (warn_unused_re= sult) +# define _GL_ATTRIBUTE_NODISCARD __attribute__ ((__warn_unused_result__)) +# endif +# ifndef _GL_ATTRIBUTE_NODISCARD +# define _GL_ATTRIBUTE_NODISCARD +# endif #endif =20 /* _GL_ATTRIBUTE_NOINLINE tells that the compiler should not inline the function. */ /* Applies to: functions. */ =2D#if _GL_HAS_ATTRIBUTE (noinline) =2D# define _GL_ATTRIBUTE_NOINLINE __attribute__ ((__noinline__)) =2D#else =2D# define _GL_ATTRIBUTE_NOINLINE +#ifndef _GL_ATTRIBUTE_NOINLINE +# if _GL_HAS_ATTRIBUTE (noinline) +# define _GL_ATTRIBUTE_NOINLINE __attribute__ ((__noinline__)) +# else +# define _GL_ATTRIBUTE_NOINLINE +# endif #endif =20 /* _GL_ATTRIBUTE_NONNULL ((N1, N2,...)) declares that the arguments N1, N2= ,... @@ -368,20 +402,24 @@ AC_DEFUN([gl_COMMON_BODY], [ _GL_ATTRIBUTE_NONNULL () declares that all pointer arguments must not be null. */ /* Applies to: functions. */ =2D#if _GL_HAS_ATTRIBUTE (nonnull) =2D# define _GL_ATTRIBUTE_NONNULL(args) __attribute__ ((__nonnull__ args)) =2D#else =2D# define _GL_ATTRIBUTE_NONNULL(args) +#ifndef _GL_ATTRIBUTE_NONNULL +# if _GL_HAS_ATTRIBUTE (nonnull) +# define _GL_ATTRIBUTE_NONNULL(args) __attribute__ ((__nonnull__ args)) +# else +# define _GL_ATTRIBUTE_NONNULL(args) +# endif #endif =20 /* _GL_ATTRIBUTE_NONSTRING declares that the contents of a character array= is not meant to be NUL-terminated. */ /* Applies to: struct/union members and variables that are arrays of eleme= nt type '[[un]signed] char'. */ =2D#if _GL_HAS_ATTRIBUTE (nonstring) =2D# define _GL_ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__)) =2D#else =2D# define _GL_ATTRIBUTE_NONSTRING +#ifndef _GL_ATTRIBUTE_NONSTRING +# if _GL_HAS_ATTRIBUTE (nonstring) +# define _GL_ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__)) +# else +# define _GL_ATTRIBUTE_NONSTRING +# endif #endif =20 /* There is no _GL_ATTRIBUTE_NORETURN; use _Noreturn instead. */ @@ -389,10 +427,12 @@ AC_DEFUN([gl_COMMON_BODY], [ /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw excepti= ons. */ /* Applies to: functions. */ =2D#if _GL_HAS_ATTRIBUTE (nothrow) && !defined __cplusplus =2D# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) =2D#else =2D# define _GL_ATTRIBUTE_NOTHROW +#ifndef _GL_ATTRIBUTE_NOTHROW +# if _GL_HAS_ATTRIBUTE (nothrow) && !defined __cplusplus +# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif #endif =20 /* _GL_ATTRIBUTE_PACKED declares: @@ -401,10 +441,12 @@ AC_DEFUN([gl_COMMON_BODY], [ minimizing the memory required. */ /* Applies to: struct members, struct, union, in C++ also: class. */ =2D#if _GL_HAS_ATTRIBUTE (packed) =2D# define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__)) =2D#else =2D# define _GL_ATTRIBUTE_PACKED +#ifndef _GL_ATTRIBUTE_PACKED +# if _GL_HAS_ATTRIBUTE (packed) +# define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__)) +# else +# define _GL_ATTRIBUTE_PACKED +# endif #endif =20 /* _GL_ATTRIBUTE_PURE declares that It is OK for a compiler to omit duplic= ate @@ -414,19 +456,23 @@ AC_DEFUN([gl_COMMON_BODY], [ observable state, and always returns exactly once. (This attribute is looser than _GL_ATTRIBUTE_CONST.) */ /* Applies to: functions. */ =2D#if _GL_HAS_ATTRIBUTE (pure) =2D# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) =2D#else =2D# define _GL_ATTRIBUTE_PURE +#ifndef _GL_ATTRIBUTE_PURE +# if _GL_HAS_ATTRIBUTE (pure) +# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define _GL_ATTRIBUTE_PURE +# endif #endif =20 /* _GL_ATTRIBUTE_RETURNS_NONNULL declares that the function's return value= is a non-NULL pointer. */ /* Applies to: functions. */ =2D#if _GL_HAS_ATTRIBUTE (returns_nonnull) =2D# define _GL_ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull= __)) =2D#else =2D# define _GL_ATTRIBUTE_RETURNS_NONNULL +#ifndef _GL_ATTRIBUTE_RETURNS_NONNULL +# if _GL_HAS_ATTRIBUTE (returns_nonnull) +# define _GL_ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull_= _)) +# else +# define _GL_ATTRIBUTE_RETURNS_NONNULL +# endif #endif =20 /* _GL_ATTRIBUTE_SENTINEL(pos) declares that the variadic function expects= a @@ -434,17 +480,21 @@ AC_DEFUN([gl_COMMON_BODY], [ _GL_ATTRIBUTE_SENTINEL () - The last argument is NULL (requires C99). _GL_ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NUL= L. */ /* Applies to: functions. */ =2D#if _GL_HAS_ATTRIBUTE (sentinel) =2D# define _GL_ATTRIBUTE_SENTINEL(pos) __attribute__ ((__sentinel__ pos)) =2D#else =2D# define _GL_ATTRIBUTE_SENTINEL(pos) +#ifndef _GL_ATTRIBUTE_SENTINEL +# if _GL_HAS_ATTRIBUTE (sentinel) +# define _GL_ATTRIBUTE_SENTINEL(pos) __attribute__ ((__sentinel__ pos)) +# else +# define _GL_ATTRIBUTE_SENTINEL(pos) +# endif #endif =20 /* A helper macro. Don't use it directly. */ =2D#if _GL_HAS_ATTRIBUTE (unused) =2D# define _GL_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) =2D#else =2D# define _GL_ATTRIBUTE_UNUSED +#ifndef _GL_ATTRIBUTE_UNUSED +# if _GL_HAS_ATTRIBUTE (unused) +# define _GL_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +# else +# define _GL_ATTRIBUTE_UNUSED +# endif #endif =20 ]dnl There is no _GL_ATTRIBUTE_VISIBILITY; see m4/visibility.m4 instead. @@ -455,10 +505,12 @@ AC_DEFUN([gl_COMMON_BODY], [ /* Applies to: label (both in C and C++). */ /* Note that g++ < 4.5 does not support the '__attribute__ ((__unused__)) = ;' syntax. But clang does. */ =2D#if !(defined __cplusplus && !_GL_GNUC_PREREQ (4, 5)) || defined __clang= __ =2D# define _GL_UNUSED_LABEL _GL_ATTRIBUTE_UNUSED =2D#else =2D# define _GL_UNUSED_LABEL +#ifndef _GL_UNUSED_LABEL +# if !(defined __cplusplus && !_GL_GNUC_PREREQ (4, 5)) || defined __clang__ +# define _GL_UNUSED_LABEL _GL_ATTRIBUTE_UNUSED +# else +# define _GL_UNUSED_LABEL +# endif #endif ]) AH_VERBATIM([async_safe],