From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id B633C3858D35 for ; Thu, 17 Aug 2023 18:36:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B633C3858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 43B4BD75; Thu, 17 Aug 2023 11:36:44 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C38DA3F64C; Thu, 17 Aug 2023 11:36:02 -0700 (PDT) From: Richard Sandiford To: Richard Biener Mail-Followup-To: Richard Biener ,Joseph Myers , gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Cc: Joseph Myers , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] c: Add support for [[__extension__ ...]] References: Date: Thu, 17 Aug 2023 19:36:01 +0100 In-Reply-To: (Richard Biener's message of "Thu, 17 Aug 2023 19:07:28 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-19.6 required=5.0 tests=BAYES_00,KAM_DMARC_NONE,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Richard Biener writes: >> Am 17.08.2023 um 13:25 schrieb Richard Sandiford via Gcc-patches : >>=20 >> =EF=BB=BFJoseph Myers writes: >>>> On Wed, 16 Aug 2023, Richard Sandiford via Gcc-patches wrote: >>>>=20 >>>> Would it be OK to add support for: >>>>=20 >>>> [[__extension__ ...]] >>>>=20 >>>> to suppress the pedwarn about using [[]] prior to C2X? Then we can >>>=20 >>> That seems like a plausible feature to add. >>=20 >> Thanks. Of course, once I actually tried it, I hit a snag: >> :: isn't a single lexing token prior to C2X, and so something like: >>=20 >> [[__extension__ arm::streaming]] >>=20 >> would not be interpreted as a scoped attribute in C11. The patch >> gets around that by allowing two colons in place of :: when >> __extension__ is used. I realise that's pushing the bounds of >> acceptability though... >>=20 >> I wondered about trying to require the two colons to be immediately >> adjacent. But: >>=20 >> (a) There didn't appear to be an existing API to check that, which seemed >> like a red flag. The closest I could find was get_source_text_betwee= n. > > IStR a cop Toben has ->prev_white or so Ah, thanks. if (c_parser_next_token_is (parser, CPP_SCOPE) || (loose_scope_p && c_parser_next_token_is (parser, CPP_COLON) && c_parser_peek_2nd_token (parser)->type =3D=3D CPP_COLON && !(c_parser_peek_2nd_token (parser)->flags & PREV_WHITE))) seems to work for (i.e. reject): typedef int [[__extension__ gnu : : vector_size (4)]] g3; typedef int [[__extension__ gnu :/**/: vector_size (4)]] g13; but not: #define BAR : typedef int [[__extension__ gnu BAR BAR vector_size (4)]] g5; #define JOIN(A, B) A/**/B typedef int [[__extension__ gnu JOIN(:,:) vector_size (4)]] g14; I now realise the patch was peeking at the wrong token. Will fix, and add more tests. Richard