From: Richard Biener Date: Wed, 9 Dec 2020 08:56:59 +0000 (+0100) Subject: c/98200 - improve error recovery for GIMPLE FE X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=42bdf814493c2c39e7a6bd3fb2dd4491352ce5d9;p=gcc.git c/98200 - improve error recovery for GIMPLE FE This avoids ICEing by making sure to propagate error early. 2020-12-09 Richard Biener PR c/98200 gcc/c/ * gimple-parser.c (c_parser_gimple_postfix_expression): Return early on error. gcc/testsuite/ * gcc.dg/gimplefe-error-8.c: New testcase. --- diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index 5c0ed826119..473cb900481 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -1700,6 +1700,8 @@ c_parser_gimple_postfix_expression (gimple_parser &parser) expr.set_error (); break; } + if (expr.value == error_mark_node) + return expr; return c_parser_gimple_postfix_expression_after_primary (parser, EXPR_LOC_OR_LOC (expr.value, loc), expr); } diff --git a/gcc/testsuite/gcc.dg/gimplefe-error-8.c b/gcc/testsuite/gcc.dg/gimplefe-error-8.c new file mode 100644 index 00000000000..59e81eb4b32 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-error-8.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +int __GIMPLE() f(int x, int y) +{ + int a; + a = (x < y) ? 1 : 2; /* { dg-error "expected" } */ + return a; +}