diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-02-20 19:22:51 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-02-20 19:22:51 +0000 |
commit | 6b3d3e54c003b03f16e235ad2ff49e95587bbf92 (patch) | |
tree | 81d295f0e5e6912c0036d7a9bb824e3a91ebe4f1 /lib/Parse/ParseDeclCXX.cpp | |
parent | 2ec6cfcfa00832b015c7a2018884d95ef15f4477 (diff) |
Process and handle attributes on conditions and for loop variables. Process and
diagnose attributes on alias declarations, using directives, and attribute
declarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175649 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDeclCXX.cpp')
-rw-r--r-- | lib/Parse/ParseDeclCXX.cpp | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 4d428ceea1..22f5863e5f 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -451,24 +451,21 @@ Decl *Parser::ParseUsingDeclaration(unsigned Context, Decl **OwnedType) { CXXScopeSpec SS; SourceLocation TypenameLoc; - bool IsTypeName; - ParsedAttributesWithRange attrs(AttrFactory); + bool IsTypeName = false; + ParsedAttributesWithRange Attrs(AttrFactory); // FIXME: Simply skip the attributes and diagnose, don't bother parsing them. - MaybeParseCXX11Attributes(attrs); - ProhibitAttributes(attrs); - attrs.clear(); - attrs.Range = SourceRange(); + MaybeParseCXX11Attributes(Attrs); + ProhibitAttributes(Attrs); + Attrs.clear(); + Attrs.Range = SourceRange(); // Ignore optional 'typename'. // FIXME: This is wrong; we should parse this as a typename-specifier. if (Tok.is(tok::kw_typename)) { - TypenameLoc = Tok.getLocation(); - ConsumeToken(); + TypenameLoc = ConsumeToken(); IsTypeName = true; } - else - IsTypeName = false; // Parse nested-name-specifier. ParseOptionalCXXScopeSpecifier(SS, ParsedType(), /*EnteringContext=*/false); @@ -495,14 +492,13 @@ Decl *Parser::ParseUsingDeclaration(unsigned Context, return 0; } - MaybeParseCXX11Attributes(attrs); + MaybeParseCXX11Attributes(Attrs); // Maybe this is an alias-declaration. bool IsAliasDecl = Tok.is(tok::equal); TypeResult TypeAlias; if (IsAliasDecl) { - // TODO: Attribute support. C++0x attributes may appear before the equals. - // Where can GNU attributes appear? + // TODO: Can GNU attributes appear here? ConsumeToken(); Diag(Tok.getLocation(), getLangOpts().CPlusPlus11 ? @@ -547,20 +543,21 @@ Decl *Parser::ParseUsingDeclaration(unsigned Context, TypeAlias = ParseTypeName(0, TemplateInfo.Kind ? Declarator::AliasTemplateContext : - Declarator::AliasDeclContext, AS, OwnedType); + Declarator::AliasDeclContext, AS, OwnedType, + &Attrs); } else { // C++11 attributes are not allowed on a using-declaration, but GNU ones // are. - ProhibitAttributes(attrs); + ProhibitAttributes(Attrs); // Parse (optional) attributes (most likely GNU strong-using extension). - MaybeParseGNUAttributes(attrs); + MaybeParseGNUAttributes(Attrs); } // Eat ';'. DeclEnd = Tok.getLocation(); ExpectAndConsume(tok::semi, diag::err_expected_semi_after, - !attrs.empty() ? "attributes list" : + !Attrs.empty() ? "attributes list" : IsAliasDecl ? "alias declaration" : "using declaration", tok::semi); @@ -592,13 +589,13 @@ Decl *Parser::ParseUsingDeclaration(unsigned Context, MultiTemplateParamsArg TemplateParamsArg( TemplateParams ? TemplateParams->data() : 0, TemplateParams ? TemplateParams->size() : 0); - // FIXME: Propagate attributes. return Actions.ActOnAliasDeclaration(getCurScope(), AS, TemplateParamsArg, - UsingLoc, Name, TypeAlias); + UsingLoc, Name, Attrs.getList(), + TypeAlias); } return Actions.ActOnUsingDeclaration(getCurScope(), AS, true, UsingLoc, SS, - Name, attrs.getList(), + Name, Attrs.getList(), IsTypeName, TypenameLoc); } |