From 9ce387d9cfcf19b04ca6e95d3c16e44cdf31f01c Mon Sep 17 00:00:00 2001 From: Volker Reichelt Date: Mon, 28 Aug 2006 22:34:55 +0000 Subject: re PR c++/28860 (Trouble with bound template template parameter in specialization) PR c++/28860 * cp-tree.h (maybe_process_partial_specialization): Return tree instead of void. * parser.c (cp_parser_class_head): Use return value of maybe_process_partial_specialization. * pt.c (maybe_process_partial_specialization): Return error_mark_node for broken specializations, TYPE otherwise. Check for template template parameters. * g++.dg/template/ttp22.C: New test. From-SVN: r116541 --- gcc/cp/ChangeLog | 11 +++++++++++ gcc/cp/cp-tree.h | 2 +- gcc/cp/parser.c | 2 +- gcc/cp/pt.c | 18 +++++++++++++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/ttp22.C | 8 ++++++++ 6 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/ttp22.C (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 369a678..8b7eae9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,14 @@ +2006-08-28 Volker Reichelt + + PR c++/28860 + * cp-tree.h (maybe_process_partial_specialization): Return + tree instead of void. + * parser.c (cp_parser_class_head): Use return value of + maybe_process_partial_specialization. + * pt.c (maybe_process_partial_specialization): Return error_mark_node + for broken specializations, TYPE otherwise. Check for template + template parameters. + 2006-08-27 Mark Mitchell PR c++/28058 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index c50836b..3c20afe 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4111,7 +4111,7 @@ extern int template_class_depth (tree); extern int is_specialization_of (tree, tree); extern bool is_specialization_of_friend (tree, tree); extern int comp_template_args (tree, tree); -extern void maybe_process_partial_specialization (tree); +extern tree maybe_process_partial_specialization (tree); extern tree most_specialized_instantiation (tree); extern void print_candidates (tree); extern void instantiate_pending_templates (int); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index a97518a..5271113 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -13287,7 +13287,7 @@ cp_parser_class_head (cp_parser* parser, if (template_id_p) { type = TREE_TYPE (id); - maybe_process_partial_specialization (type); + type = maybe_process_partial_specialization (type); if (nested_name_specifier) pushed_scope = push_scope (nested_name_specifier); } diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 17557c0..79d9de4 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -673,13 +673,20 @@ check_explicit_instantiation_namespace (tree spec) /* The TYPE is being declared. If it is a template type, that means it is a partial specialization. Do appropriate error-checking. */ -void +tree maybe_process_partial_specialization (tree type) { tree context; if (type == error_mark_node) - return; + return error_mark_node; + + if (TREE_CODE (type) == BOUND_TEMPLATE_TEMPLATE_PARM) + { + error ("name of class shadows template template parameter %qD", + TYPE_NAME (type)); + return error_mark_node; + } context = TYPE_CONTEXT (type); @@ -764,7 +771,12 @@ maybe_process_partial_specialization (tree type) } } else if (processing_specialization) - error ("explicit specialization of non-template %qT", type); + { + error ("explicit specialization of non-template %qT", type); + return error_mark_node; + } + + return type; } /* Returns nonzero if we can optimize the retrieval of specializations diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 767f94e..6e20431 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-08-28 Volker Reichelt + + PR c++/28860 + * g++.dg/template/ttp22.C: New test. + 2006-08-28 Kazu Hirata PR middle-end/26632 diff --git a/gcc/testsuite/g++.dg/template/ttp22.C b/gcc/testsuite/g++.dg/template/ttp22.C new file mode 100644 index 0000000..f344943 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/ttp22.C @@ -0,0 +1,8 @@ +// PR c++/28860 +// { dg-do compile} + +template class A> +class A<0>; // { dg-error "shadows template template parameter" } + +template class B> +class B<0> {}; // { dg-error "shadows template template parameter" } -- cgit v1.1