<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2390</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="2390"></A><H4>2390.
  
Is the argument of <TT>__has_cpp_attribute</TT> macro-expanded?
</H4>
<B>Section: </B>15.2&#160; [<A href="https://wg21.link/cpp.cond">cpp.cond</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Richard Smith
 &#160;&#160;&#160;

 <B>Date: </B>2018-11-14<BR>


<P>[Accepted as a DR at the July, 2019 meeting.]</P>

<P>The Standard does not specify whether the argument of
<TT>__has_cpp_attribute</TT> is macro-expanded before being tested
to see if it names an attribute or not, and there is implementation
divergence.</P>

<P><B>Notes from the February, 2019 meeting:</B></P>

<P>CWG observed that a use of an attribute would be macro-expanded,
so it seemed reasonable to expect to be able to specify the same
macro as the argument to <TT>__has_cpp_attribute</TT> and get the
corresponding result.</P>

<P><B>Proposed resolution (June, 2019):</B></P>

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

<BLOCKQUOTE>

Each <I>has-attribute-expression</I> is replaced by a
non-zero <I>pp-number</I> matching the form of
an <I>integer-literal</I> if the implementation supports an
attribute with the name specified by interpreting
the <I>pp-token</I>s<INS>, after macro expansion,</INS>
as an <I>attribute-token</I>, and by <TT>0</TT>
otherwise. The program is ill-formed if the <I>pp-token</I>s
do not match the form of an <I>attribute-token</I>.

</BLOCKQUOTE>

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

<BLOCKQUOTE>

After all replacements due to macro expansion and
evaluations of <I>defined-macro-expression</I>s<INS>,</INS>
<DEL>and</DEL> <I>has-include-expression</I>s<INS>,
and <I>has_attribute_expression</I>s</INS> have been
performed, all remaining identifiers and keywords, except
for <TT>true</TT> and <TT>false</TT>, are replaced with
the <I>pp-number</I> <TT>0</TT>, and then each preprocessing
token is converted into a token. [<I>Note:</I> An
alternative token (5.9 [<A href="https://wg21.link/lex.digraph">lex.digraph</A>]) is not an
identifier, even when its spelling consists entirely of
letters and underscores.  Therefore it is not subject to
this replacement. &#8212;<I>end note</I>]

</BLOCKQUOTE>

</OL>

<BR><BR>
</BODY>
</HTML>
