If we run into multiple errors within the same template instantiation,
only print the template instantiation backtrace for the first error.

Also, if a base class has failed to type-check during instantiation,
just drop that base class and continue on to check other base classes.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66563 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index 4a12b07..057b256 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -56,7 +56,10 @@
 
 /// \brief Post-diagnostic hook for printing the instantiation stack.
 void Sema::PrintInstantiationStackHook(unsigned, void *Cookie) {
-  static_cast<Sema*>(Cookie)->PrintInstantiationStack();
+  Sema &SemaRef = *static_cast<Sema*>(Cookie);
+  SemaRef.PrintInstantiationStack();
+  SemaRef.LastTemplateInstantiationErrorContext 
+    = SemaRef.ActiveTemplateInstantiations.back().Entity;
 }
 
 /// \brief Prints the current instantiation stack through a series of
@@ -503,7 +506,7 @@
   for (ClassTemplateSpecializationDecl::base_class_iterator
          Base = ClassTemplate->getTemplatedDecl()->bases_begin(),
          BaseEnd = ClassTemplate->getTemplatedDecl()->bases_end();
-       Base != BaseEnd && !Invalid; ++Base) {
+       Base != BaseEnd; ++Base) {
     if (!Base->getType()->isDependentType()) {
       // FIXME: Allocate via ASTContext
       InstantiatedBases.push_back(new CXXBaseSpecifier(*Base));
@@ -533,7 +536,8 @@
       Invalid = true;
   }
 
-  if (AttachBaseSpecifiers(ClassTemplateSpec, &InstantiatedBases[0],
+  if (!Invalid &&
+      AttachBaseSpecifiers(ClassTemplateSpec, &InstantiatedBases[0],
                            InstantiatedBases.size()))
     Invalid = true;