This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-19


2937. Grammar for preprocessing-file has no normative effect

Section: 5.2  [lex.phases]     Status: DR     Submitter: Brian Bi     Date: 2024-09-27

[Accepted as a DR at the November, 2024 meeting.]

(From submission #615.)

Subclause 15.1 [cpp.pre] defines the grammar production preprocessing-file, but nothing in the standard specifies that a translation unit is ill-formed if it fails to match that grammar. Similarly, translation-unit has no effect.

Proposed resolution (approved by CWG 2024-11-08):

  1. Change in 5.2 [lex.phases] bullet 1.4 as follows:

    • ...
    • The source file is analyzed as a preprocessing-file (15.1 [cpp.pre]). Preprocessing directives are executed, macro invocations are expanded, and _Pragma unary operator expressions are executed. A #include preprocessing directive causes the named header or source file to be processed from phase 1 through phase 4, recursively. All preprocessing directives are then deleted.
    • ...
  2. Change in 5.2 [lex.phases] bullet 1.7 as follows:

    Whitespace characters separating tokens are no longer significant. Each preprocessing token is converted into a token (5.10 [lex.token]). The resulting tokens constitute a translation unit and are syntactically and semantically analyzed as a translation-unit (6.6 [basic.link]) and translated.