diff mbox series

[C++] PR c++/88869 - C++17 ICE with CTAD and explicit specialization.

Message ID 20190222020708.23699-1-jason@redhat.com
State New
Headers show
Series [C++] PR c++/88869 - C++17 ICE with CTAD and explicit specialization. | expand

Commit Message

Jason Merrill Feb. 22, 2019, 2:07 a.m. UTC
The members of an explicit specialization of a class template don't have the
template parameters of that class template, so we shouldn't try to provide
arguments for them.  Only set outer_args when the class is an instantiation.

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

	* pt.c (do_class_deduction): Don't include explicit specialization
	args in outer_args.
---
 gcc/cp/pt.c                                    |  2 +-
 gcc/testsuite/g++.dg/cpp1z/class-deduction63.C | 11 +++++++++++
 gcc/cp/ChangeLog                               |  4 ++++
 3 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp1z/class-deduction63.C


base-commit: b6700c1afdd5e39fe9e886578f8404dc53390f74
diff mbox series

Patch

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 76fb625a068..42dd095a6b0 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -27224,7 +27224,7 @@  do_class_deduction (tree ptype, tree tmpl, tree init, int flags,
 
   tree outer_args = NULL_TREE;
   if (DECL_CLASS_SCOPE_P (tmpl)
-      && CLASSTYPE_TEMPLATE_INFO (DECL_CONTEXT (tmpl)))
+      && CLASSTYPE_TEMPLATE_INSTANTIATION (DECL_CONTEXT (tmpl)))
     {
       outer_args = CLASSTYPE_TI_ARGS (DECL_CONTEXT (tmpl));
       type = TREE_TYPE (most_general_template (tmpl));
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction63.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction63.C
new file mode 100644
index 00000000000..4fc66fcbe15
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction63.C
@@ -0,0 +1,11 @@ 
+// PR c++/88869
+// { dg-do compile { target c++17 } }
+
+template <typename> struct B;
+template <> struct B<int> {
+  template <typename T> struct C {
+    T e;
+    C (T f) : e(f) {}
+  };
+  void foo () { C c (42); }
+};
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 2f99f2b95c8..013bca59380 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@ 
 2019-02-21  Jason Merrill  <jason@redhat.com>
 
+	PR c++/88869 - C++17 ICE with CTAD and explicit specialization.
+	* pt.c (do_class_deduction): Don't include explicit specialization
+	args in outer_args.
+
 	PR c++/89422 - ICE with -g and lambda in default arg in template.
 	* pt.c (tsubst_function_decl): SET_DECL_FRIEND_CONTEXT sooner.