aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/gimple-parser.c
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2021-09-13 10:37:49 -0700
committerIan Lance Taylor <iant@golang.org>2021-09-13 10:37:49 -0700
commite252b51ccde010cbd2a146485d8045103cd99533 (patch)
treee060f101cdc32bf5e520de8e5275db9d4236b74c /gcc/c/gimple-parser.c
parentf10c7c4596dda99d2ee872c995ae4aeda65adbdf (diff)
parent104c05c5284b7822d770ee51a7d91946c7e56d50 (diff)
downloadgcc-e252b51ccde010cbd2a146485d8045103cd99533.zip
gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.gz
gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.bz2
Merge from trunk revision 104c05c5284b7822d770ee51a7d91946c7e56d50.
Diffstat (limited to 'gcc/c/gimple-parser.c')
-rw-r--r--gcc/c/gimple-parser.c24
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;