Skip to content

[cpp.pragma.op] Colocate the two pragma specifications #8100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 37 additions & 37 deletions source/preprocessor.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2161,6 +2161,43 @@
the resulting program to behave in a non-conforming manner.
Any pragma that is not recognized by the implementation is ignored.

\rSec1[cpp.pragma.op]{Pragma operator}%
\indextext{macro!pragma operator}%
\indextext{operator!pragma|see{macro, pragma operator}}

\pnum
A unary operator expression of the form:
\begin{ncbnf}
\terminal{_Pragma} \terminal{(} string-literal \terminal{)}
\end{ncbnf}
is processed as follows: The \grammarterm{string-literal} is \defnx{destringized}{destringization}
by deleting the \tcode{L} prefix, if present, deleting the leading and trailing
double-quotes, replacing each escape sequence \tcode{\textbackslash"} by a double-quote, and
replacing each escape sequence \tcode{\textbackslash\textbackslash} by a single
backslash. The resulting sequence of characters is processed through translation phase 3
to produce preprocessing tokens that are executed as if they were the
\grammarterm{pp-tokens} in a pragma directive. The original four preprocessing
tokens in the unary operator expression are removed.

\pnum
\begin{example}
\begin{codeblock}
#pragma listing on "..\listing.dir"
\end{codeblock}
can also be expressed as:
\begin{codeblock}
_Pragma ( "listing on \"..\\listing.dir\"" )
\end{codeblock}
The latter form is processed in the same way whether it appears literally
as shown, or results from macro replacement, as in:
\begin{codeblock}
#define LISTING(x) PRAGMA(listing on #x)
#define PRAGMA(x) _Pragma(#x)

LISTING( ..\listing.dir )
\end{codeblock}
\end{example}

\rSec1[cpp.null]{Null directive}%
\indextext{preprocessing directive!null}

Expand Down Expand Up @@ -2469,41 +2506,4 @@
Any other predefined macro names shall begin with a
leading underscore followed by an uppercase letter or a second
underscore.

\rSec1[cpp.pragma.op]{Pragma operator}%
\indextext{macro!pragma operator}%
\indextext{operator!pragma|see{macro, pragma operator}}

\pnum
A unary operator expression of the form:
\begin{ncbnf}
\terminal{_Pragma} \terminal{(} string-literal \terminal{)}
\end{ncbnf}
is processed as follows: The \grammarterm{string-literal} is \defnx{destringized}{destringization}
by deleting the \tcode{L} prefix, if present, deleting the leading and trailing
double-quotes, replacing each escape sequence \tcode{\textbackslash"} by a double-quote, and
replacing each escape sequence \tcode{\textbackslash\textbackslash} by a single
backslash. The resulting sequence of characters is processed through translation phase 3
to produce preprocessing tokens that are executed as if they were the
\grammarterm{pp-tokens} in a pragma directive. The original four preprocessing
tokens in the unary operator expression are removed.

\pnum
\begin{example}
\begin{codeblock}
#pragma listing on "..\listing.dir"
\end{codeblock}
can also be expressed as:
\begin{codeblock}
_Pragma ( "listing on \"..\\listing.dir\"" )
\end{codeblock}
The latter form is processed in the same way whether it appears literally
as shown, or results from macro replacement, as in:
\begin{codeblock}
#define LISTING(x) PRAGMA(listing on #x)
#define PRAGMA(x) _Pragma(#x)

LISTING( ..\listing.dir )
\end{codeblock}
\end{example}
\indextext{preprocessing directive|)}