c/98200 - improve error recovery for GIMPLE FE

This avoids ICEing by making sure to propagate error early.

2020-12-09  Richard Biener  <rguenther@suse.de>

	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.
This commit is contained in:
Richard Biener 2020-12-09 09:56:59 +01:00
parent 1cb2d1d5ce
commit 42bdf81449
2 changed files with 11 additions and 0 deletions

View file

@ -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);
}

View file

@ -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;
}