On Fri, 18 Aug 2023, Richard Sandiford via Gcc-patches wrote:

> [[]] attributes are a recent addition to C, but as a GNU extension,
> GCC allows them to be used in C11 and earlier.  Normally this use
> would trigger a pedwarn (for -pedantic, -Wc11-c2x-compat, etc.).
> 
> This patch allows the pedwarn to be suppressed by starting the
> attribute-list with __extension__.
> 
> Also, :: is not a single lexing token prior to C2X, so it wasn't
> possible to use scoped attributes in C11, even as a GNU extension.
> The patch allows two colons to be used in place of :: when
> __extension__ is used.  No attempt is made to check whether the
> two colons are immediately adjacent.
> 
> gcc/
>       * doc/extend.texi: Document the C [[__extension__ ...]] construct.
> 
> gcc/c/
>       * c-parser.cc (c_parser_std_attribute): Conditionally allow
>       two colons to be used in place of ::.
>       (c_parser_std_attribute_list): New function, split out from...
>       (c_parser_std_attribute_specifier): ...here.  Allow the attribute-list
>       to start with __extension__.  When it does, also allow two colons
>       to be used in place of ::.
> 
> gcc/testsuite/
>       * gcc.dg/c2x-attr-syntax-6.c: New test.
>       * gcc.dg/c2x-attr-syntax-7.c: Likewise.

OK.

-- 
Joseph S. Myers
jos...@codesourcery.com

Reply via email to