This is the mail archive of the gcc-patches@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]

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


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.
However, such function could become handy in order error-recovery
situations.

Thoughts?

Thanks,

Manuel.

Attachment: fix-pr23722.diff
Description: Text document


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