[Bug c/23722] bad error recovery with if blocks and else
manu at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Wed Nov 7 19:19:00 GMT 2007
------- Comment #2 from manu at gcc dot gnu dot org 2007-11-07 19:19 -------
Created an attachment (id=14500)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14500&action=view)
possible patch
This patch does two things I would like someone to comment on:
* Add a bit 'in_if_stmt' to c_parser to be able to tell whether the body of an
'if' statement is being parsed.
* Replace 'else' with '}' in order to balance the braces and parse the body of
'else' in the following way:
+ parser->tokens[0].type = CPP_CLOSE_BRACE;
Ideally, I would like to push a '}' before 'else' but I don't know how to do
that properly and I am not sure such a patch would be approved. But I am sure
such a function could become handy in order error-recovery situations.
Thoughts?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23722
More information about the Gcc-bugs
mailing list