From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 120185 invoked by alias); 20 Dec 2016 08:51:51 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 120159 invoked by uid 89); 20 Dec 2016 08:51:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.0 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=seq, 2016-12-20 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 Dec 2016 08:51:40 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id EAFF9ACC9; Tue, 20 Dec 2016 08:51:37 +0000 (UTC) Date: Tue, 20 Dec 2016 08:57:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org cc: "Joseph S. Myers" Subject: [PATCH][gimplefe] Improve error recovery Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2016-12/txt/msg01686.txt.bz2 Just noticed a few issues when feeding the GIMPLE FE random -gimple dumps. On errors not skipping to expected tokens leads to a load of strange followup parsing errors and worse, to endless parsing attempts in one case. Fixed with the following. Bootstrap / regtest running together with the pass manager change posted in the other thread. I consider gimple-parser.c changes like this "middle-end", Joseph, are you fine with that? Richard. 2016-12-20 Richard Biener c/ * gimple-parser.c (c_parser_gimple_compound_statement): Improve error recovery. (c_parser_gimple_statement): Only build assigns for non-error stmts. (c_parser_gimple_postfix_expression_after): Improve error recovery. Index: gcc/c/gimple-parser.c =================================================================== --- gcc/c/gimple-parser.c (revision 243738) +++ gcc/c/gimple-parser.c (working copy) @@ -215,7 +215,7 @@ c_parser_gimple_compound_statement (c_pa expr_stmt: c_parser_gimple_statement (parser, seq); if (! c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>")) - return return_p; + c_parser_skip_until_found (parser, CPP_SEMICOLON, NULL); } } c_parser_consume_token (parser); @@ -327,9 +327,12 @@ c_parser_gimple_statement (c_parser *par case CPP_NOT: case CPP_MULT: /* pointer deref */ rhs = c_parser_gimple_unary_expression (parser); - assign = gimple_build_assign (lhs.value, rhs.value); - gimple_set_location (assign, loc); - gimple_seq_add_stmt (seq, assign); + if (rhs.value != error_mark_node) + { + assign = gimple_build_assign (lhs.value, rhs.value); + gimple_set_location (assign, loc); + gimple_seq_add_stmt (seq, assign); + } return; default:; @@ -385,10 +388,13 @@ c_parser_gimple_statement (c_parser *par && lookup_name (c_parser_peek_token (parser)->value)) { rhs = c_parser_gimple_unary_expression (parser); - gimple *call = gimple_build_call_from_tree (rhs.value); - gimple_call_set_lhs (call, lhs.value); - gimple_seq_add_stmt (seq, call); - gimple_set_location (call, loc); + if (rhs.value != error_mark_node) + { + gimple *call = gimple_build_call_from_tree (rhs.value); + gimple_call_set_lhs (call, lhs.value); + gimple_seq_add_stmt (seq, call); + gimple_set_location (call, loc); + } return; } @@ -802,7 +808,10 @@ c_parser_gimple_postfix_expression_after tree idx = c_parser_gimple_unary_expression (parser).value; if (! c_parser_require (parser, CPP_CLOSE_SQUARE, "expected %<]%>")) - break; + { + c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, NULL); + break; + } start = expr.get_start (); finish = c_parser_tokens_buf (parser, 0)->location;