When looking for the instantiated declaration that corresponds to a
given declaration in a template, make sure that the context we're
searching through is complete. Fixes PR6376.

llvm-svn: 97444
diff --git a/clang/test/SemaTemplate/instantiate-complete.cpp b/clang/test/SemaTemplate/instantiate-complete.cpp
index 183fefa..0ae13b9 100644
--- a/clang/test/SemaTemplate/instantiate-complete.cpp
+++ b/clang/test/SemaTemplate/instantiate-complete.cpp
@@ -66,3 +66,20 @@
 void enum_constructors(X1<float> &x1) {
   X3<X1<float> > x3 = x1;
 }
+
+namespace PR6376 {
+  template<typename T, typename U> struct W { };
+
+  template<typename T>
+  struct X {
+    template<typename U>
+    struct apply {
+      typedef W<T, U> type;
+    };
+  };
+  
+  template<typename T, typename U>
+  struct Y : public X<T>::template apply<U>::type { };
+
+  template struct Y<int, float>;
+}