Implement out-of-line definitions of nested class templates. Most of
the logic is there for out-of-line definitions with multiple levels of
nested templates, but this is still a work-in-progress: we're having
trouble determining when we should look into a dependent
nested-name-specifier. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80003 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 99c1338..ee6238c 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -2106,11 +2106,6 @@
     }
   }
         
-  // Check that we can declare a template here.
-  if (TemplateParamLists.size() && 
-      CheckTemplateDeclScope(S, TemplateParamLists))
-    return 0;
-  
   // Match up the template parameter lists with the scope specifier, then
   // determine whether we have a template or a template specialization.
   if (TemplateParameterList *TemplateParams
@@ -2391,11 +2386,6 @@
     D.setInvalidType();
   }
 
-  // Check that we can declare a template here.
-  if (TemplateParamLists.size() && 
-      CheckTemplateDeclScope(S, TemplateParamLists))
-    return 0;
-  
   bool isVirtualOkay = false;
   FunctionDecl *NewFD;
   if (isFriend) {
@@ -2515,6 +2505,11 @@
                                                   TemplateParamLists.size())) {
     if (TemplateParams->size() > 0) {
       // This is a function template
+      
+      // Check that we can declare a template here.
+      if (CheckTemplateDeclScope(S, TemplateParams))
+        return 0;
+      
       FunctionTemplate = FunctionTemplateDecl::Create(Context, CurContext,
                                                       NewFD->getLocation(),
                                                       Name, TemplateParams,
@@ -3960,8 +3955,9 @@
         OwnedDecl = false;
         DeclResult Result = CheckClassTemplate(S, TagSpec, TUK, KWLoc,
                                                SS, Name, NameLoc, Attr,
-                                               move(TemplateParameterLists),
+                                               TemplateParams,
                                                AS);
+        TemplateParameterLists.release();
         return Result.get();
       } else {
         // FIXME: diagnose the extraneous 'template<>', once we recover