]> git.ipfire.org Git - thirdparty/gcc.git/commit
re PR c/23722 (bad error recovery with if blocks and else)
authorManuel López-Ibáñez <manu@gcc.gnu.org>
Mon, 26 Nov 2007 19:01:54 +0000 (19:01 +0000)
committerManuel López-Ibáñez <manu@gcc.gnu.org>
Mon, 26 Nov 2007 19:01:54 +0000 (19:01 +0000)
commitb4b560332c6978dde1aafaff5cbca1a4347cd718
tree3aa88863b57e5e2d234313c7a65fb6d464e0d2ee
parent0e7edcd5ebda4d219143e42f6daaa9633779e71b
re PR c/23722 (bad error recovery with if blocks and else)

2007-11-26  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

PR c/23722
* c-parser.c (struct c_parser): New bit in_if_block.
(c_parser_compound_statement_nostart): Handle unexpected 'else'
keyword.
(c_parser_statement_after_labels): Set in_if_block to false while
parsing.
(c_parser_if_body): Don't call c_parser_statement_after_labels if
a semicolon is found, just consume it. Don't call
c_parser_statement_after_labels if an open brace is found, call
c_parser_compound_statement instead.
(c_parser_else_body): New.
(c_parser_if_statement): Set in_if_block to true when parsing the
body of the 'if' statement. Use c_parser_else_body.

testsuite/
* gcc.dg/cpp/19990413-1.c: Update.
* gcc.dg/parse-else-error.c: New.
* gcc.dg/parse-else-error-2.c: New.
* gcc.dg/parse-else-error-3.c: New.
* gcc.dg/parse-else-error-4.c: New.

From-SVN: r130446
gcc/ChangeLog
gcc/c-parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cpp/19990413-1.c
gcc/testsuite/gcc.dg/parse-else-error-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/parse-else-error-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/parse-else-error-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/parse-else-error.c [new file with mode: 0644]