From: Volker Reichelt Date: Mon, 28 Aug 2006 23:12:32 +0000 (+0000) Subject: re PR c++/28860 (Trouble with bound template template parameter in specialization) X-Git-Tag: releases/gcc-4.0.4~409 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3720c2d760a82d0c20d250e8723daf4e780fbb3;p=thirdparty%2Fgcc.git 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: r116544 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2079a2856886..c0363ef140ce 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-25 Volker Reichelt PR c++/28853 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 47db45f797e5..41a93910dcc6 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4041,7 +4041,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 13cf044cf0c8..5d04a2fedadd 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -13008,7 +13008,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 9f22cc367d8a..9ae563f50be8 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -676,13 +676,20 @@ check_specialization_namespace (tree tmpl) /* 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); @@ -767,7 +774,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 59b575f42789..f653f619a47a 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-25 Volker Reichelt PR c++/28853 diff --git a/gcc/testsuite/g++.dg/template/ttp22.C b/gcc/testsuite/g++.dg/template/ttp22.C new file mode 100644 index 000000000000..f3449435f4b0 --- /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" }