Skip to content

import-keyword, module-keyword, and export-keyword are not preprocessing tokens #5301

@xmh0511

Description

@xmh0511

According to clause [lex.phases], phase 3 occurs previous to phase 4, In other words, the determination of preprocessing tokens occurs before the execution of preprocessing directives.

phase 3:

The source file is decomposed into preprocessing tokens ([lex.pptoken]) and sequences of whitespace characters (including comments).

phase 4:

Preprocessing directives are executed, macro invocations are expanded, and _­Pragma unary operator expressions are executed.

That is, the replacement of preprocessing tokens import to import-keyword, module to module-keyword, and export to export-keyword all occur within the duration of execution of preprocessing directives. As specified in [cpp.module], and [cpp.import], they are:

The module and export (if it exists) preprocessing tokens are replaced by the module-keyword and export-keyword preprocessing tokens respectively.

In all three forms of pp-import, the import and export (if it exists) preprocessing tokens are replaced by the import-keyword and export-keyword preprocessing tokens respectively.

The emphasized parts also confirm this point. We should admit that: import, module, and export are preprocessing tokens in phase 3. They also remain to be preprocessing tokens until the execution of the relevant preprocessing directives in phase 4. After these phases, these replaced x-keywords will be used as keywords in the subsequent phases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions