Properly instantiate friend class template declarations and link them into
the redeclaration chain.  Recommitted from r99477 with a fix:  we need to
merge in default template arguments from previous declarations.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99496 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaTemplate/friend-template.cpp b/test/SemaTemplate/friend-template.cpp
index 8bc2631..6ee30aa 100644
--- a/test/SemaTemplate/friend-template.cpp
+++ b/test/SemaTemplate/friend-template.cpp
@@ -74,12 +74,16 @@
   template<typename T>
   class X3 {
     template<typename U, U Value> friend struct X2a;
-    template<typename U, T Value> friend struct X2b;
+
+    // FIXME: the redeclaration note ends up here because redeclaration
+    // lookup ends up finding the friend target from X3<int>.
+    template<typename U, T Value> friend struct X2b; // expected-error {{template non-type parameter has a different type 'long' in template redeclaration}} \
+      // expected-note {{previous non-type template parameter with type 'int' is here}}
   };
 
   X3<int> x3i; // okay
 
-  X3<long> x3l; // FIXME: should cause an instantiation-time failure
+  X3<long> x3l; // expected-note {{in instantiation}}
 }
 
 // PR5716