Make sure that the template parameter lists get from the parser down to ActOnFunctionDeclarator for function template definitions

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74040 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index 23e12d8..699316e 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -2077,6 +2077,10 @@
                                   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/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 7c4cb60..c319f7f 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -3037,6 +3037,8 @@
 }
 
 Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) {
+  if (!D)
+    return D;
   FunctionDecl *FD = cast<FunctionDecl>(D.getAs<Decl>());
 
   CurFunctionNeedsScopeChecking = false;
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index 4ecb44c..63696a1 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -2507,6 +2507,27 @@
   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,