[cfe-commits] [PATCH] c++11 type attribute fix
Michael.Han at autodesk.com
Tue Oct 23 16:38:47 PDT 2012
> But something has already gone wrong if in "[[foo]] int [[foo]] x;", both attributes end up in the same attribute list.
I think attributes that appear before declaration specifier will be taken and merged in the attribute list of the declaration specifier when declaration specifier is parsed; that's why it seems to me using source location is the only way to tell if an attribute is part of declaration specifier, or taken from somewhere else. Do you think this is a bug in parser that should be fixed? Maybe, in case of "[[foo]] int [[foo]] x", there should be two attribute list one associated with declaration specifier and the other associated with the declarator id?
> I don't understand why you're special-casing AT_CarriesDependency.
This attribute can't be applied to types so I am emitting an error message that is different than default error message (unknown attributes ignored); thus I am special casing it. My understanding is in general any type attributes that can be handled (either applying it to types, or emitting customized error message) should be special cased.
From: Eli Friedman [mailto:eli.friedman at gmail.com]
Sent: Tuesday, October 23, 2012 3:31 PM
To: Michael Han
Cc: cfe-commits at cs.uiuc.edu
Subject: Re: [cfe-commits] [PATCH] c++11 type attribute fix
On Tue, Oct 23, 2012 at 3:04 PM, Michael Han <Michael.Han at autodesk.com> wrote:
> Hi Eli,
> Thank you for the review!
> I was using "<" to differentiate case '[[foo]] int x' from 'int [[foo]] x'. Is there a reliable way to tell from SourceLocation that one construct appears before the other?
SourceManager::isBeforeInTranslationUnit . But something has already gone wrong if in "[[foo]] int [[foo]] x;", both attributes end up in the same attribute list.
> Regarding "try to apply to a type, fall back to a decl": the patch tries to avoid that by having all C++11 attributes that apply to types get processed in processTypeAttrs, so C++11 attributes are either get handled directly (like carries_dependency), or warns on default case; there is no fall back to declaration. Do you think this strategy is in general valid and if so any suggestions on the best place to handle C++11 attributes that applies to types?
I don't understand why you're special-casing AT_CarriesDependency.
Otherwise, that makes sense.
More information about the cfe-commits