Title
Alternative tokens appearing as attribute-tokens
Status
review
Section
5.5 [lex.digraph]
Submitter
Jim X

Created on 2023-03-16.00:00:00 last changed 10 months ago

Messages

Date: 2023-06-16.17:02:47

CWG 2023-06-16

Forwarded to EWG with paper issue #1581.

Date: 2023-05-15.00:00:00

Additional notes (May, 2023)

During additional discussion on the EWG reflector, Alisdair Meredith expressed that he intends to propose that some alternative tokens be treated as full keywords in phase 7, to prevent and from being used as an rvalue reference and compl from being used for naming destructors. That would reverse the above direction.

Furthermore, an idea was floated to treat all alternative tokens as full keywords in phase 7 and as identifiers in phase 4, amending the grammar productions for expressions as necessary. This removes the special treatment of alternative tokens entirely, however the treatment of examples such as #define and blah would change from ill-formed to well-formed. Some opposition was voiced against changing the phase 4 treatment of alternative tokens.

Date: 2023-05-12.20:59:33

Proposed resolution (approved by CWG 2023-05-12):

  1. Change in 5.2 [lex.phases] paragraph 2 as follows:

    Whitespace characters separating tokens are no longer significant. Each preprocessing token is converted into a token (5.6 [lex.token]), replacing each alternative token by its corresponding primary token (5.5 [lex.digraph]). The resulting tokens constitute a translation unit and are syntactically and semantically analyzed and translated.
  2. Change in 9.12.1 [dcl.attr.grammar] paragraph 4 as follows:

    ... If a keyword (5.11 [lex.key]) or an alternative token (5.5 [lex.digraph]) that satisfies the syntactic requirements of an identifier (5.10 [lex.name]) is contained in an attribute-token, it is considered an identifier. ...

This resolution also addresses issue 1897.

Date: 2023-05-12.20:59:33

Subclause 5.5 [lex.digraph] paragraph 2 specifies:

In all respects of the language, each alternative token behaves the same, respectively, as its primary token, except for its spelling. [ Footnote: ... ]

However, 9.12.1 [dcl.attr.grammar] paragraph 4 specifies:

... If a keyword (5.11 [lex.key]) or an alternative token (5.5 [lex.digraph]) that satisfies the syntactic requirements of an identifier (5.10 [lex.name]) is contained in an attribute-token, it is considered an identifier. ...

It seems an alternative token (say, or) is treated the same as the operator ||, yet only the alternative token is considered an identifier, not the operator, when appearing in an attribute-token. That seems contradictory.

History
Date User Action Args
2023-06-16 17:02:47adminsetmessages: + msg7328
2023-05-24 18:54:04adminsetmessages: + msg7288
2023-05-24 18:54:04adminsetstatus: ready -> review
2023-05-12 20:59:33adminsetmessages: + msg7281
2023-05-12 20:59:33adminsetstatus: open -> ready
2023-03-16 00:00:00admincreate