Improve error recovery in parse_asm_statement() and do not return an error statement.
[cparser] / parser.c
index 0f7f557..35762b9 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -9048,6 +9048,7 @@ end_of_asm:
        expect(')', end_error);
        expect(';', end_error);
 
+end_error:
        if (asm_statement->outputs == NULL) {
                /* GCC: An 'asm' instruction without any output operands will be treated
                 * identically to a volatile 'asm' instruction. */
@@ -9055,8 +9056,6 @@ end_of_asm:
        }
 
        return statement;
-end_error:
-       return create_error_statement();
 }
 
 static statement_t *parse_label_inner_statement(statement_t const *const label, char const *const label_kind)
@@ -9483,19 +9482,18 @@ static statement_t *parse_do(void)
        statement->do_while.body = parse_loop_body(statement);
        rem_anchor_token(T_while);
 
-       expect(T_while, end_error);
+       expect(T_while, end_error0);
+end_error0:;
        expression_t *const cond = parse_condition();
        statement->do_while.condition = cond;
        /* ยง6.8.5:2    The controlling expression of an iteration statement shall
         *             have scalar type. */
        semantic_condition(cond, "condition of 'do-while'-statement");
-       expect(';', end_error);
+       expect(';', end_error1);
+end_error1:
 
        POP_PARENT();
        return statement;
-end_error:
-       POP_PARENT();
-       return create_error_statement();
 }
 
 /**