Fix a bug which creduce found reducing PR12585.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155185 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index ff8c4da..a0b996b 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -938,7 +938,7 @@
       while (!OutermostContext->isFileContext())
         OutermostContext = OutermostContext->getLookupParent();
 
-      if (PrevDecl &&
+      if (PrevClassTemplate &&
           (OutermostContext->Equals(PrevDecl->getDeclContext()) ||
            OutermostContext->Encloses(PrevDecl->getDeclContext()))) {
         SemanticContext = PrevDecl->getDeclContext();