Richard Biener <richard.guent...@gmail.com> writes: >> Am 17.08.2023 um 13:25 schrieb Richard Sandiford via Gcc-patches >> <gcc-patches@gcc.gnu.org>: >> >> Joseph Myers <jos...@codesourcery.com> writes: >>>> On Wed, 16 Aug 2023, Richard Sandiford via Gcc-patches wrote: >>>> >>>> Would it be OK to add support for: >>>> >>>> [[__extension__ ...]] >>>> >>>> to suppress the pedwarn about using [[]] prior to C2X? Then we can >>> >>> That seems like a plausible feature to add. >> >> 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: >> >> [[__extension__ arm::streaming]] >> >> 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... >> >> I wondered about trying to require the two colons to be immediately >> adjacent. But: >> >> (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_between. > > 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 == 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