Implement the basic approach for instantiating types, with a lot of FIXME'd
stubs for those types we don't yet know how to instantiate (everything
that isn't a template parameter!).

We now instantiate default arguments for template type parameters when
needed. This will be our testbed while I fill out the remaining
type-instantiation logic.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65649 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index 5b2e89e..aabbffa 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -5,11 +5,11 @@
 //
 // This file is distributed under the University of Illinois Open Source
 // License. See LICENSE.TXT for details.
-//+//===----------------------------------------------------------------------===/
+//===----------------------------------------------------------------------===/
 
 //
 //  This file implements semantic analysis for C++ templates.
-//+//===----------------------------------------------------------------------===/
+//===----------------------------------------------------------------------===/
 
 #include "Sema.h"
 #include "clang/AST/ASTContext.h"
@@ -757,6 +757,17 @@
           break;
 
         ArgType = TTP->getDefaultArgument();
+
+        // If the argument type is dependent, instantiate it now based
+        // on the previously-computed template arguments.
+        if (ArgType->isDependentType())
+          ArgType = InstantiateType(ArgType, &Converted[0], Converted.size(),
+                                    TTP->getDefaultArgumentLoc(),
+                                    TTP->getDeclName());
+
+        if (ArgType.isNull())
+          break;
+
         ArgLoc = TTP->getDefaultArgumentLoc();
       } else if (NonTypeTemplateParmDecl *NTTP 
                    = dyn_cast<NonTypeTemplateParmDecl>(*Param)) {