This is the mail archive of the
mailing list for the GCC project.
Re: [patch] Fix PR c++/19980: ICE on invalid template declaration
- From: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>
- To: mark at codesourcery dot com
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 22 Feb 2005 11:29:21 +0100 (CET)
- Subject: Re: [patch] Fix PR c++/19980: ICE on invalid template declaration
On 20 Feb, Mark Mitchell wrote:
> Volker Reichelt wrote:
>> This is due to a problem in start_preparsed_function: When processing
>> the template declaration the call "push_template_decl (decl1);"
>> returns an error_mark_node, since "foo" is already declared as "int".
>> Since the error_mark_node is not handled, things go downhill from here.
> The right fix for this might really be to have start_preparsed function
> return false in this case (it presently does not have a return value),
> after popping any pushed context, and then have callers skip the body of
> the function. Trying to actually do anything in the body of such a
> function is risky.
> But, that's too complicated for Stage 3. Your patch is OK.
How about adding a comment to the patch?
--- gcc/gcc/cp/decl.c 27 Jan 2005 07:32:20 -0000 1.1355
+++ gcc/gcc/cp/decl.c 15 Feb 2005 19:18:28 -0000
@@ -9917,7 +9917,12 @@ start_preparsed_function (tree decl1, tr
class scope, current_class_type will be NULL_TREE until set above
by push_nested_class.) */
- decl1 = push_template_decl (decl1);
+ /* FIXME: Handle error_mark_node more gracefully. */
+ 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;