Skip to content

Commit 06614c2

Browse files
authored
Merge 2025-06 CWG Motion 11
P2843R3 Preprocessing is never undefined
2 parents 8331083 + d9555c6 commit 06614c2

File tree

3 files changed

+30
-28
lines changed

3 files changed

+30
-28
lines changed

source/lex.tex

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,7 @@
521521
characters \tcode{*/}. These comments do not nest.
522522
\indextext{comment!\tcode{//}}%
523523
The characters \tcode{//} start a comment, which terminates immediately before the
524-
next new-line character. If there is a form-feed or a vertical-tab
525-
character in such a comment, only whitespace characters shall appear
526-
between it and the new-line that terminates the comment; no diagnostic
527-
is required.
524+
next new-line character.
528525
\begin{note}
529526
The comment characters \tcode{//}, \tcode{/*},
530527
and \tcode{*/} have no special meaning within a \tcode{//} comment and

source/lib-intro.tex

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3296,16 +3296,6 @@
32963296
\tcode{\#define} or \tcode{\#undef} names declared in any standard
32973297
library header.
32983298

3299-
\pnum
3300-
\indextext{unit!translation}%
3301-
A translation unit shall not \tcode{\#define} or \tcode{\#undef}
3302-
names lexically identical
3303-
to keywords,
3304-
to the identifiers listed in \tref{lex.name.special}, or
3305-
to the \grammarterm{attribute-token}{s} described in~\ref{dcl.attr},
3306-
except that the names \tcode{likely} and \tcode{unlikely} may be
3307-
defined as function-like macros~\iref{cpp.replace}.
3308-
33093299
\rSec4[extern.names]{External linkage}
33103300

33113301
\pnum

source/preprocessor.tex

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@
543543
\tcode{defined}
544544
unary operator does not match one of the two specified forms
545545
prior to macro replacement,
546-
the behavior is undefined.
546+
the program is ill-formed, no diagnostic required.
547547

548548
\pnum
549549
After all replacements due to macro expansion and
@@ -764,7 +764,7 @@
764764
is \impldef{treatment of whitespace when processing a \tcode{\#include} directive}.
765765
If the attempt succeeds, the directive with the so-formed \grammarterm{header-name}
766766
is processed as specified for the previous form.
767-
Otherwise, the behavior is undefined.
767+
Otherwise, the program is ill-formed, no diagnostic required.
768768
\begin{note}
769769
Adjacent \grammarterm{string-literal}s are not concatenated into
770770
a single \grammarterm{string-literal}
@@ -1529,6 +1529,16 @@
15291529
replacement list of preprocessing tokens are not considered
15301530
part of the replacement list for either form of macro.
15311531

1532+
\pnum
1533+
\indextext{unit!translation}%
1534+
A translation unit shall not \tcode{\#define} or \tcode{\#undef}
1535+
names lexically identical
1536+
to keywords,
1537+
to the identifiers listed in \tref{lex.name.special}, or
1538+
to the \grammarterm{attribute-token}{s} described in~\ref{dcl.attr},
1539+
except that the names \tcode{likely} and \tcode{unlikely} may be
1540+
defined as function-like macros.
1541+
15321542
\pnum
15331543
If a
15341544
\indextext{\#\#0 operator@\tcode{\#} operator}
@@ -1618,7 +1628,7 @@
16181628
\begin{footnote}
16191629
A \grammarterm{conditionally-supported-directive} is a preprocessing directive regardless of whether the implementation supports it.
16201630
\end{footnote}
1621-
the behavior is undefined.
1631+
the program is ill-formed.
16221632

16231633
\pnum
16241634
\begin{example}
@@ -1813,16 +1823,21 @@
18131823
stringizing argument is retained in the character string literal,
18141824
except for special handling for producing the spelling of
18151825
\grammarterm{header-name}s,
1816-
\grammarterm{string-literal}s,
1817-
and \grammarterm{character-literal}s:
1818-
a \tcode{\textbackslash} character is inserted before each
1819-
\tcode{"} and \tcode{\textbackslash} character of a
1826+
\grammarterm{character-literal}s,
1827+
and \grammarterm{string-literal}s
1828+
(including the delimiting \unicode{0022}{quotation mark} (\tcode{"}))
1829+
contained within the preprocessing token:
1830+
a \unicode{005c}{reverse solidus} character (\tcode{\textbackslash})
1831+
is inserted before each \unicode{0022}{quotation mark} and
1832+
\unicode{005c}{reverse solidus} character of a
18201833
\grammarterm{header-name},
18211834
\grammarterm{character-literal},
1822-
or \grammarterm{string-literal}
1823-
(including the delimiting \tcode{"} characters).
1835+
or \grammarterm{string-literal},
1836+
and each new-line character is
1837+
replaced by the two-character sequence \tcode{\textbackslash n}.
18241838
If the replacement that results is not a valid character string literal,
1825-
the behavior is undefined. The character string literal corresponding to
1839+
the program is ill-formed.
1840+
The character string literal corresponding to
18261841
an empty stringizing argument is \tcode{""}.
18271842
The order of evaluation of
18281843
\tcode{\#}
@@ -1871,7 +1886,7 @@
18711886
a \grammarterm{universal-character-name}\iref{lex.charset}.
18721887
\end{note}
18731888
If the result is not a valid preprocessing token,
1874-
the behavior is undefined.
1889+
the program is ill-formed.
18751890
The resulting preprocessing token is available for further macro replacement.
18761891
The order of evaluation of
18771892
\tcode{\#\#}
@@ -2082,7 +2097,7 @@
20822097
by the digit sequence (interpreted as a decimal integer).
20832098
If the digit sequence specifies zero
20842099
or a number greater than 2147483647,
2085-
the behavior is undefined.
2100+
the program is ill-formed.
20862101

20872102
\pnum
20882103
A preprocessing directive of the form
@@ -2106,7 +2121,7 @@
21062121
(each identifier currently defined as a macro name is replaced by its
21072122
replacement list of preprocessing tokens).
21082123
If the directive resulting after all replacements does not match
2109-
one of the two previous forms, the behavior is undefined;
2124+
one of the two previous forms, the program is ill-formed;
21102125
otherwise, the result is processed as appropriate.
21112126

21122127
\rSec1[cpp.error]{Diagnostic directives}%
@@ -2450,7 +2465,7 @@
24502465
or a
24512466
\tcode{\#undef}
24522467
preprocessing directive,
2453-
the behavior is undefined.
2468+
the program is ill-formed.
24542469
Any other predefined macro names shall begin with a
24552470
leading underscore followed by an uppercase letter or a second
24562471
underscore.

0 commit comments

Comments
 (0)