On 7/7/21 4:23 AM, Matthias Kretz wrote:
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?

aliases can also appear at block scope, unlike namespace definitions, but you could factor out some of the alias handling to call from both places.

Or can/should cp_parser_declaration look ahead behind the
attribute(s)? How?

cp_parser_skip_attributes_opt

Jason

Reply via email to