PR c++/84355 - ICE with deduction for member class template.
authorJason Merrill <jason@redhat.com>
Mon, 12 Mar 2018 14:40:45 +0000 (10:40 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 12 Mar 2018 14:40:45 +0000 (10:40 -0400)
* pt.c (tsubst) [TEMPLATE_TYPE_PARM]: Always substitute into
CLASS_PLACEHOLDER_TEMPLATE.

From-SVN: r258451

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp1z/class-deduction50.C [new file with mode: 0644]

index 703f5970cff6a5380563ddd6d0419171f6b13cbb..e2373b20064f5640ff8db68ad38585f86382bdce 100644 (file)
@@ -1,5 +1,9 @@
 2018-03-12  Jason Merrill  <jason@redhat.com>
 
+       PR c++/84355 - ICE with deduction for member class template.
+       * pt.c (tsubst) [TEMPLATE_TYPE_PARM]: Always substitute into
+       CLASS_PLACEHOLDER_TEMPLATE.
+
        PR c++/84802 - ICE capturing uninstantiated class.
        * lambda.c (build_capture_proxy): Call complete_type.
 
index a92b36a60318422823c958fcd18a7893cbe9853d..4640ca08ce003188dbe6057ddd7ee1d4989a03dd 100644 (file)
@@ -14125,8 +14125,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
                        = tsubst_constraint (constr, args, complain, in_decl);
                    else if (tree pl = CLASS_PLACEHOLDER_TEMPLATE (t))
                      {
-                       if (DECL_TEMPLATE_TEMPLATE_PARM_P (pl))
-                         pl = tsubst (pl, args, complain, in_decl);
+                       pl = tsubst_copy (pl, args, complain, in_decl);
                        CLASS_PLACEHOLDER_TEMPLATE (r) = pl;
                      }
                  }
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction50.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction50.C
new file mode 100644 (file)
index 0000000..e8cdd8c
--- /dev/null
@@ -0,0 +1,22 @@
+// PR c++/84355
+// { dg-additional-options -std=c++17 }
+
+template <class, class> struct same;
+template <class T> struct same<T,T> {};
+
+template<typename T> struct A
+{
+  template<class U> struct B
+  {
+    B(U);
+  };
+
+  A() {
+    B b(0);
+    same<decltype(b),B<int>>{};
+  }
+};
+
+struct C {};
+
+A<C> a;