<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Mar 9, 2015 at 6:33 AM, Jonathan Wakely <span dir="ltr">&lt;<a href="mailto:cxx@kayari.org" target="_blank">cxx@kayari.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We couldn&#39;t wok out whether SD-6 intends this to work:<br>
<br>
#define D deprecated<br>
#if __has_cpp_attribute (D)<br>
#endif<br>
<br>
Currently GCC performs macro-expansion but Clang doesn&#39;t.</blockquote><div><br></div><div>I don&#39;t have a preference here.</div><div><br></div><div>I think Clang inherits the &quot;do not expand&quot; behavior from its __has_feature and __has_extension builtins, where avoiding expansion is an important feature (some of our feature names are moderately likely to clash with essentially unrelated macro names). It&#39;s also consistent with the treatment of &#39;defined&#39;.</div><div><br></div><div>Having the same expansion behavior for __has_cpp_attribute(D) and [[D]] seems like it might be useful, but only marginally: you&#39;re already restricted to only using this in a #if or #elif, so hard-coding the name of the attribute doesn&#39;t seem like a huge hardship. I could just about see value in something like this:</div><div><br></div><div>#if defined(__clang__)</div><div>#define FOO_ATTR_NS clang</div><div>#elif defined(__GNUC__)</div><div>#define FOO_ATTR_NS gnu</div><div>#elif /*...*/</div><div>/*...*/</div><div>#endif</div><div><br></div><div>#if __has_cpp_attribute(FOO_ATTR_NS::foo)</div><div>[[FOO_ATTR_NS::foo]]</div><div>#endif</div><div>int main() {}</div><div><br></div><div>...but only if multiple vendors implement the same attribute as an extension, but not under the same namespace prefix. For GCC attributes that Clang emulates, it accepts [[gnu::attr]]; I&#39;d expect other implementations that attempt to be compatible with some other compiler to do the same, so this should probably be a rare situation.</div></div></div></div>