[cfe-dev] [PATCH] New syntax and functionality for __has_attribute

Aaron Ballman aaron at aaronballman.com
Sat Jan 11 13:21:13 PST 2014


On Sat, Jan 11, 2014 at 4:16 PM, Nico Rieck <nico.rieck at gmail.com> wrote:
> On 11.01.2014 22:13, Aaron Ballman wrote:
>> However, I did notice something interesting -- we don't support that
>> syntax in a declarative sense (Attr.td does not list a spelling for
>> it), but dllexport and dllimport are silently accepted by clang and
>> the attributes are attached to the decl.
>
> That's what I wondered when reading your examples, since I have been
> using __attribute__((dllexport)) just fine for quite a while. And GCC
> also accepts both variants.

This is off-topic slightly, but...

I can see how this would be incredibly confusing. :-D  This appears to
be a behavior of the way we handle attributes. The parser creates a
parsed attribute by saying "here's the name, here's the syntax used,
here are the args I got, etc" and then eventually sema gets around to
turning that into a semantic attribute. However,
AttributeList::getAttrKind only pays attention to the name and not the
syntax used. Since dllexport is known to be an
AttributeList::AT_DllExport, everything just flows through as normal.
That should probably be rectified at some point, though we'll have to
carefully watch to see how the effect shakes out as some attributes
which work (like dllexport) would then break. Fixing them should
hopefully be trivial, though.

~Aaron



More information about the cfe-dev mailing list