diff options
Diffstat (limited to 'gcc/c/gimple-parser.c')
-rw-r--r-- | gcc/c/gimple-parser.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index 58b161b..c8d9db6 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -131,7 +131,7 @@ static void c_parser_gimple_expr_list (gimple_parser &, vec<tree> *); static bool c_parser_gimple_parse_bb_spec (tree val, int *index) { - if (strncmp (IDENTIFIER_POINTER (val), "__BB", 4) != 0) + if (!startswith (IDENTIFIER_POINTER (val), "__BB")) return false; for (const char *p = IDENTIFIER_POINTER (val) + 4; *p; ++p) if (!ISDIGIT (*p)) @@ -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 ()); @@ -1887,7 +1898,8 @@ c_parser_gimple_label (gimple_parser &parser, gimple_seq *seq) gcc_assert (c_parser_next_token_is (parser, CPP_COLON)); c_parser_consume_token (parser); tree label = define_label (loc1, name); - gimple_seq_add_stmt_without_update (seq, gimple_build_label (label)); + if (label) + gimple_seq_add_stmt_without_update (seq, gimple_build_label (label)); return; } @@ -2100,6 +2112,14 @@ c_parser_gimple_paren_condition (gimple_parser &parser) if (! c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) return error_mark_node; tree cond = c_parser_gimple_binary_expression (parser).value; + if (cond != error_mark_node + && ! COMPARISON_CLASS_P (cond) + && ! CONSTANT_CLASS_P (cond) + && ! SSA_VAR_P (cond)) + { + c_parser_error (parser, "comparison required"); + cond = error_mark_node; + } if (! c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>")) return error_mark_node; return cond; |