From: Volker Reichelt Date: Fri, 2 Sep 2005 11:20:21 +0000 (+0000) Subject: re PR c++/22233 (ICE with wrong number of template parameters) X-Git-Tag: releases/gcc-3.4.5~215 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e0a29545b4ac43e1545c7c27e3dbed9f8487c87;p=thirdparty%2Fgcc.git re PR c++/22233 (ICE with wrong number of template parameters) PR c++/22233 * pt.c (push_template_decl_real): Return error_mark_node if the number of template parameters does not match previous definition. * decl.c (start_function): Handle error_mark_node returned by push_template_decl. * g++.dg/template/param1.C: New test. From-SVN: r103770 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 231698e8a674..6e489b597430 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2005-09-02 Volker Reichelt + + PR c++/22233 + * pt.c (push_template_decl_real): Return error_mark_node if the + number of template parameters does not match previous definition. + * decl.c (start_function): Handle error_mark_node returned by + push_template_decl. + 2005-09-02 Volker Reichelt Backport: diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 85aed90aee06..7381ae321228 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10320,7 +10320,11 @@ start_function (tree declspecs, tree declarator, tree attrs, int flags) class scope, current_class_type will be NULL_TREE until set above by push_nested_class.) */ if (processing_template_decl) - decl1 = push_template_decl (decl1); + { + tree newdecl1 = push_template_decl (decl1); + if (newdecl1 != error_mark_node) + decl1 = newdecl1; + } /* We are now in the scope of the function being defined. */ current_function_decl = decl1; diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c3c982485393..0db01ee65345 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -2978,6 +2978,7 @@ push_template_decl_real (tree decl, int is_friend) error ("got %d template parameters for `%#T'", TREE_VEC_LENGTH (a), current); error (" but %d required", TREE_VEC_LENGTH (t)); + return error_mark_node; } /* Perhaps we should also check that the parms are used in the diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 674838ccc102..c043043e9ec7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-09-02 Volker Reichelt + + PR c++/22233 + * g++.dg/template/param1.C: New test. + 2005-09-02 Volker Reichelt Backport: