<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 3016</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<STYLE TYPE="text/css">
  INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .INS { text-decoration:none; background-color:#D0FFD0 }
  DEL { text-decoration:line-through; background-color:#FFA0A0 }
  .DEL { text-decoration:line-through; background-color: #FFD0D0 }
  @media (prefers-color-scheme: dark) {
    HTML { background-color:#202020; color:#f0f0f0; }
    A { color:#5bc0ff; }
    A:visited { color:#c6a8ff; }
    A:hover, a:focus { color:#afd7ff; }
    INS { background-color:#033a16; color:#aff5b4; }
    .INS { background-color: #033a16; }
    DEL { background-color:#67060c; color:#ffdcd7; }
    .DEL { background-color:#67060c; }
  }
  SPAN.cmnt { font-family:Times; font-style:italic }
</STYLE>
</HEAD>
<BODY>
<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
  Core Issues List revision 118b.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-28</P>
<HR>
<A NAME="3016"></A><H4>3016.
  
Satisfying the syntactic requirements of <TT>#include</TT> and <TT>#embed</TT>
</H4>
<B>Section: </B>15.2&#160; [<A href="https://wg21.link/cpp.cond">cpp.cond</A>]
 &#160;&#160;&#160;

 <B>Status: </B>CD7
 &#160;&#160;&#160;

 <B>Submitter: </B>Hubert Tong
 &#160;&#160;&#160;

 <B>Date: </B>2025-03-24<BR>


<P>[Accepted as a DR at the June, 2025 meeting.]</P>

<P>(From submission
<A HREF="https://github.com/cplusplus/CWG/issues/691">#691</A>.)</P>

<P>Subclause 15.2 [<A href="https://wg21.link/cpp.cond#4">cpp.cond</A>] paragraph 4 talks about the
"syntactic requirements of a <TT>#include</TT> directive".  However,
those requirements are always satisfied, because the only requirement
is to have a sequence of preprocessing tokens according to the grammar
in 15.1 [<A href="https://wg21.link/cpp.pre">cpp.pre</A>].</P>

<P>However, a syntax check for properly forming a <I>header-name</I>
needs to be retained, because 15.3 [<A href="https://wg21.link/cpp.include#4">cpp.include</A>] paragraph 4
otherwise would yield undefined behavior.</P>

<P><B>Proposed resolution (approved by CWG 2025-06-20):</B></P>

<OL>
<LI>
<P>Change in 15.2 [<A href="https://wg21.link/cpp.cond#4">cpp.cond</A>] paragraph 4 as follows:</P>

<BLOCKQUOTE>

The header or source file identified by the parenthesized
preprocessing token sequence in each
contained <I>has-include-expression</I> is searched for as if that
preprocessing token sequence were the <I>pp-tokens</I> in a #include
directive, except that no further macro expansion is performed. If
<DEL>such a directive would not satisfy the syntactic requirements of
a #include directive</DEL>
<INS>the preprocessing token sequence does not consist solely of a
<I>header-name</I> or cannot be combined (15.3 [<A href="https://wg21.link/cpp.include">cpp.include</A>])
into a single <I>header-name</I> preprocessing token</INS>, the
program is ill-formed. The <I>has-include-expression</I> evaluates to
1 if the search for the source file succeeds, and to 0 if the search
fails.

</BLOCKQUOTE>
</LI>

<LI>
<P>Change in 15.2 [<A href="https://wg21.link/cpp.cond#5">cpp.cond</A>] paragraph 5 as follows:</P>

<BLOCKQUOTE>

The parenthesized <I>pp-balanced-token-seq</I> in each
contained <I>has-embed-expression</I> is processed as if
that <I>pp-balanced-token-seq</I> were the pp-tokens in the third form
of a #embed directive (15.4 [<A href="https://wg21.link/cpp.embed">cpp.embed</A>]). <DEL>If such a
directive would not satisfy the syntactic requirements of a #embed
directive, the program is ill-formed.</DEL>
The <I>has-embed-expression</I> evaluates to: ...

</BLOCKQUOTE>
</LI>
</OL>
<BR><BR>
</BODY>
</HTML>
