Skip to content

Commit a831780

Browse files
committed
P2361R6 Unevaluated strings
1 parent c0685a5 commit a831780

File tree

3 files changed

+55
-26
lines changed

3 files changed

+55
-26
lines changed

source/declarations.tex

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
\begin{bnf}
7878
\nontermdef{static_assert-declaration}\br
7979
\keyword{static_assert} \terminal{(} constant-expression \terminal{)} \terminal{;}\br
80-
\keyword{static_assert} \terminal{(} constant-expression \terminal{,} string-literal \terminal{)} \terminal{;}
80+
\keyword{static_assert} \terminal{(} constant-expression \terminal{,} unevaluated-string \terminal{)} \terminal{;}
8181
\end{bnf}
8282

8383
\begin{bnf}
@@ -264,7 +264,7 @@
264264
the \grammarterm{static_assert-declaration} \defnx{fails}{\idxcode{static_assert}!failed},
265265
the program is ill-formed, and the resulting
266266
diagnostic message\iref{intro.compliance} should include the text of
267-
the \grammarterm{string-literal}, if one is supplied.
267+
the \grammarterm{unevaluated-string}, if one is supplied.
268268
\begin{example}
269269
\begin{codeblock}
270270
static_assert(sizeof(int) == sizeof(void*), "wrong pointer size");
@@ -8145,11 +8145,12 @@
81458145
An \tcode{asm} declaration has the form
81468146
\begin{bnf}
81478147
\nontermdef{asm-declaration}\br
8148-
\opt{attribute-specifier-seq} \keyword{asm} \terminal{(} string-literal \terminal{)} \terminal{;}
8148+
\opt{attribute-specifier-seq} \keyword{asm} \terminal{(} balanced-token-seq \terminal{)} \terminal{;}
81498149
\end{bnf}
81508150

8151-
The \tcode{asm} declaration is conditionally-supported; its meaning is
8152-
\impldef{meaning of \tcode{asm} declaration}.
8151+
The \tcode{asm} declaration is conditionally-supported;
8152+
any restrictions on the \grammarterm{balanced-token-seq} and
8153+
its meaning is \impldef{meaning of \tcode{asm} declaration}.
81538154
The optional \grammarterm{attribute-specifier-seq} in
81548155
an \grammarterm{asm-declaration} appertains to the \tcode{asm} declaration.
81558156
\begin{note}
@@ -8185,25 +8186,30 @@
81858186
%
81868187
\begin{bnf}
81878188
\nontermdef{linkage-specification}\br
8188-
\keyword{extern} string-literal \terminal{\{} \opt{declaration-seq} \terminal{\}}\br
8189-
\keyword{extern} string-literal name-declaration
8189+
\keyword{extern} unevaluated-string \terminal{\{} \opt{declaration-seq} \terminal{\}}\br
8190+
\keyword{extern} unevaluated-string name-declaration
81908191
\end{bnf}
81918192

8192-
The \grammarterm{string-literal} indicates the required language linkage.
8193+
The \grammarterm{unevaluated-string} indicates the required language linkage.
8194+
\begin{note}
8195+
Escape sequences and \grammarterm{universal-character-name}s
8196+
have been replaced\iref{lex.string.uneval}.
8197+
\end{note}
81938198
This document specifies the semantics for the
8194-
\grammarterm{string-literal}{s} \tcode{"C"} and \tcode{"C++"}. Use of a
8195-
\grammarterm{string-literal} other than \tcode{"C"} or \tcode{"C++"} is
8196-
conditionally-supported, with \impldef{semantics of linkage specifiers} semantics.
8199+
\grammarterm{unevaluated-string}{s} \tcode{"C"} and \tcode{"C++"}.
8200+
Use of an \grammarterm{unevaluated-string}
8201+
other than \tcode{"C"} or \tcode{"C++"} is conditionally-supported,
8202+
with \impldef{semantics of linkage specifiers} semantics.
81978203
\begin{note}
8198-
Therefore, a linkage-specification with a \grammarterm{string-literal} that
8199-
is unknown to the implementation requires a diagnostic.
8204+
Therefore, a \grammarterm{linkage-specification} with a language linkage
8205+
that is unknown to the implementation requires a diagnostic.
82008206
\end{note}
82018207

