Skip to content

Commit 8d7e199

Browse files
jensmaurertkoeppe
authored andcommitted
P2361R6 Unevaluated strings
1 parent d6a2b55 commit 8d7e199

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");
@@ -8169,11 +8169,12 @@
81698169
An \tcode{asm} declaration has the form
81708170
\begin{bnf}
81718171
\nontermdef{asm-declaration}\br
8172-
\opt{attribute-specifier-seq} \keyword{asm} \terminal{(} string-literal \terminal{)} \terminal{;}
8172+
\opt{attribute-specifier-seq} \keyword{asm} \terminal{(} balanced-token-seq \terminal{)} \terminal{;}
81738173
\end{bnf}
81748174

8175-
The \tcode{asm} declaration is conditionally-supported; its meaning is
8176-
\impldef{meaning of \tcode{asm} declaration}.
8175+
The \tcode{asm} declaration is conditionally-supported;
8176+
any restrictions on the \grammarterm{balanced-token-seq} and
8177+
its meaning are \impldef{meaning of \tcode{asm} declaration}.
81778178
The optional \grammarterm{attribute-specifier-seq} in
81788179
an \grammarterm{asm-declaration} appertains to the \tcode{asm} declaration.
81798180
\begin{note}
@@ -8209,25 +8210,30 @@
82098210
%
82108211
\begin{bnf}
82118212
\nontermdef{linkage-specification}\br
8212-
\keyword{extern} string-literal \terminal{\{} \opt{declaration-seq} \terminal{\}}\br
8213-
\keyword{extern} string-literal name-declaration
8213+
\keyword{extern} unevaluated-string \terminal{\{} \opt{declaration-seq} \terminal{\}}\br
8214+
\keyword{extern} unevaluated-string name-declaration
82148215
\end{bnf}
82158216

8216-
The \grammarterm{string-literal} indicates the required language linkage.
8217+
The \grammarterm{unevaluated-string} indicates the required language linkage.
8218+
\begin{note}
8219+
Escape sequences and \grammarterm{universal-character-name}s
8220+
have been replaced\iref{lex.string.uneval}.
8221+
\end{note}
82178222
This document specifies the semantics for the
8218-
\grammarterm{string-literal}{s} \tcode{"C"} and \tcode{"C++"}. Use of a
8219-
\grammarterm{string-literal} other than \tcode{"C"} or \tcode{"C++"} is
8220-
conditionally-supported, with \impldef{semantics of linkage specifiers} semantics.
8223+
\grammarterm{unevaluated-string}{s} \tcode{"C"} and \tcode{"C++"}.
8224+
Use of an \grammarterm{unevaluated-string}
8225+
other than \tcode{"C"} or \tcode{"C++"} is conditionally-supported,
8226+
with \impldef{semantics of linkage specifiers} semantics.
82218227
\begin{note}
8222-
Therefore, a linkage-specification with a \grammarterm{string-literal} that
8223-
is unknown to the implementation requires a diagnostic.
8228+
Therefore, a \grammarterm{linkage-specification} with a language linkage
8229+
that is unknown to the implementation requires a diagnostic.
82248230
\end{note}
82258231

82268232
\recommended
8227-
The spelling of the \grammarterm{string-literal} should be
8228-
taken from the document defining that language. For example, \tcode{Ada}
8229-
(not \tcode{ADA}) and \tcode{Fortran} or \tcode{FORTRAN}, depending on
8230-
the vintage.
8233+
The spelling of the language linkage should be taken
8234+
from the document defining that language.
8235+
For example, \tcode{Ada} (not \tcode{ADA}) and
8236+
\tcode{Fortran} or \tcode{FORTRAN}, depending on the vintage.
82318237

82328238
\pnum
82338239
\indextext{specification!linkage!implementation-defined}%
@@ -8830,10 +8836,10 @@
88308836
An
88318837
\grammarterm{attribute-argument-clause} may be present and, if present, it shall have the form:
88328838
\begin{ncbnf}
8833-
\terminal{(} string-literal \terminal{)}
8839+
\terminal{(} unevaluated-string \terminal{)}
88348840
\end{ncbnf}
88358841
\begin{note}
8836-
The \grammarterm{string-literal} in the \grammarterm{attribute-argument-clause}
8842+
The \grammarterm{unevaluated-string} in the \grammarterm{attribute-argument-clause}
88378843
can be used to explain the rationale for deprecation and/or to suggest a replacing entity.
88388844
\end{note}
88398845

@@ -9044,7 +9050,7 @@
90449050
and, if present, shall have the form:
90459051

90469052
\begin{ncbnf}
9047-
\terminal{(} string-literal \terminal{)}
9053+
\terminal{(} unevaluated-string \terminal{)}
90489054
\end{ncbnf}
90499055

90509056
\pnum
@@ -9091,7 +9097,7 @@
90919097
This is typically because discarding the return value
90929098
of a nodiscard call has surprising consequences.
90939099
\end{note}
9094-
The \grammarterm{string-literal}
9100+
The \grammarterm{unevaluated-string}
90959101
in a \tcode{nodiscard} \grammarterm{attribute-argument-clause}
90969102
should be used in the message of the warning
90979103
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
@@ -2033,6 +2033,28 @@
20332033
what effect these sequences have on encoding state.
20342034
\end{itemize}
20352035

2036+
\rSec2[lex.string.uneval]{Unevaluated strings}
2037+
2038+
\begin{bnf}
2039+
\nontermdef{unevaluated-string}\br
2040+
string-literal
2041+
\end{bnf}
2042+
2043+
\pnum
2044+
An \grammarterm{unevaluated-string} shall have no \grammarterm{encoding-prefix}.
2045+
2046+
\pnum
2047+
Each \grammarterm{universal-character-name} and each \grammarterm{simple-escape-sequence} in an \grammarterm{unevaluated-string} is
2048+
replaced by the member of the translation character set it denotes.
2049+
An \grammarterm{unevaluated-string} that contains
2050+
a \grammarterm{numeric-escape-sequence} or
2051+
a \grammarterm{conditional-escape-sequence}
2052+
is ill-formed.
2053+
2054+
\pnum
2055+
An \grammarterm{unevaluated-string} is never evaluated and
2056+
its interpretation depends on the context in which it appears.
2057+
20362058
\rSec2[lex.bool]{Boolean literals}
20372059

20382060
\indextext{literal!boolean}%

source/overloading.tex

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

39373937
\begin{bnf}
39383938
\nontermdef{literal-operator-id}\br
3939-
\keyword{operator} string-literal identifier\br
3939+
\keyword{operator} unevaluated-string identifier\br
39403940
\keyword{operator} user-defined-string-literal
39413941
\end{bnf}
39423942

39433943
\pnum
3944-
The \grammarterm{string-literal} or \grammarterm{user-defined-string-literal}
3945-
in a \grammarterm{literal-operator-id} shall have no
3946-
\grammarterm{encoding-prefix} and shall contain no characters other than the
3947-
implicit terminating \tcode{'\textbackslash 0'}.
3944+
The \grammarterm{user-defined-string-literal}
3945+
in a \grammarterm{literal-operator-id}
3946+
shall have no \grammarterm{encoding-prefix}.
3947+
The \grammarterm{unevaluated-string} or
3948+
\grammarterm{user-defined-string-literal} shall be empty.
39483949
The \grammarterm{ud-suffix} of the \grammarterm{user-defined-string-literal} or
39493950
the \grammarterm{identifier} in a \grammarterm{literal-operator-id} is called a
39503951
\defnx{literal suffix identifier}{literal!suffix identifier}.

0 commit comments

Comments
 (0)