| ... | @@ -2707,7 +2707,9 @@ static AstNode *trans_do_loop(Context *c, TransScope *parent_scope, const DoStmt | ... | @@ -2707,7 +2707,9 @@ static AstNode *trans_do_loop(Context *c, TransScope *parent_scope, const DoStmt |
| 2707 | AstNode *child_statement; | 2707 | AstNode *child_statement; |
| 2708 | child_scope = trans_stmt(c, &child_block_scope->base, stmt->getBody(), &child_statement); | 2708 | child_scope = trans_stmt(c, &child_block_scope->base, stmt->getBody(), &child_statement); |
| 2709 | if (child_scope == nullptr) return nullptr; | 2709 | if (child_scope == nullptr) return nullptr; |
| 2710 | body_node->data.block.statements.append(child_statement); | 2710 | if (child_statement != nullptr) { |
| | 2711 | body_node->data.block.statements.append(child_statement); |
| | 2712 | } |
| 2711 | } | 2713 | } |
| 2712 | | 2714 | |
| 2713 | // if (!cond) break; | 2715 | // if (!cond) break; |
| ... | @@ -2717,6 +2719,7 @@ static AstNode *trans_do_loop(Context *c, TransScope *parent_scope, const DoStmt | ... | @@ -2717,6 +2719,7 @@ static AstNode *trans_do_loop(Context *c, TransScope *parent_scope, const DoStmt |
| 2717 | terminator_node->data.if_bool_expr.condition = trans_create_node_prefix_op(c, PrefixOpBoolNot, condition_node); | 2719 | terminator_node->data.if_bool_expr.condition = trans_create_node_prefix_op(c, PrefixOpBoolNot, condition_node); |
| 2718 | terminator_node->data.if_bool_expr.then_block = trans_create_node(c, NodeTypeBreak); | 2720 | terminator_node->data.if_bool_expr.then_block = trans_create_node(c, NodeTypeBreak); |
| 2719 | | 2721 | |
| | 2722 | assert(terminator_node != nullptr); |
| 2720 | body_node->data.block.statements.append(terminator_node); | 2723 | body_node->data.block.statements.append(terminator_node); |
| 2721 | | 2724 | |
| 2722 | while_scope->node->data.while_expr.body = body_node; | 2725 | while_scope->node->data.while_expr.body = body_node; |
| ... | @@ -3044,9 +3047,13 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const Stmt *stmt, | ... | @@ -3044,9 +3047,13 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const Stmt *stmt, |
| 3044 | case Stmt::UnaryExprOrTypeTraitExprClass: | 3047 | case Stmt::UnaryExprOrTypeTraitExprClass: |
| 3045 | return wrap_stmt(out_node, out_child_scope, scope, | 3048 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3046 | trans_unary_expr_or_type_trait_expr(c, scope, (const UnaryExprOrTypeTraitExpr *)stmt)); | 3049 | trans_unary_expr_or_type_trait_expr(c, scope, (const UnaryExprOrTypeTraitExpr *)stmt)); |
| 3047 | case Stmt::DoStmtClass: | 3050 | case Stmt::DoStmtClass: { |
| 3048 | return wrap_stmt(out_node, out_child_scope, scope, | 3051 | AstNode *while_node = trans_do_loop(c, scope, (const DoStmt *)stmt); |
| 3049 | trans_do_loop(c, scope, (const DoStmt *)stmt)); | 3052 | if (while_node->data.while_expr.body == nullptr) { |
| | 3053 | while_node->data.while_expr.body = trans_create_node(c, NodeTypeBlock); |
| | 3054 | } |
| | 3055 | return wrap_stmt(out_node, out_child_scope, scope, while_node); |
| | 3056 | } |
| 3050 | case Stmt::ForStmtClass: { | 3057 | case Stmt::ForStmtClass: { |
| 3051 | AstNode *while_node = trans_for_loop(c, scope, (const ForStmt *)stmt); | 3058 | AstNode *while_node = trans_for_loop(c, scope, (const ForStmt *)stmt); |
| 3052 | if (while_node->data.while_expr.body == nullptr) { | 3059 | if (while_node->data.while_expr.body == nullptr) { |