diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-08-20 22:52:58 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-08-20 22:52:58 +0000 |
commit | 3447e76762fc322a6d4489eb3511a4c25d0a0c24 (patch) | |
tree | 505083263f15a82e451f7589bac2642f038601dc /clang/lib/Parse/ParseDeclCXX.cpp | |
parent | fa2b97e61a915354bef1b28c35776eb362888606 (diff) | |
download | bcm5719-llvm-3447e76762fc322a6d4489eb3511a4c25d0a0c24.tar.gz bcm5719-llvm-3447e76762fc322a6d4489eb3511a4c25d0a0c24.zip |
Initial support for parsing and representation of member function templates.
llvm-svn: 79570
Diffstat (limited to 'clang/lib/Parse/ParseDeclCXX.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index fd860a4e257..bce9ee0d826 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -905,15 +905,19 @@ void Parser::HandleMemberFunctionDefaultArgs(Declarator& DeclaratorInfo, /// constant-initializer: /// '=' constant-expression /// -void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS) { +void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, + const ParsedTemplateInfo &TemplateInfo) { // static_assert-declaration if (Tok.is(tok::kw_static_assert)) { + // FIXME: Check for templates SourceLocation DeclEnd; ParseStaticAssertDeclaration(DeclEnd); return; } if (Tok.is(tok::kw_template)) { + assert(!TemplateInfo.TemplateParams && + "Nested template improperly parsed?"); SourceLocation DeclEnd; ParseDeclarationStartingWithTemplate(Declarator::MemberContext, DeclEnd, AS); @@ -925,10 +929,12 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS) { // __extension__ silences extension warnings in the subexpression. ExtensionRAIIObject O(Diags); // Use RAII to do this. ConsumeToken(); - return ParseCXXClassMemberDeclaration(AS); + return ParseCXXClassMemberDeclaration(AS, TemplateInfo); } if (Tok.is(tok::kw_using)) { + // FIXME: Check for template aliases + // Eat 'using'. SourceLocation UsingLoc = ConsumeToken(); @@ -948,11 +954,12 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS) { // decl-specifier-seq: // Parse the common declaration-specifiers piece. DeclSpec DS; - ParseDeclarationSpecifiers(DS, ParsedTemplateInfo(), AS, DSC_class); + ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DSC_class); if (Tok.is(tok::semi)) { ConsumeToken(); + // FIXME: Friend templates? if (DS.isFriendSpecified()) Actions.ActOnFriendDecl(CurScope, &DS, /*IsDefinition*/ false); else @@ -996,7 +1003,7 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS) { return; } - ParseCXXInlineMethodDef(AS, DeclaratorInfo); + ParseCXXInlineMethodDef(AS, DeclaratorInfo, TemplateInfo); return; } } @@ -1059,15 +1066,20 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS) { DeclPtrTy ThisDecl; if (DS.isFriendSpecified()) { - // TODO: handle initializers, bitfields, 'delete' + // TODO: handle initializers, bitfields, 'delete', friend templates ThisDecl = Actions.ActOnFriendDecl(CurScope, &DeclaratorInfo, /*IsDefinition*/ false); - } else + } else { + Action::MultiTemplateParamsArg TemplateParams(Actions, + TemplateInfo.TemplateParams? TemplateInfo.TemplateParams->data() : 0, + TemplateInfo.TemplateParams? TemplateInfo.TemplateParams->size() : 0); ThisDecl = Actions.ActOnCXXMemberDeclarator(CurScope, AS, DeclaratorInfo, + move(TemplateParams), BitfieldSize.release(), Init.release(), Deleted); + } if (ThisDecl) DeclsInGroup.push_back(ThisDecl); @@ -1181,6 +1193,8 @@ void Parser::ParseCXXMemberSpecification(SourceLocation RecordLoc, continue; } + // FIXME: Make sure we don't have a template here. + // Parse all the comma separated declarators. ParseCXXClassMemberDeclaration(CurAS); } |