82028208
\recommended
8203-
The spelling of the \grammarterm{string-literal} should be
8204-
taken from the document defining that language. For example, \tcode{Ada}
8205-
(not \tcode{ADA}) and \tcode{Fortran} or \tcode{FORTRAN}, depending on
8206-
the vintage.
8209+
The spelling of the language linkage should be taken
8210+
from the document defining that language.
8211+
For example, \tcode{Ada} (not \tcode{ADA}) and
8212+
\tcode{Fortran} or \tcode{FORTRAN}, depending on the vintage.
82078213

82088214
\pnum
82098215
\indextext{specification!linkage!implementation-defined}%
@@ -8806,10 +8812,10 @@
88068812
An
88078813
\grammarterm{attribute-argument-clause} may be present and, if present, it shall have the form:
88088814
\begin{ncbnf}
8809-
\terminal{(} string-literal \terminal{)}
8815+
\terminal{(} unevaluated-string \terminal{)}
88108816
\end{ncbnf}
88118817
\begin{note}
8812-
The \grammarterm{string-literal} in the \grammarterm{attribute-argument-clause}
8818+
The \grammarterm{unevaluated-string} in the \grammarterm{attribute-argument-clause}
88138819
can be used to explain the rationale for deprecation and/or to suggest a replacing entity.
88148820
\end{note}
88158821

@@ -9020,7 +9026,7 @@
90209026
and, if present, shall have the form:
90219027

90229028
\begin{ncbnf}
9023-
\terminal{(} string-literal \terminal{)}
9029+
\terminal{(} unevaluated-string \terminal{)}
90249030
\end{ncbnf}
90259031

90269032
\pnum
@@ -9067,7 +9073,7 @@
90679073
This is typically because discarding the return value
90689074
of a nodiscard call has surprising consequences.
90699075
\end{note}
9070-
The \grammarterm{string-literal}
9076+
The \grammarterm{unevaluated-string}
90719077
in a \tcode{nodiscard} \grammarterm{attribute-argument-clause}
90729078
should be used in the message of the warning
90739079
as the rationale for why the result should not be discarded.

source/lex.tex

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,6 +2058,28 @@
20582058
what effect these sequences have on encoding state.
20592059
\end{itemize}
20602060

2061+
\rSec2[lex.string.uneval]{Unevaluated strings}
2062+
2063+
\begin{bnf}
2064+
\nontermdef{unevaluated-string}\br
2065+
string-literal
2066+
\end{bnf}
2067+
2068+
\pnum
2069+
An \grammarterm{unevaluated-string} shall have no \grammarterm{encoding-prefix}.
2070+
2071+
\pnum
2072+
Each \grammarterm{universal-character-name} and each \grammarterm{simple-escape-sequence} in an \grammarterm{unevaluated-string} is
2073+
replaced by the member of the translation character set it denotes.
2074+
An \grammarterm{unevaluated-string} that contains
2075+
a \grammarterm{numeric-escape-sequence} or
2076+
a \grammarterm{conditional-escape-sequence}
2077+
is ill-formed.
2078+
2079+
\pnum
2080+
An \grammarterm{unevaluated-string} is never evaluated and
2081+
its interpretation depends on the context in which it appears.
2082+
20612083
\rSec2[lex.bool]{Boolean literals}
20622084

20632085
\indextext{literal!boolean}%

source/overloading.tex

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3942,15 +3942,16 @@
39423942

39433943
\begin{bnf}
39443944
\nontermdef{literal-operator-id}\br
3945-
\keyword{operator} string-literal identifier\br
3945+
\keyword{operator} unevaluated-string identifier\br
39463946
\keyword{operator} user-defined-string-literal
39473947
\end{bnf}
39483948

39493949
\pnum
3950-
The \grammarterm{string-literal} or \grammarterm{user-defined-string-literal}
3951-
in a \grammarterm{literal-operator-id} shall have no
3952-
\grammarterm{encoding-prefix} and shall contain no characters other than the
3953-
implicit terminating \tcode{'\textbackslash 0'}.
3950+
The \grammarterm{user-defined-string-literal}
3951+
in a \grammarterm{literal-operator-id}
3952+
shall have no \grammarterm{encoding-prefix}.
3953+
The \grammarterm{unevaluated-string} or
3954+
\grammarterm{user-defined-string-literal} shall be empty.
39543955
The \grammarterm{ud-suffix} of the \grammarterm{user-defined-string-literal} or
39553956
the \grammarterm{identifier} in a \grammarterm{literal-operator-id} is called a
39563957
\defnx{literal suffix identifier}{literal!suffix identifier}.

0 commit comments

Comments
 (0)