diff options
author | reichelt <reichelt@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-08-28 22:34:55 +0000 |
---|---|---|
committer | reichelt <reichelt@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-08-28 22:34:55 +0000 |
commit | 2ce07779975917f1891c39120b6ba1e06e451635 (patch) | |
tree | ab647b9e6bbd47a98a10082b10f51c8bcbec667d | |
parent | 58f43b9022418d659bfa7c3600662fdecd313774 (diff) |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116541 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 2 | ||||
-rw-r--r-- | gcc/cp/parser.c | 2 | ||||
-rw-r--r-- | gcc/cp/pt.c | 18 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/ttp22.C | 8 |
6 files changed, 41 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 369a678036a..8b7eae9dfb9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,14 @@ +2006-08-28 Volker Reichelt <reichelt@igpm.rwth-aachen.de> + + 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 <mark@codesourcery.com> PR c++/28058 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index c50836b0be0..3c20afed5ec 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 a97518ac9a5..5271113485a 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 17557c0fffa..79d9de4e4ce 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 767f94e3a84..6e2043195bc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-08-28 Volker Reichelt <reichelt@igpm.rwth-aachen.de> + + PR c++/28860 + * g++.dg/template/ttp22.C: New test. + 2006-08-28 Kazu Hirata <kazu@codesourcery.com> 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 00000000000..f3449435f4b --- /dev/null +++ b/gcc/testsuite/g++.dg/template/ttp22.C @@ -0,0 +1,8 @@ +// PR c++/28860 +// { dg-do compile} + +template<template<int> class A> +class A<0>; // { dg-error "shadows template template parameter" } + +template<template<int> class B> +class B<0> {}; // { dg-error "shadows template template parameter" } |