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/test/CXX/drs/dr1xx.cpp b/clang/test/CXX/drs/dr1xx.cpp
index 1507c67..a925011 100644
--- a/clang/test/CXX/drs/dr1xx.cpp
+++ b/clang/test/CXX/drs/dr1xx.cpp
@@ -71,8 +71,7 @@
     using T::template f<int>; // expected-error {{'template' keyword not permitted here}} expected-error {{using declaration cannot refer to a template specialization}}
     // FIXME: We shouldn't suggest using the 'template' keyword in a location where it's not valid.
     using T::f<int>; // expected-error {{use 'template' keyword}} expected-error {{using declaration cannot refer to a template specialization}}
-    // FIXME: The first 'using' above introduces 'f' as a non-template member of 'B', leading to bad recovery:
-    void g() { this->f<int>(123); } // expected-error {{expected '('}}
+    void g() { this->f<int>(123); } // expected-error {{use 'template' keyword}}
   };
 }
 
diff --git a/clang/test/SemaTemplate/dependent-names.cpp b/clang/test/SemaTemplate/dependent-names.cpp
index 070c7e4..05ef33b 100644
--- a/clang/test/SemaTemplate/dependent-names.cpp
+++ b/clang/test/SemaTemplate/dependent-names.cpp
@@ -427,3 +427,23 @@
   };
   void g() { f<X>(); }
 }
+
+namespace DependentUnresolvedUsingTemplate {
+  template<typename T>
+  struct X : T {
+    using T::foo;
+    void f() { this->template foo(); } // expected-error {{does not refer to a template}}
+    void g() { this->template foo<>(); } // expected-error {{does not refer to a template}}
+    void h() { this->template foo<int>(); } // expected-error {{does not refer to a template}}
+  };
+  struct A { template<typename = int> int foo(); };
+  struct B { int foo(); }; // expected-note 3{{non-template here}}
+  void test(X<A> xa, X<B> xb) {
+    xa.f();
+    xa.g();
+    xa.h();
+    xb.f(); // expected-note {{instantiation of}}
+    xb.g(); // expected-note {{instantiation of}}
+    xb.h(); // expected-note {{instantiation of}}
+  }
+}