<br><br><div>On Sat Jan 11 2014 at 10:57:22 AM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>> wrote:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Sat, Jan 11, 2014 at 1:49 PM, <a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a> <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br>
> I'm not sure this is necessary - do any compilers (including different<br>
> versions of clang itself, which I believe is the main use of has_attribute)<br>
> support the same attribute but in differing syntaxes?<br>
<br>
Yes, clang has numerous attributes instances of this. I believe GCC<br>
does as well. For instance, it's quite common to have a GNU spelling<br>
and a C++11 syntax for the same attribute. There are also cases where<br>
attributes with the same spelling but different syntax provide<br>
differing semantics, such as the aligned attribute (which has five<br>
different syntaxes).<br></blockquote><div><br></div><div>Sorry, I'm not trying to be obtuse, but I'm not sure if/how that answers my question. <br><br>What I'm asking is, is there ever a case where a compile-time check is required to decide which syntax to use? (where two compilers (including two different versions of the same compiler) have support for the same attribute but in disparate syntaxes?)<br>
<br>The existence of an attribute with more than one, or less than all syntaxes is not an issue - if in every compiler that implements the attribute it is implemented in the same set of syntaxes, then there's no need to query which syntax is valid, is there? It would be a universal constant.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
> Otherwise it just<br>
> seems an invariant of the attribute and not something that would need<br>
> compile time tests for because it won't vary by compilation<br>
<br>
I strongly disagree. Consider the dllexport example I had given.<br>
Supporting that is currently guess-work with __has_attribute because<br>
we only respond back that the attribute is known, but not a particular<br>
syntax. </blockquote><div><br></div><div>Wouldn't it be documented somewhere? Why would it need to be queried dynamically (at compile-time)? That would only be necessary if the attribute was supported with different syntaxes in different compilers. Is that the case? </div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Yet the syntax is specifically required in order to use it<br>
properly.<br>
<br>
FWIW, this is also PR15853.<br></blockquote><div><br></div><div>OK, the unparsability problem could be addressed separately, though. I guess that's why GCC's attribute syntax has the double parens. <br><br>But I see from the bug Richard suggested this - I'm just trying to understand it. </div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
~Aaron<br>
</blockquote>