diff options
Diffstat (limited to 'lib/Parse')
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 2 | ||||
-rw-r--r-- | lib/Parse/ParseDeclCXX.cpp | 12 | ||||
-rw-r--r-- | lib/Parse/ParseTemplate.cpp | 39 | ||||
-rw-r--r-- | lib/Parse/Parser.cpp | 1 |
4 files changed, 27 insertions, 27 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 114f4cb570..e2601b6cf4 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -1726,7 +1726,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) { // If this identifier is followed by a '<', we may have a template-id. DeclTy *Template; - if (NextToken().is(tok::less) && + if (getLang().CPlusPlus && NextToken().is(tok::less) && (Template = Actions.isTemplateName(*Tok.getIdentifierInfo(), CurScope))) { IdentifierInfo *II = Tok.getIdentifierInfo(); diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 1fbe32a459..b2b0d8f59f 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -345,8 +345,8 @@ void Parser::ParseClassSpecifier(DeclSpec &DS, return; } - // Parse the tag portion of this. - DeclTy *TagDecl + // Create the tag portion of the class, possibly resulting in a template. + DeclTy *TagOrTempDecl = Actions.ActOnTag(CurScope, TagType, TK, StartLoc, SS, Name, NameLoc, Attr, Action::MultiTemplateParamsArg( @@ -356,15 +356,15 @@ void Parser::ParseClassSpecifier(DeclSpec &DS, // Parse the optional base clause (C++ only). if (getLang().CPlusPlus && Tok.is(tok::colon)) { - ParseBaseClause(TagDecl); + ParseBaseClause(TagOrTempDecl); } // If there is a body, parse it and inform the actions module. if (Tok.is(tok::l_brace)) if (getLang().CPlusPlus) - ParseCXXMemberSpecification(StartLoc, TagType, TagDecl); + ParseCXXMemberSpecification(StartLoc, TagType, TagOrTempDecl); else - ParseStructUnionBody(StartLoc, TagType, TagDecl); + ParseStructUnionBody(StartLoc, TagType, TagOrTempDecl); else if (TK == Action::TK_Definition) { // FIXME: Complain that we have a base-specifier list but no // definition. @@ -372,7 +372,7 @@ void Parser::ParseClassSpecifier(DeclSpec &DS, } const char *PrevSpec = 0; - if (DS.SetTypeSpecType(TagType, StartLoc, PrevSpec, TagDecl)) + if (DS.SetTypeSpecType(TagType, StartLoc, PrevSpec, TagOrTempDecl)) Diag(StartLoc, diag::err_invalid_decl_spec_combination) << PrevSpec; } diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp index b9a55147b8..e95c106f28 100644 --- a/lib/Parse/ParseTemplate.cpp +++ b/lib/Parse/ParseTemplate.cpp @@ -39,7 +39,7 @@ Parser::DeclTy *Parser::ParseTemplateDeclaration(unsigned Context) { // // We parse multiple levels non-recursively so that we can build a // single data structure containing all of the template parameter - // lists, and easily differentiate between the case above and: + // lists easily differentiate between the case above and: // // template<typename T> // class A { @@ -82,19 +82,16 @@ Parser::DeclTy *Parser::ParseTemplateDeclaration(unsigned Context) { } while (Tok.is(tok::kw_export) || Tok.is(tok::kw_template)); // Parse the actual template declaration. - DeclTy *TemplateDecl = ParseDeclarationOrFunctionDefinition(&ParamLists); - - return TemplateDecl; + return ParseDeclarationOrFunctionDefinition(&ParamLists); } /// ParseTemplateParameters - Parses a template-parameter-list enclosed in -/// angle brackets. Depth is the depth of this -/// template-parameter-list, which is the number of template headers -/// directly enclosing this template header. TemplateParams is the -/// current list of template parameters we're building. The template -/// parameter we parse will be added to this list. LAngleLoc and -/// RAngleLoc will receive the positions of the '<' and '>', -/// respectively, that enclose this template parameter list. +/// angle brackets. Depth is the depth of this template-parameter-list, which +/// is the number of template headers directly enclosing this template header. +/// TemplateParams is the current list of template parameters we're building. +/// The template parameter we parse will be added to this list. LAngleLoc and +/// RAngleLoc will receive the positions of the '<' and '>', respectively, +/// that enclose this template parameter list. bool Parser::ParseTemplateParameters(unsigned Depth, TemplateParameterList &TemplateParams, SourceLocation &LAngleLoc, @@ -223,8 +220,8 @@ Parser::DeclTy *Parser::ParseTypeParameter(unsigned Depth, unsigned Position) { return 0; } - DeclTy *TypeParam = Actions.ActOnTypeParameter(CurScope, TypenameKeyword, - KeyLoc, ParamName, NameLoc, + DeclTy *TypeParam = Actions.ActOnTypeParameter(CurScope, TypenameKeyword, + KeyLoc, ParamName, NameLoc, Depth, Position); // Grab a default type id (if given). @@ -251,7 +248,7 @@ Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) { SourceLocation TemplateLoc = ConsumeToken(); TemplateParameterList TemplateParams; SourceLocation LParenLoc, RParenLoc; - if(!ParseTemplateParameters(Depth+1, TemplateParams, LParenLoc, + if(!ParseTemplateParameters(Depth + 1, TemplateParams, LParenLoc, RParenLoc)) { return 0; } @@ -266,10 +263,11 @@ Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) { SourceLocation ClassLoc = ConsumeToken(); // Get the identifier, if given. - IdentifierInfo* ident = 0; + SourceLocation NameLoc; + IdentifierInfo* ParamName = 0; if(Tok.is(tok::identifier)) { - ident = Tok.getIdentifierInfo(); - ConsumeToken(); + ParamName = Tok.getIdentifierInfo(); + NameLoc = ConsumeToken(); } else if(Tok.is(tok::equal) || Tok.is(tok::comma) || Tok.is(tok::greater)) { // Unnamed template parameter. Don't have to do anything here, just // don't consume this token. @@ -279,6 +277,8 @@ Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) { } // Get the a default value, if given. + // FIXME: I think that the results of this block need to be passed to the + // act-on call, so we can assemble the parameter correctly. OwningExprResult DefaultExpr(Actions); if(Tok.is(tok::equal)) { ConsumeToken(); @@ -288,8 +288,9 @@ Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) { } } - // FIXME: Add an action for template template parameters. - return 0; + return Actions.ActOnTemplateTemplateParameter(CurScope, TemplateLoc, + &TemplateParams, ParamName, + NameLoc, Depth, Position); } /// ParseNonTypeTemplateParameter - Handle the parsing of non-type diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index c5c7dd4733..2f7e2ea0fc 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -379,7 +379,6 @@ Parser::DeclTy *Parser::ParseExternalDeclaration() { case tok::kw_export: // As in 'export template' // A function definition cannot start with a these keywords. return ParseDeclaration(Declarator::FileContext); - default: // We can't tell whether this is a function-definition or declaration yet. return ParseDeclarationOrFunctionDefinition(); |