From: jakub Date: Tue, 20 Nov 2007 16:19:40 +0000 (+0000) Subject: PR c++/34089 X-Git-Tag: upstream/4.9.2~44986 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=04a3504e617a1fe02e015a5cdc946715ed4d9050;p=platform%2Fupstream%2Flinaro-gcc.git PR c++/34089 * parser.c (cp_parser_class_head): Reject function template ids. * g++.dg/template/crash74.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130316 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b7c7661..a8025f2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2007-11-20 Jakub Jelinek + PR c++/34089 + * parser.c (cp_parser_class_head): Reject function template ids. + PR c++/28879 * tree.c (build_cplus_array_type_1): Don't pass any VLA types when processing_template_decl to build_array_type. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 41cb26e..8e16d22 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -14536,8 +14536,18 @@ cp_parser_class_head (cp_parser* parser, /* Look up the type. */ if (template_id_p) { - type = TREE_TYPE (id); - type = maybe_process_partial_specialization (type); + if (TREE_CODE (id) == TEMPLATE_ID_EXPR + && (DECL_FUNCTION_TEMPLATE_P (TREE_OPERAND (id, 0)) + || TREE_CODE (TREE_OPERAND (id, 0)) == OVERLOAD)) + { + error ("function template %qD redeclared as a class template", id); + type = error_mark_node; + } + else + { + type = TREE_TYPE (id); + type = maybe_process_partial_specialization (type); + } if (nested_name_specifier) pushed_scope = push_scope (nested_name_specifier); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3ad61fd..18413b3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-11-20 Jakub Jelinek + + PR c++/34089 + * g++.dg/template/crash74.C: New test. + 2007-11-20 Richard Guenther * gcc.c-torture/execute/20071120-1.c: New testcase. diff --git a/gcc/testsuite/g++.dg/template/crash74.C b/gcc/testsuite/g++.dg/template/crash74.C new file mode 100644 index 0000000..9f2e415 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash74.C @@ -0,0 +1,6 @@ +// PR c++/34089 +// { dg-do compile } +// { dg-options "" } + +template void foo () { } +template struct foo { }; // { dg-error "redeclared as" }