re PR c++/68170 (Declaring friend template class template in C++1z produces error...
authorJason Merrill <jason@redhat.com>
Mon, 7 Dec 2015 19:34:04 +0000 (14:34 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 7 Dec 2015 19:34:04 +0000 (14:34 -0500)
PR c++/68170
* pt.c (maybe_new_partial_specialization): The injected-class-name
is not a new partial specialization.

From-SVN: r231380

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/template/friend60.C [new file with mode: 0644]

index 7381a756278568757bdb512c97a7c8d14b88b9c5..7c045e3ab269699d2d385975d75461e29ff53910 100644 (file)
@@ -1,5 +1,9 @@
 2015-12-07  Jason Merrill  <jason@redhat.com>
 
+       PR c++/68170
+       * pt.c (maybe_new_partial_specialization): The injected-class-name
+       is not a new partial specialization.
+
        * Make-lang.in (check-c++1z, check-c++-all): Use GXX_TESTSUITE_STDS.
 
 2015-12-06  Jason Merrill  <jason@redhat.com>
index 22dcee281ba5baabdb3bee6a94416f09baec3d47..60cc94c2aac4c8d766db5d00164fa80ee7786152 100644 (file)
@@ -855,6 +855,10 @@ maybe_new_partial_specialization (tree type)
       if (!current_template_parms)
         return NULL_TREE;
 
+      // The injected-class-name is not a new partial specialization.
+      if (DECL_SELF_REFERENCE_P (TYPE_NAME (type)))
+       return NULL_TREE;
+
       // If the constraints are not the same as those of the primary
       // then, we can probably create a new specialization.
       tree type_constr = current_template_constraints ();
diff --git a/gcc/testsuite/g++.dg/template/friend60.C b/gcc/testsuite/g++.dg/template/friend60.C
new file mode 100644 (file)
index 0000000..5ba9ab2
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/68170
+
+template< typename T >
+class A
+{
+};
+
+template<>
+class A< void >
+{
+  template< typename X >
+  friend class A;
+};