On Tuesday, 22 June 2021 21:52:16 CEST Jason Merrill wrote:
> > 2. About the namespace aliases: IIUC an attribute would currently be
> > rejected because of the C++ grammar. Do you want to make it valid before
> > WG21 officially decides how to proceed? And if you have a pointer for me
> > where I'd have to adjust the grammar rules, that'd help. 
> 
> You will want to adjust cp_parser_namespace_alias_definition to handle
> attributes like cp_parser_namespace_definition.  The latter currently
> accepts attributes both before and after the name, which seems like a
> good pattern to follow so it doesn't matter which WG21 chooses.
> Probably best to pedwarn about C++11 attributes in both locations for
> now, not just after.

This introduces an ambiguity in cp_parser_declaration. The function has to 
decide whether to call cp_parser_namespace_definition or fall back to 
cp_parser_block_declaration (which calls 
cp_parser_namespace_alias_definition). But now the parser has to look ahead a 
lot farther:

namespace foo [[whatever]] {}
namespace bar [[whatever]] = foo;

I.e. only at '{' vs. '=' can cp_parser_declaration decide to call 
cp_parser_namespace_definition.

Consequently, should I really modify cp_parser_namespace_definition to handle 
namespace aliases? Or can/should cp_parser_declaration look ahead behind the 
attribute(s)? How?
With pedantic standard C++ it would be easy, since only these attribute 
placements are allowed:

namespace [[whatever] foo {}
namespace bar [[whatever]] = foo;

-- 
──────────────────────────────────────────────────────────────────────────
 Dr. Matthias Kretz                           https://mattkretz.github.io
 GSI Helmholtz Centre for Heavy Ion Research               https://gsi.de
 std::experimental::simd              https://github.com/VcDevel/std-simd
──────────────────────────────────────────────────────────────────────────

Reply via email to