I'm not sure this is necessary - do any compilers (including different versions of clang itself, which I believe is the main use of has_attribute) support the same attribute but in differing syntaxes? Otherwise it just seems an invariant of the attribute and not something that would need compile time tests for because it won't vary by compilation<p dir="ltr">
</p>
<p dir="ltr">On Friday, January 10, 2014 2:11:31 PM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>> wrote:</p>
<blockquote><p dir="ltr">The __has_attribute feature macro is fantastic in many respects, but<br>
is lacking the ability to determine whether a specific attribute<br>
syntax is available or not. Instead, it currently checks whether the<br>
attribute is known within the compilation target, and nothing more.<br>
This can cause problems because not all attributes are applied in the<br>
same way.</p>
<p dir="ltr">Consider dllexport as a contrived example:</p>
<p dir="ltr">#if __has_attribute(dllexport)<br>
  void foo(void) __attribute__((dllexport));<br>
#endif</p>
<p dir="ltr">This code looks fine, but is actually broken because clang only<br>
supports __declspec(dllexport) and not __attribute__((dllexport)), and<br>
__declspec must precede the declaration.</p>
<p dir="ltr">The attached patch implements new syntax for __has_attribute while<br>
retaining backwards compatibility. It allows you to specify exactly<br>
which attribute syntax you desire. If no specific syntax is specified,<br>
it behaves as it always has.</p>
<p dir="ltr">The supported forms are:</p>
<p dir="ltr">__has_attribute(__attribute__((ident))) // GNU-style<br>
__has_attribute(__declspec(ident)) // MS-style<br>
__has_attribute([[ident]])  // C++11-style<br>
__has_attribute([[scope::ident]]) // C++11-style<br>
__has_attribute(ident) // Keywords, or "don't care"</p>
<p dir="ltr">Note that attribute arguments are not supported by design -- they<br>
really don't make any sense in the context of a feature macro.</p>
<p dir="ltr">~Aaron<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</p>
</blockquote>
<p dir="ltr"><br>
</p>