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

Aaron Ballman aaron at aaronballman.com
Sat Jan 11 10:57:22 PST 2014


On Sat, Jan 11, 2014 at 1:49 PM, dblaikie at gmail.com <dblaikie at gmail.com> wrote:
> 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?

Yes, clang has numerous attributes instances of this. I believe GCC
does as well. For instance, it's quite common to have a GNU spelling
and a C++11 syntax for the same attribute. There are also cases where
attributes with the same spelling but different syntax provide
differing semantics, such as the aligned attribute (which has five
different 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

I strongly disagree. Consider the dllexport example I had given.
Supporting that is currently guess-work with __has_attribute because
we only respond back that the attribute is known, but not a particular
syntax. Yet the syntax is specifically required in order to use it
properly.

FWIW, this is also PR15853.

~Aaron



More information about the cfe-dev mailing list