diff options
author | Richard Biener <rguenther@suse.de> | 2021-05-18 08:41:43 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2021-05-18 09:04:37 +0200 |
commit | 414fe08a352eac69168f4fb3671246c84a1ac5aa (patch) | |
tree | 549358505d9583b5a40b8d475c472c23c84fb2c1 /gcc/c/gimple-parser.c | |
parent | 4054472b3fa15e11ccd48190f5e3ecfc89d65af9 (diff) | |
download | gcc-414fe08a352eac69168f4fb3671246c84a1ac5aa.zip gcc-414fe08a352eac69168f4fb3671246c84a1ac5aa.tar.gz gcc-414fe08a352eac69168f4fb3671246c84a1ac5aa.tar.bz2 |
c/100522 - avoid invalid GIMPLE in GIMPLE parsing
This plugs a few easy holes avoiding ICEs down the route.
2021-05-18 Richard Biener <rguenther@suse.de>
PR c/100522
gcc/c/
* gimple-parser.c (c_parser_gimple_postfix_expression_after_primary):
Diagnose calls to non-functions.
(c_parser_gimple_statement): Diagnose unexpected assignment RHS.
gcc/testsuite/
* gcc.dg/gimplefe-error-10.c: New testcase.
Diffstat (limited to 'gcc/c/gimple-parser.c')
-rw-r--r-- | gcc/c/gimple-parser.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index 398e216..dfacf23 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -877,6 +877,11 @@ c_parser_gimple_statement (gimple_parser &parser, gimple_seq *seq) rhs.value = build3_loc (loc, COND_EXPR, TREE_TYPE (trueval.value), rhs.value, trueval.value, falseval.value); } + if (get_gimple_rhs_class (TREE_CODE (rhs.value)) == GIMPLE_INVALID_RHS) + { + c_parser_error (parser, "unexpected RHS for assignment"); + return; + } assign = gimple_build_assign (lhs.value, rhs.value); gimple_seq_add_stmt_without_update (seq, assign); gimple_set_location (assign, loc); @@ -1754,6 +1759,12 @@ c_parser_gimple_postfix_expression_after_primary (gimple_parser &parser, c_parser_gimple_expr_list (parser, &exprlist); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); + if (!FUNC_OR_METHOD_TYPE_P (TREE_TYPE (expr.value))) + { + c_parser_error (parser, "invalid call to non-function"); + expr.set_error (); + break; + } expr.value = build_call_array_loc (expr_loc, TREE_TYPE (TREE_TYPE (expr.value)), expr.value, exprlist.length (), exprlist.address ()); |