summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-06-24 00:54:41 +0000
committerDouglas Gregor <dgregor@apple.com>2009-06-24 00:54:41 +0000
commit17a7c1297ac8e1490d611d77d7e33863dfa3700a (patch)
tree3a4d28c96305975b8c17f0a75d68a5d7395126da /clang/lib
parent92ffdd15f8bbb16e3494cecc0253f9960a657432 (diff)
downloadbcm5719-llvm-17a7c1297ac8e1490d611d77d7e33863dfa3700a.tar.gz
bcm5719-llvm-17a7c1297ac8e1490d611d77d7e33863dfa3700a.zip
Make sure that the template parameter lists get from the parser down to ActOnFunctionDeclarator for function template definitions
llvm-svn: 74040
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Parse/ParseTemplate.cpp2
-rw-r--r--clang/lib/Parse/Parser.cpp11
-rw-r--r--clang/lib/Sema/Sema.h4
-rw-r--r--clang/lib/Sema/SemaDecl.cpp2
-rw-r--r--clang/lib/Sema/SemaTemplate.cpp21
5 files changed, 37 insertions, 3 deletions
diff --git a/clang/lib/Parse/ParseTemplate.cpp b/clang/lib/Parse/ParseTemplate.cpp
index daf9500af88..ab359f4c5e0 100644
--- a/clang/lib/Parse/ParseTemplate.cpp
+++ b/clang/lib/Parse/ParseTemplate.cpp
@@ -201,7 +201,7 @@ Parser::ParseSingleDeclarationAfterTemplate(
}
return DeclPtrTy();
}
- return ParseFunctionDefinition(DeclaratorInfo);
+ return ParseFunctionDefinition(DeclaratorInfo, TemplateInfo);
}
if (DeclaratorInfo.isFunctionDeclarator())
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index a2a66f9255d..18048443223 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -590,7 +590,8 @@ Parser::ParseDeclarationOrFunctionDefinition(AccessSpecifier AS) {
/// [C++] function-definition: [C++ 8.4]
/// decl-specifier-seq[opt] declarator function-try-block
///
-Parser::DeclPtrTy Parser::ParseFunctionDefinition(Declarator &D) {
+Parser::DeclPtrTy Parser::ParseFunctionDefinition(Declarator &D,
+ const ParsedTemplateInfo &TemplateInfo) {
const DeclaratorChunk &FnTypeInfo = D.getTypeObject(0);
assert(FnTypeInfo.Kind == DeclaratorChunk::Function &&
"This isn't a function declarator!");
@@ -632,7 +633,13 @@ Parser::DeclPtrTy Parser::ParseFunctionDefinition(Declarator &D) {
// Tell the actions module that we have entered a function definition with the
// specified Declarator for the function.
- DeclPtrTy Res = Actions.ActOnStartOfFunctionDef(CurScope, D);
+ DeclPtrTy Res = TemplateInfo.TemplateParams?
+ Actions.ActOnStartOfFunctionTemplateDef(CurScope,
+ Action::MultiTemplateParamsArg(Actions,
+ TemplateInfo.TemplateParams->data(),
+ TemplateInfo.TemplateParams->size()),
+ D)
+ : Actions.ActOnStartOfFunctionDef(CurScope, D);
if (Tok.is(tok::kw_try))
return ParseFunctionTryBlock(Res);
diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h
index 23e12d80c98..699316efef6 100644
--- a/clang/lib/Sema/Sema.h
+++ b/clang/lib/Sema/Sema.h
@@ -2077,6 +2077,10 @@ public:
MultiTemplateParamsArg TemplateParameterLists,
Declarator &D);
+ virtual DeclPtrTy ActOnStartOfFunctionTemplateDef(Scope *FnBodyScope,
+ MultiTemplateParamsArg TemplateParameterLists,
+ Declarator &D);
+
virtual DeclResult
ActOnExplicitInstantiation(Scope *S, SourceLocation TemplateLoc,
unsigned TagSpec,
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 7c4cb60fd58..c319f7f9698 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -3037,6 +3037,8 @@ Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope,
}
Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) {
+ if (!D)
+ return D;
FunctionDecl *FD = cast<FunctionDecl>(D.getAs<Decl>());
CurFunctionNeedsScopeChecking = false;
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 4ecb44c3c5f..63696a13d3e 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -2507,6 +2507,27 @@ Sema::ActOnTemplateDeclarator(Scope *S,
return HandleDeclarator(S, D, move(TemplateParameterLists), false);
}
+Sema::DeclPtrTy
+Sema::ActOnStartOfFunctionTemplateDef(Scope *FnBodyScope,
+ MultiTemplateParamsArg TemplateParameterLists,
+ Declarator &D) {
+ assert(getCurFunctionDecl() == 0 && "Function parsing confused");
+ assert(D.getTypeObject(0).Kind == DeclaratorChunk::Function &&
+ "Not a function declarator!");
+ DeclaratorChunk::FunctionTypeInfo &FTI = D.getTypeObject(0).Fun;
+
+ if (FTI.hasPrototype) {
+ // FIXME: Diagnose arguments without names in C.
+ }
+
+ Scope *ParentScope = FnBodyScope->getParent();
+
+ DeclPtrTy DP = HandleDeclarator(ParentScope, D,
+ move(TemplateParameterLists),
+ /*IsFunctionDefinition=*/true);
+ return ActOnStartOfFunctionDef(FnBodyScope, DP);
+}
+
// Explicit instantiation of a class template specialization
Sema::DeclResult
Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation TemplateLoc,
OpenPOWER on IntegriCloud