aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2019-03-07 11:15:56 -0500
committerJason Merrill <jason@gcc.gnu.org>2019-03-07 11:15:56 -0500
commitae9b289201b6c6996b9c701109658adfb551327b (patch)
tree5904b313fcc2c714fdec4164b5f849dbbd1a1188 /gcc
parent1738b52201b1ce28c9f869646f5412b8937ccfe6 (diff)
downloadgcc-ae9b289201b6c6996b9c701109658adfb551327b.zip
gcc-ae9b289201b6c6996b9c701109658adfb551327b.tar.gz
gcc-ae9b289201b6c6996b9c701109658adfb551327b.tar.bz2
PR c++/88820 - ICE with CTAD and member template used in DMI.
Here the problem was that in order to form a FUNCTION_DECL for foo<int> in the uninstantiated template, we were trying to deduce template args for S from the template parm itself, and failing. * pt.c (do_class_deduction): Handle parm used as its own arg. From-SVN: r269463
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/pt.c3
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/class-deduction64.C9
3 files changed, 17 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c2162a4..94e278d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2019-03-07 Jason Merrill <jason@redhat.com>
+
+ PR c++/88820 - ICE with CTAD and member template used in DMI.
+ * pt.c (do_class_deduction): Handle parm used as its own arg.
+
2019-03-07 Jakub Jelinek <jakub@redhat.com>
PR c++/89585
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 8a5a0b3..906cfe0 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -27184,6 +27184,9 @@ do_class_deduction (tree ptype, tree tmpl, tree init, int flags,
error ("non-class template %qT used without template arguments", tmpl);
return error_mark_node;
}
+ if (init && TREE_TYPE (init) == ptype)
+ /* Using the template parm as its own argument. */
+ return ptype;
tree type = TREE_TYPE (tmpl);
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction64.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction64.C
new file mode 100644
index 0000000..3a06e6f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction64.C
@@ -0,0 +1,9 @@
+// PR c++/88820
+// { dg-do compile { target c++17 } }
+
+template <int> struct S;
+
+template <S> struct W {
+ template <typename> static int foo();
+ bool b = foo<int>();
+};