diff options
author | DeLesley Hutchins <delesley@google.com> | 2012-03-02 22:12:59 +0000 |
---|---|---|
committer | DeLesley Hutchins <delesley@google.com> | 2012-03-02 22:12:59 +0000 |
commit | 2287c5e2352fc51cd74e8a9a7725cbf87e41c007 (patch) | |
tree | ae07c0784e322a4900199e6cbf277d0cdba8d316 /lib/Parse/ParseDeclCXX.cpp | |
parent | 2a35be803c405221f5f23c7bdedb91f09efdd3ac (diff) |
Make late-parsed attributes follow the conventions of ordinary
GNU attributes to a better extent, by allowing them in more
places on a declator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151945 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDeclCXX.cpp')
-rw-r--r-- | lib/Parse/ParseDeclCXX.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 3bf7005769..983bd7ee15 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -1782,11 +1782,15 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, return; } + // Hold late-parsed attributes so we can attach a Decl to them later. + LateParsedAttrList CommonLateParsedAttrs; + // decl-specifier-seq: // Parse the common declaration-specifiers piece. ParsingDeclSpec DS(*this, TemplateDiags); DS.takeAttributesFrom(attrs); - ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DSC_class); + ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DSC_class, + &CommonLateParsedAttrs); MultiTemplateParamsArg TemplateParams(Actions, TemplateInfo.TemplateParams? TemplateInfo.TemplateParams->data() : 0, @@ -1893,8 +1897,11 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, ParseCXXInlineMethodDef(AS, AccessAttrs, DeclaratorInfo, TemplateInfo, VS, DefinitionKind, Init); + for (unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i) { + CommonLateParsedAttrs[i]->addDecl(FunDecl); + } for (unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i) { - LateParsedAttrs[i]->setDecl(FunDecl); + LateParsedAttrs[i]->addDecl(FunDecl); } LateParsedAttrs.clear(); @@ -1981,8 +1988,11 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, } // Set the Decl for any late parsed attributes + for (unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i) { + CommonLateParsedAttrs[i]->addDecl(ThisDecl); + } for (unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i) { - LateParsedAttrs[i]->setDecl(ThisDecl); + LateParsedAttrs[i]->addDecl(ThisDecl); } LateParsedAttrs.clear(); |