This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/23722] bad error recovery with if blocks and else



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]