aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2012-12-06 09:37:04 -0500
committerJason Merrill <jason@gcc.gnu.org>2012-12-06 09:37:04 -0500
commitd8169a0d2a030e0b25fc545f535328b5adfaadec (patch)
tree2f21964d095b17cf337c7e6fbd439cf54e912a00
parent5128e01493b8f75a32b413c9ff504401a116b9ca (diff)
downloadgcc-d8169a0d2a030e0b25fc545f535328b5adfaadec.zip
gcc-d8169a0d2a030e0b25fc545f535328b5adfaadec.tar.gz
gcc-d8169a0d2a030e0b25fc545f535328b5adfaadec.tar.bz2
re PR c++/54653 (tsubst_template_parms ICE)
PR c++/54653 * parser.c (cp_parser_class_head): A partial specialization scope counts as a template. * pt.c (tsubst_template_parms): Handle template template parm parms. (tsubst_decl) [TEMPLATE_DECL]: Handle getting a template template argument back. From-SVN: r194249
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/parser.c3
-rw-r--r--gcc/cp/pt.c6
-rw-r--r--gcc/testsuite/g++.dg/template/partial-specialization2.C8
4 files changed, 22 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 917f3e9..04a71f2 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,12 @@
2012-12-06 Jason Merrill <jason@redhat.com>
+ PR c++/54653
+ * parser.c (cp_parser_class_head): A partial specialization scope
+ counts as a template.
+ * pt.c (tsubst_template_parms): Handle template template parm parms.
+ (tsubst_decl) [TEMPLATE_DECL]: Handle getting a template template
+ argument back.
+
PR c++/55564
* pt.c (unify) [ARRAY_TYPE]: Unify the element type before the bounds.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 1fe6246..190b8d9 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -18589,7 +18589,8 @@ cp_parser_class_head (cp_parser* parser,
&& CLASS_TYPE_P (scope)
&& CLASSTYPE_TEMPLATE_INFO (scope)
&& PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (scope))
- && !CLASSTYPE_TEMPLATE_SPECIALIZATION (scope))
+ && (!CLASSTYPE_TEMPLATE_SPECIALIZATION (scope)
+ || uses_template_parms (CLASSTYPE_TI_ARGS (scope))))
++num_templates;
}
}
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 27084a2..c1e12f0 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -9552,7 +9552,7 @@ tsubst_template_parms (tree parms, tree args, tsubst_flags_t complain)
++processing_template_decl;
for (new_parms = &r;
- TMPL_PARMS_DEPTH (parms) > TMPL_ARGS_DEPTH (args);
+ parms && TMPL_PARMS_DEPTH (parms) > TMPL_ARGS_DEPTH (args);
new_parms = &(TREE_CHAIN (*new_parms)),
parms = TREE_CHAIN (parms))
{
@@ -9831,6 +9831,10 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
tree new_type = tsubst (TREE_TYPE (t), args, complain, in_decl);
if (new_type == error_mark_node)
RETURN (error_mark_node);
+ /* If we get a real template back, return it. This can happen in
+ the context of most_specialized_class. */
+ if (TREE_CODE (new_type) == TEMPLATE_DECL)
+ return new_type;
r = copy_decl (t);
DECL_CHAIN (r) = NULL_TREE;
diff --git a/gcc/testsuite/g++.dg/template/partial-specialization2.C b/gcc/testsuite/g++.dg/template/partial-specialization2.C
new file mode 100644
index 0000000..c22d739
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/partial-specialization2.C
@@ -0,0 +1,8 @@
+// PR c++/54653
+
+template <class T> struct A;
+template <class T> struct A<T*> {
+ template <class U> struct B;
+};
+
+template <class T> struct A<T*>::B<T*> { }; // { dg-error "too few template-parameter-lists" }