This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/23722] bad error recovery with if blocks and else
- From: "manu at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 Nov 2007 19:19:32 -0000
- Subject: [Bug c/23722] bad error recovery with if blocks and else
- References: <bug-23722-6528@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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