Extend the notion of active template instantiations to include the
context of a template-id for which we need to instantiate default
template arguments.

In the TextDiagnosticPrinter, don't suppress the caret diagnostic if
we are producing a non-note diagnostic that follows a note diagnostic
with the same location, because notes are (conceptually) a part of the
warning or error that comes before them.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66572 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index fc1173d..ea91a38 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -825,10 +825,15 @@
 
         // If the argument type is dependent, instantiate it now based
         // on the previously-computed template arguments.
-        if (ArgType->isDependentType())
+        if (ArgType->isDependentType()) {
+          InstantiatingTemplate Inst(*this, TemplateLoc, 
+                                     Template, &Converted[0], 
+                                     Converted.size(),
+                                     SourceRange(TemplateLoc, RAngleLoc));
           ArgType = InstantiateType(ArgType, &Converted[0], Converted.size(),
                                     TTP->getDefaultArgumentLoc(),
                                     TTP->getDeclName());
+        }
 
         if (ArgType.isNull())
           return true;
@@ -888,6 +893,11 @@
       QualType NTTPType = NTTP->getType();
       if (NTTPType->isDependentType()) {
         // Instantiate the type of the non-type template parameter.
+        InstantiatingTemplate Inst(*this, TemplateLoc, 
+                                   Template, &Converted[0], 
+                                   Converted.size(),
+                                   SourceRange(TemplateLoc, RAngleLoc));
+
         NTTPType = InstantiateType(NTTPType, 
                                    &Converted[0], Converted.size(),
                                    NTTP->getLocation(),