From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 13B6B3858D33; Thu, 16 Feb 2023 22:34:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 13B6B3858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676586878; bh=oPxcldsALl2Vjv4B5qYwcemAsQCjU5dY8fqb4v8U0TM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mQ8fADAN+5q7/Bk4plTe8sjrW9kuqe0/N2Ay1iHQLFateNn2zclojjImGMLHXT9Yw KStKEEXO5MDYv23g//OaxzV9W+6noI+fFaTLVlcluT5fe0hp88KUNMGPLdujHoi1yq BCAPymfvISYDKURjsuYcJoelEF1sfAwDLTFXt/kk= From: "aaron at aaronballman dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/108796] Can't intermix C2x and GNU style attributes Date: Thu, 16 Feb 2023 22:34:37 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: aaron at aaronballman dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108796 --- Comment #10 from Aaron Ballman --- One other reason for the Clang behavior that may be worth mentioning is that this helps users who wish to migrate away from `__attribute__` and towards `[[]]`. Many (most?) uses of attributes end up behind a macro, so the user = may not even be aware which syntax is being used. Consider this contrived examp= le: ``` // LibraryHeader.h #if SOMETHING #define FOO_ATTR __attribute__((foo)) #define BAR_ATTR __attribute__((bar)) #define BAZ_ATTR [[lib::baz]] #elif SOMETHING_ELSE ... #else #define FOO_ATTR #define BAR_ATTR #define BAZ_ATTR #endif // UserCode.c FOO_ATTR BAR_ATTR void func(void) { ... } ``` The user reading UserCode.c has no idea what attribute syntax is being used, nor do they probably care all that much. Under a strict parsing model, trying to add `BAZ_ATTR` to the declaration of `func()` requires the user to be very aware of exactly what each macro expa= nds to, otherwise they might get the order wrong. With a relaxed parsing model, the user doesn't have to care. Additionally, = the library header can migrate `BAR_ATTR` to `[[gnu::bar]]` syntax without also migrating `FOO_ATTR` at the same time with less fear of breaking downstream users due to attribute ordering, so this allows for gradual migration to a newer syntax. (It's not "no fear" because `[[]]` has strict appertainment rules, so it's possible for some attributes to break user code when migrati= ng from `__attribute__` to `[[]]` due to differences in appertainment.)=