r198883 - Removing a bit of custom parsing functionality used by the thread safety analysis APIs. Now using tablegen to determine whether an attribute's arguments should be parsed in an unevaluated context instead of relying on a separate, hard-coded list of attributes.

Aaron Ballman aaron at aaronballman.com
Fri Jan 10 08:32:29 PST 2014


On Fri, Jan 10, 2014 at 11:20 AM, Alexander Kornienko <alexfh at google.com> wrote:
> This change seems to break parsing of the guarded_by attribute using the
> C++11 syntax:
>
> $ cat test.cc
> class __attribute__((lockable)) Mutex {};
>
> struct Cxx11Style {
>   Mutex cxx11_mutex;
>   int i [[gnu::guarded_by(cxx11_mutex)]];
> };
>
> $ clang -fsyntax-only -std=c++11 test.cc
> test.cc:5:11: warning: unknown attribute 'guarded_by' ignored [-Wattributes]
>   int i [[gnu::guarded_by(cxx11_mutex)]];
>           ^
> 1 warning generated.
>
>
> Is it intentional?

There is no C++11 syntax for guarded_by attributes:

def GuardedBy : InheritableAttr {
  let Spellings = [GNU<"guarded_by">];
  ...

So I would claim it's unintentional, but not incorrect (the fact that
it used to be allowed is kind of scary, actually). Assuming that GCC
does not support this attribute, I would not be opposed to adding a
clang:: scoped spelling if it's desirable. If GCC does support this
scoped spelling, then we should update Attr.td accordingly. Delesley,
do you have any opinions on this?

~Aaron



More information about the cfe-commits mailing list