Fix regression in r332076.

If the name after 'template' is an unresolved using declaration (not containing
'typename'), then we don't yet know if it's a valid template-name, so don't
reject it prior to instantiation. Instead, treat it as naming a dependent
member of the current instantiation.

llvm-svn: 332291
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index b2ac7d9..530fc66 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -105,6 +105,12 @@
     return nullptr;
   }
 
+  // 'using Dependent::foo;' can resolve to a template name.
+  // 'using typename Dependent::foo;' cannot (not even if 'foo' is an
+  // injected-class-name).
+  if (isa<UnresolvedUsingValueDecl>(D))
+    return D;
+
   return nullptr;
 }
 
@@ -214,6 +220,10 @@
 
     // We'll do this lookup again later.
     R.suppressDiagnostics();
+  } else if (isa<UnresolvedUsingValueDecl>((*R.begin())->getUnderlyingDecl())) {
+    // We don't yet know whether this is a template-name or not.
+    MemberOfUnknownSpecialization = true;
+    return TNK_Non_template;
   } else {
     TemplateDecl *TD = cast<TemplateDecl>((*R.begin())->getUnderlyingDecl());
 
@@ -429,7 +439,7 @@
     if (ExampleLookupResult && TemplateKWLoc.isValid()) {
       Diag(Found.getNameLoc(), diag::err_template_kw_refers_to_non_template)
         << Found.getLookupName() << SS.getRange();
-      Diag(ExampleLookupResult->getLocation(),
+      Diag(ExampleLookupResult->getUnderlyingDecl()->getLocation(),
            diag::note_template_kw_refers_to_non_template)
           << Found.getLookupName();
       return true;