Patchwork C++ PATCH for c++/56971 (ICE with friend template and template template parameter)

login
register
mail settings
Submitter Jason Merrill
Date May 24, 2013, 8:03 p.m.
Message ID <519FC77D.9060702@redhat.com>
Download mbox | patch
Permalink /patch/246283/
State New
Headers show

Comments

Jason Merrill - May 24, 2013, 8:03 p.m.
We do in fact set TYPE_STRUCTURAL_EQUALITY_P on TEMPLATE_TEMPLATE_PARM, 
so we can't assume it isn't set.

Tested x86_64-pc-linux-gnu, applying to trunk.

Patch

commit affd3dcbcfeeda70db2413f19948dfd039ce0a0a
Author: Jason Merrill <jason@redhat.com>
Date:   Fri May 24 13:52:31 2013 -0400

    	PR c++/56971
    	* pt.c (any_template_arguments_need_structural_equality_p): A
    	TEMPLATE_TEMPLATE_PARM can require structural type comparison.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index f861f4c..fb2fe2a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -20397,8 +20397,7 @@  any_template_arguments_need_structural_equality_p (tree args)
 
 	      if (error_operand_p (arg))
 		return true;
-	      else if (TREE_CODE (arg) == TEMPLATE_DECL
-		       || TREE_CODE (arg) == TEMPLATE_TEMPLATE_PARM)
+	      else if (TREE_CODE (arg) == TEMPLATE_DECL)
 		continue;
 	      else if (TYPE_P (arg) && TYPE_STRUCTURAL_EQUALITY_P (arg))
 		return true;
diff --git a/gcc/testsuite/g++.dg/template/ttp28.C b/gcc/testsuite/g++.dg/template/ttp28.C
new file mode 100644
index 0000000..a15dea1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/ttp28.C
@@ -0,0 +1,21 @@ 
+// PR c++/56971
+
+template <typename T>
+class rp {
+};
+
+template <template <typename> class P>
+struct b {
+    template <class, template <typename> class FriendP>
+    friend void f(b<FriendP> from);
+};
+
+template <class, template <typename> class P>
+void f(b<P> from) {
+}
+
+int main() {
+    b<rp> v;
+    f<int>(v);
+    return 0;
+}