[PATCH] Declaring standard C++ attributes

Aaron Ballman aaron at aaronballman.com
Wed Jan 29 12:54:14 PST 2014

On Wed, Jan 29, 2014 at 3:45 PM, Richard Smith <metafoo at gmail.com> wrote:
> I'm not really sure what this is for: don't we want to have a flag for
> 'cannot have parens' rather than 'is a standardized C++ attribute'?

Since standardized C++ attributes all have custom parsing rules (some
can have parens, some can't, and the future holds mystery), I think it
makes sense to have two cases: things which the standard mandates the
parsing rules for, and things which can be generically parsed.

> Also, it
> seems easy to detect standard attributes: they're C++ attributes with no
> scope token. We don't need to generate a flag for that.

Except there's nothing mandating that (for instance, gcc or MSVC
[someday] could arbitrarily add a C++ style attribute without a scope,
ignoring the non-normative note to the contrary). This gives us
flexibility to handle it, though it's not required today.

> It looks like this causes a regression: we start rejecting
> [[deprecated("foo")]] with it, don't we?

We don't support [[deprecated("foo")]] yet, nor are there any tests
for it. We only support [[deprecated]] currently.


> On Wed Jan 29 2014 at 11:56:34 AM, Aaron Ballman <aaron at aaronballman.com>
> wrote:
>> This patch provides a declarative way to specify a standards-based
>> C++11-style attribute using the StdCXX spelling class. It then removes
>> a small, hard-coded list of standard attributes from the parser and
>> uses a generated list to accomplish the same thing.
>> Since C++11 attributes are not in the std:: namespace, this also
>> removes the std:: variant from standards-based attributes. However, if
>> the std:: namespace were to become part of the standard, it can be
>> handled when flattening out the attributes in the same way that we do
>> for GCC spellings.
>> ~Aaron

More information about the cfe-commits mailing list