When mapping from an injected-class-name to its corresponding
template, make sure to get the template that corresponds to *this*
declaration of the class template or specialization, rather than the
canonical specialization. Fixes PR5187.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84119 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaTemplate/default-arguments.cpp b/test/SemaTemplate/default-arguments.cpp
index f9bb44e..33677aa 100644
--- a/test/SemaTemplate/default-arguments.cpp
+++ b/test/SemaTemplate/default-arguments.cpp
@@ -22,3 +22,23 @@
 
 template struct p<bool>; // expected-note {{in instantiation of default argument for 'p<bool>' required here}}
 template struct p<int>;
+
+// PR5187
+template<typename T, typename U>
+struct A;
+
+template<typename T, typename U = T>
+struct A;
+
+template<typename T, typename U>
+struct A {
+  void f(A<T>);
+};
+
+template<typename T>
+struct B { };
+
+template<>
+struct B<void> {
+  typedef B<void*> type;
+};