Blob Blame History Raw
2018-12-06  Alexandre Oliva <aoliva@redhat.com>
 
	PR c++/86747
	* pt.c (tsubst_friend_class): Enter tsubsted class context.

--- gcc/cp/pt.c
+++ gcc/cp/pt.c
@@ -10558,7 +10558,10 @@ tsubst_friend_class (tree friend_tmpl, tree args)
   if (TREE_CODE (context) == NAMESPACE_DECL)
     push_nested_namespace (context);
   else
-    push_nested_class (context);
+    {
+      context = tsubst (context, args, tf_error, NULL_TREE);
+      push_nested_class (context);
+    }
 
   tmpl = lookup_name_real (DECL_NAME (friend_tmpl), /*prefer_type=*/false,
 			   /*non_class=*/false, /*block_p=*/false,
--- /dev/null
+++ gcc/testsuite/g++.dg/pr86747.C
@@ -0,0 +1,8 @@
+// { dg-do compile }
+
+template <typename T> class A {
+  template <void (A::*p)()> class C; // #1
+  template <void (A::*q)()> friend class C; // #2
+};
+
+A<double> a;