[PATCH] Declaring standard C++ attributes

Richard Smith metafoo at gmail.com
Wed Jan 29 13:01:56 PST 2014


On Wed Jan 29 2014 at 12:54:14 PM, Aaron Ballman <aaron at aaronballman.com>
wrote:

> 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.
>

So this flag is (at best) misnamed, then, since we want the generic parsing
logic for [[deprecated]]?

It's also causing us to do the wrong thing for [[clang::fallthrough]];
(which starts to accept arguments with this patch, but should not).

It seems like what we want is a flag that means "may not have an argument
clause".


> > 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.
>

If they do, we should publicly shame them and refuse to implement it. =)


> > 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.
>

We do support it, and it works (but I agree, we seem to have forgotten to
handle this properly and there are no tests for it). The argument clause is
ignored entirely for '[[deprecated]]' today, which is not entirely
conforming, since we're required to reject arguments that aren't
string-literals, but is more conforming than rejecting such arguments.

~Aaron
>
> >
> > 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140129/223d2d6f/attachment.html>


More information about the cfe-commits mailing list