On Thu, Nov 15, 2012 at 10:33 AM, Michael Han <[email protected]> wrote:
> Hi,
>
> Consider this code
> class [[foo]] c [[foo]];
>
> Clang generates diagnostic like this:
> error: an attribute list cannot appear here
> class [[foo]] c [[foo]];
> ^~~~
>
> I think the first attribute is conforming, and it's the second attribute
> that should be diagnosed.
Yes, I agree that it would be better to point the diagnostic at the
second attribute-specifier-seq (and ideally to say that it's in the
wrong place, and offer a fixit...).
> Attached the patch that fixes this.
I don't think your approach here is going to work. This is valid:
class c {};
class c [[ ]] x;
I believe your patch would treat 'class c' as a declaration in the
second line, which it is not.
In order to correctly handle this, I suggest you parse attributes
after the class name as well as before it, before trying to classify
the reference. If you then find that it's a TUK_Reference, return the
attributes you found after the class name to the caller, for them to
handle appropriately. Otherwise, produce a diagnostic indicating that
they were written in the wrong place (offering a fixit would be
awesome...). For a class definition, you should probably look for
attributes both before and after the optional 'final'.
Thanks for looking into this!
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits