<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Dec 4, 2014 at 4:16 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5">On Thu, Dec 4, 2014 at 7:22 AM, Aaron Ballman <span dir="ltr"><<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Ping<br>
<div><div><br>
On Mon, Nov 24, 2014 at 10:02 AM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>> wrote:<br>
> On Thu, Nov 20, 2014 at 7:22 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>> wrote:<br>
>> On Thu, Nov 20, 2014 at 3:48 PM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>><br>
>> wrote:<br>
>>><br>
>>> On Thu, Nov 20, 2014 at 6:27 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>><br>
>>> wrote:<br>
>>> > On Thu, Nov 20, 2014 at 1:38 PM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>><br>
>>> > wrote:<br>
>>> >><br>
>>> >> The __has_attribute implementation does not pay attention to the<br>
>>> >> syntax supported by attributes -- instead, it looks to see whether an<br>
>>> >> attribute is generally known with that spelling. Since pragmas can now<br>
>>> >> be spelled as attributes, this means __has_attribute(loop) returns<br>
>>> >> true because of the #pragma loop functionality. Same for unroll.<br>
>>> >><br>
>>> >> Should __has_attribute ignore attributes spelled with a #pragma<br>
>>> >> spelling?<br>
>>> ><br>
>>> ><br>
>>> > I would go further: __has_attribute should probably only look for<br>
>>> > GNU-syntax<br>
>>> > attributes. We have __has_cpp_attribute for C++-syntax attributes now,<br>
>>> > and I<br>
>>> > don't think anyone is (yet) using this for __declspec, so now seems like<br>
>>> > a<br>
>>> > good time to make this change.<br>
>>><br>
>>> A long, long while back, we discussed having a way to determine<br>
>>> attributes by syntax, because that's sometimes important, as well as a<br>
>>> general query mechanism.<br>
>>><br>
>>> How about adding:<br>
>>><br>
>>> __has_declspec_attribute<br>
>>> __has_keyword_attribute<br>
>>> __has_gnu_attribute<br>
>>><br>
>>> and leaving __has_attribute generic across syntaxes?<br>
>>><br>
>>> This also reduces the chances of breaking code by allowing the<br>
>>> __has_attribute syntax to continue to work as it always has.<br>
>><br>
>><br>
>> Back when we only had GNU attributes, that's all it detected. I'm not<br>
>> convinced that people are actually using it for anything else,<br>
><br>
> I believe I've seen some code using it for __declspec attributes.<br>
> IIRC, we may have run into this with MinGW, which implements<br>
> __declspec as a macro, replaced by __attribute__.<br>
><br>
>> and I think<br>
>> it would be surprising if it said an attribute was supported but that<br>
>> attribute didn't work with GNU syntax. A generic-across-syntaxes<br>
>> __has_attribute is basically useless.<br>
><br>
> The more I think about cross-syntax attribute checking, the more I<br>
> agree it's useless.<br>
><br>
> I still think it would make sense to add the various forms of this,<br>
> and I definitely think that pragmas should be excluded from<br>
> __has_attribute.<br>
><br>
> How does this sound as a path forward:<br>
><br>
> * Change __has_attribute to only support GNU-style attributes. This<br>
> has the potential to break code, so this will require careful watching<br>
> of the lists.<br>
> * Add __has_declspec_attribute & __has_keyword_attribute, that only<br>
> apply to __declspecs and keywords.</div></div></blockquote><div><br></div></div></div><div>Sounds good to me, except perhaps for the __has_keyword_attribute part. We already provide that functionality through __is_identifier, and it's not completely clear to me that we want both mechanisms</div></div></div></div>
</blockquote></div><br></div><div class="gmail_extra">Hmm, also, the fact that we implement certain keywords as attributes seems like an implementation detail rather than something we should expose to users.</div></div>