Hi, I am trying to replace c_parser_paren_condition (parser) in c_parser_gimple_if_stmt by c_parser_gimple_paren_condition (parser) as described in the patch
I am trying test case void __GIMPLE () foo () { int a; bb_2: if (a == 2) goto bb_3; else goto bb_4; bb_3: a_2 = 4; bb_4: return; } but it fails to parse gimple expression and produces error as /home/prasad/test3.c: In function ‘foo’: /home/prasad/test3.c:1:18: error: invalid operands in gimple comparison void __GIMPLE () foo () ^~~ if (<<< Unknown tree: c_maybe_const_expr a >>> == 2) goto bb_3; else goto bb_4; /home/prasad/test3.c:1:18: internal compiler error: verify_gimple failed I failed to debug where it is setting to C_MAYBE_CONST_EXPR Thanks, Prasad
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 70800a2..9e5152c 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -1425,6 +1425,7 @@ static void c_parser_gimple_switch_stmt (c_parser *, gimple_seq *); static void c_parser_gimple_return_stmt (c_parser *, gimple_seq *); static void c_finish_gimple_return (location_t, tree); static c_expr c_parser_parse_ssa_names (c_parser *); +static tree c_parser_gimple_paren_condition (c_parser *); /* Parse a translation unit (C90 6.7, C99 6.9). @@ -19025,6 +19026,25 @@ c_parser_gimple_goto_stmt (location_t loc, tree label, gimple_seq *seq) return; } +/* Parse a parenthesized condition */ + +static tree +c_parser_gimple_paren_condition (c_parser *parser) +{ + c_expr cond; + enum tree_code subcode = NOP_EXPR; + cond.original_code = ERROR_MARK; + cond.original_type = NULL; + location_t loc = c_parser_peek_token (parser)->location; + if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) + return error_mark_node; + cond = c_parser_gimple_binary_expression (parser, &subcode); + cond = convert_lvalue_to_rvalue (loc, cond, true, true); + cond.value = c_objc_common_truthvalue_conversion (loc, cond.value); + c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); + return cond.value; +} + /* Parse gimple if-else statement */ static void @@ -19033,7 +19053,7 @@ c_parser_gimple_if_stmt (c_parser *parser, gimple_seq *seq) tree cond, t_label, f_label, label; location_t loc; c_parser_consume_token (parser); - cond = c_parser_paren_condition (parser); + cond = c_parser_gimple_paren_condition (parser); if (c_parser_next_token_is_keyword (parser, RID_GOTO)) {