aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2019-04-03 17:51:36 -0400
committerJason Merrill <jason@gcc.gnu.org>2019-04-03 17:51:36 -0400
commite53ec543e66382d2552e89077e05fe70e2a75c78 (patch)
treee07810196903d37d30a63e7b9caacb49b8c556d6 /gcc
parentc17bad5326d5f1f79207409e13e80ec61934ebfe (diff)
downloadgcc-e53ec543e66382d2552e89077e05fe70e2a75c78.zip
gcc-e53ec543e66382d2552e89077e05fe70e2a75c78.tar.gz
gcc-e53ec543e66382d2552e89077e05fe70e2a75c78.tar.bz2
PR c++/81866 - ICE with member template and default targ.
This testcase manages to find a way to look up the partial instantiation of B for the default argument of C before we've created the partial instantiation of B as part of the normal instantiation of the members of A. Which we can deal with, but we were getting confused because the partial instantiation was stored with a RECORD_TYPE specialization rather than TEMPLATE_DECL. * pt.c (tsubst_template_decl): Handle getting a type from retrieve_specialization. From-SVN: r270138
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/pt.c8
-rw-r--r--gcc/testsuite/g++.dg/template/memtmpl6.C13
3 files changed, 24 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 91d1431..888b431 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2019-04-03 Jason Merrill <jason@redhat.com>
+ PR c++/81866 - ICE with member template and default targ.
+ * pt.c (tsubst_template_decl): Handle getting a type from
+ retrieve_specialization.
+
PR c++/86586 - -fcompare-debug=-Wsign-compare.
* typeck.c (cp_build_binary_op): Don't fold for -Wsign-compare.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 2b92b60..9cb29d2 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -13266,7 +13266,13 @@ tsubst_template_decl (tree t, tree args, tsubst_flags_t complain,
hash = hash_tmpl_and_args (t, full_args);
spec = retrieve_specialization (t, full_args, hash);
if (spec != NULL_TREE)
- return spec;
+ {
+ if (TYPE_P (spec))
+ /* Type partial instantiations are stored as the type by
+ lookup_template_class_1, not here as the template. */
+ spec = CLASSTYPE_TI_TEMPLATE (spec);
+ return spec;
+ }
}
/* Make a new template decl. It will be similar to the
diff --git a/gcc/testsuite/g++.dg/template/memtmpl6.C b/gcc/testsuite/g++.dg/template/memtmpl6.C
new file mode 100644
index 0000000..9ce35ab
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/memtmpl6.C
@@ -0,0 +1,13 @@
+// PR c++/81866
+
+template<class>
+struct A {
+ template<class> struct C;
+ template<class> struct B;
+ template<class T = B<int> > struct C {};
+};
+
+int main() {
+ A<int>::C<> ac;
+ return 0;
+}