diff options
author | Anders Carlsson <andersca@mac.com> | 2009-03-26 00:52:18 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-03-26 00:52:18 +0000 |
commit | 5aeccdbb4bdc94e48c04cacc59fa812af32109b2 (patch) | |
tree | a12d78394bc3923a43dea66e6e5054c3bc772a1f | |
parent | 50713450f61b85805e1ca97e547a4082b7798bd3 (diff) |
Handle parsing of templates in member declarations. Pass the AccessSpecifier all the way down to ActOnClassTemplate.
Doug, Sebastian: Plz review! :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67723 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Parse/Action.h | 3 | ||||
-rw-r--r-- | include/clang/Parse/Parser.h | 7 | ||||
-rw-r--r-- | lib/Parse/ParseDeclCXX.cpp | 9 | ||||
-rw-r--r-- | lib/Parse/ParseTemplate.cpp | 5 | ||||
-rw-r--r-- | lib/Parse/Parser.cpp | 5 | ||||
-rw-r--r-- | lib/Sema/Sema.h | 3 | ||||
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 3 |
7 files changed, 24 insertions, 11 deletions
diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h index 288e9a2cad..c75a209d33 100644 --- a/include/clang/Parse/Action.h +++ b/include/clang/Parse/Action.h @@ -1175,7 +1175,8 @@ public: SourceLocation KWLoc, const CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, - MultiTemplateParamsArg TemplateParameterLists) { + MultiTemplateParamsArg TemplateParameterLists, + AccessSpecifier AS) { return 0; } diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index f49f7bd598..630b7ea499 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -549,7 +549,9 @@ private: // C99 6.9: External Definitions. DeclTy *ParseExternalDeclaration(); DeclTy *ParseDeclarationOrFunctionDefinition( - TemplateParameterLists *TemplateParams = 0); + TemplateParameterLists *TemplateParams = 0, + AccessSpecifier AS = AS_none); + DeclTy *ParseFunctionDefinition(Declarator &D); void ParseKNRParamDeclarations(Declarator &D); // EndLoc, if non-NULL, is filled with the location of the last token of @@ -1027,7 +1029,8 @@ private: typedef llvm::SmallVector<DeclTy *, 4> TemplateParameterList; // C++ 14.1: Template Parameters [temp.param] - DeclTy *ParseTemplateDeclarationOrSpecialization(unsigned Context); + DeclTy *ParseTemplateDeclarationOrSpecialization(unsigned Context, + AccessSpecifier AS=AS_none); bool ParseTemplateParameters(unsigned Depth, TemplateParameterList &TemplateParams, SourceLocation &LAngleLoc, diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 1bbf411874..61182ef9cd 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -460,7 +460,8 @@ void Parser::ParseClassSpecifier(DeclSpec &DS, Attr, Action::MultiTemplateParamsArg(Actions, &(*TemplateParams)[0], - TemplateParams->size())); + TemplateParams->size()), + AS); else TagOrTempResult = Actions.ActOnTag(CurScope, TagType, TK, StartLoc, SS, Name, NameLoc, Attr, AS); @@ -615,7 +616,7 @@ AccessSpecifier Parser::getAccessSpecifierIfPresent() const /// ::[opt] nested-name-specifier template[opt] unqualified-id ';'[TODO] /// using-declaration [TODO] /// [C++0x] static_assert-declaration -/// template-declaration [TODO] +/// template-declaration /// [GNU] '__extension__' member-declaration /// /// member-declarator-list: @@ -638,6 +639,10 @@ Parser::DeclTy *Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS) { if (Tok.is(tok::kw_static_assert)) return ParseStaticAssertDeclaration(); + if (Tok.is(tok::kw_template)) + return ParseTemplateDeclarationOrSpecialization(Declarator::MemberContext, + AS); + // Handle: member-declaration ::= '__extension__' member-declaration if (Tok.is(tok::kw___extension__)) { // __extension__ silences extension warnings in the subexpression. diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp index 2aeb182dbd..2c07823aba 100644 --- a/lib/Parse/ParseTemplate.cpp +++ b/lib/Parse/ParseTemplate.cpp @@ -35,7 +35,8 @@ using namespace clang; /// explicit-specialization: [ C++ temp.expl.spec] /// 'template' '<' '>' declaration Parser::DeclTy * -Parser::ParseTemplateDeclarationOrSpecialization(unsigned Context) { +Parser::ParseTemplateDeclarationOrSpecialization(unsigned Context, + AccessSpecifier AS) { assert((Tok.is(tok::kw_export) || Tok.is(tok::kw_template)) && "Token does not start a template declaration."); @@ -94,7 +95,7 @@ Parser::ParseTemplateDeclarationOrSpecialization(unsigned Context) { } while (Tok.is(tok::kw_export) || Tok.is(tok::kw_template)); // Parse the actual template declaration. - return ParseDeclarationOrFunctionDefinition(&ParamLists); + return ParseDeclarationOrFunctionDefinition(&ParamLists, AS); } /// ParseTemplateParameters - Parses a template-parameter-list enclosed in diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index 135faf4e9c..7a221d007c 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -442,10 +442,11 @@ Parser::DeclTy *Parser::ParseExternalDeclaration() { /// Parser::DeclTy * Parser::ParseDeclarationOrFunctionDefinition( - TemplateParameterLists *TemplateParams) { + TemplateParameterLists *TemplateParams, + AccessSpecifier AS) { // Parse the common declaration-specifiers piece. DeclSpec DS; - ParseDeclarationSpecifiers(DS, TemplateParams); + ParseDeclarationSpecifiers(DS, TemplateParams, AS); // C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };" // declaration-specifiers init-declarator-list[opt] ';' diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index 974404cbbd..7f2f109734 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -1715,7 +1715,8 @@ public: SourceLocation KWLoc, const CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, - MultiTemplateParamsArg TemplateParameterLists); + MultiTemplateParamsArg TemplateParameterLists, + AccessSpecifier AS); QualType CheckClassTemplateId(ClassTemplateDecl *ClassTemplate, SourceLocation TemplateLoc, diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index c0476a8d3f..b8b1f3a5bb 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -388,7 +388,8 @@ Sema::ActOnClassTemplate(Scope *S, unsigned TagSpec, TagKind TK, SourceLocation KWLoc, const CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, - MultiTemplateParamsArg TemplateParameterLists) { + MultiTemplateParamsArg TemplateParameterLists, + AccessSpecifier AS) { assert(TemplateParameterLists.size() > 0 && "No template parameter lists?"); assert(TK != TK_Reference && "Can only declare or define class templates"); bool Invalid = false; |