1. Changelog
-
R1 - Change wording to not use a group, and be compatible with Alisdair’s editorial change to the line directive wording.
2. The Problem
After implementing part of [P1857R3], Clang soon discovered that it makes the following code ill-formed:
#line 1 "A.cppm" export module a ;
This is a problem because tools such as build2, ccache,
and distcc, among many others, rely on feeding the preprocessed output back into the
compiler. This output generally contains (or GNU line marker) directives at the start of the file.
3. The Fix
The standard should allow directives to appear on any line.
4. Wording
Modify [cpp.pre]:
module-file: line-directivesopt pp-global-module-fragmentopt pp-module groupopt pp-private-module-fragmentopt
control-line: pp-tokens new-line# include pp-import line-directive
pp-tokens new-line# embed identifier replacement-list new-line# define identifier lparen identifier-listopt# define replacement-list new-line) identifier lparen# define ... replacement-list new-line) identifier lparen identifier-list# define , ... replacement-list new-line) identifier new-line# undef pp-tokens new-line# line
pp-tokensopt new-line# error pp-tokensopt new-line# warning pp-tokensopt new-line# pragma new-line# line-directives: line-directive line-directivesopt
Add before the first paragraph in [cpp.line]:
line-directive: pp-tokens new-line# line