| ... | @@ -2783,7 +2783,12 @@ static AstNode *trans_for_loop(Context *c, TransScope *parent_scope, const ForSt | ... | @@ -2783,7 +2783,12 @@ static AstNode *trans_for_loop(Context *c, TransScope *parent_scope, const ForSt |
| 2783 | TransScope *body_scope = trans_stmt(c, &while_scope->base, stmt->getBody(), &body_statement); | 2783 | TransScope *body_scope = trans_stmt(c, &while_scope->base, stmt->getBody(), &body_statement); |
| 2784 | if (body_scope == nullptr) | 2784 | if (body_scope == nullptr) |
| 2785 | return nullptr; | 2785 | return nullptr; |
| 2786 | while_scope->node->data.while_expr.body = body_statement; | 2786 | |
| | 2787 | if (body_statement == nullptr) { |
| | 2788 | while_scope->node->data.while_expr.body = trans_create_node(c, NodeTypeBlock); |
| | 2789 | } else { |
| | 2790 | while_scope->node->data.while_expr.body = body_statement; |
| | 2791 | } |
| 2787 | | 2792 | |
| 2788 | return loop_block_node; | 2793 | return loop_block_node; |
| 2789 | } | 2794 | } |
| ... | @@ -3020,6 +3025,7 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const Stmt *stmt, | ... | @@ -3020,6 +3025,7 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const Stmt *stmt, |
| 3020 | return trans_local_declaration(c, scope, (const DeclStmt *)stmt, out_node, out_child_scope); | 3025 | return trans_local_declaration(c, scope, (const DeclStmt *)stmt, out_node, out_child_scope); |
| 3021 | case Stmt::WhileStmtClass: { | 3026 | case Stmt::WhileStmtClass: { |
| 3022 | AstNode *while_node = trans_while_loop(c, scope, (const WhileStmt *)stmt); | 3027 | AstNode *while_node = trans_while_loop(c, scope, (const WhileStmt *)stmt); |
| | 3028 | assert(while_node->type == NodeTypeWhileExpr); |
| 3023 | if (while_node->data.while_expr.body == nullptr) { | 3029 | if (while_node->data.while_expr.body == nullptr) { |
| 3024 | while_node->data.while_expr.body = trans_create_node(c, NodeTypeBlock); | 3030 | while_node->data.while_expr.body = trans_create_node(c, NodeTypeBlock); |
| 3025 | } | 3031 | } |
| ... | @@ -3049,17 +3055,15 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const Stmt *stmt, | ... | @@ -3049,17 +3055,15 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const Stmt *stmt, |
| 3049 | trans_unary_expr_or_type_trait_expr(c, scope, (const UnaryExprOrTypeTraitExpr *)stmt)); | 3055 | trans_unary_expr_or_type_trait_expr(c, scope, (const UnaryExprOrTypeTraitExpr *)stmt)); |
| 3050 | case Stmt::DoStmtClass: { | 3056 | case Stmt::DoStmtClass: { |
| 3051 | AstNode *while_node = trans_do_loop(c, scope, (const DoStmt *)stmt); | 3057 | AstNode *while_node = trans_do_loop(c, scope, (const DoStmt *)stmt); |
| | 3058 | assert(while_node->type == NodeTypeWhileExpr); |
| 3052 | if (while_node->data.while_expr.body == nullptr) { | 3059 | if (while_node->data.while_expr.body == nullptr) { |
| 3053 | while_node->data.while_expr.body = trans_create_node(c, NodeTypeBlock); | 3060 | while_node->data.while_expr.body = trans_create_node(c, NodeTypeBlock); |
| 3054 | } | 3061 | } |
| 3055 | return wrap_stmt(out_node, out_child_scope, scope, while_node); | 3062 | return wrap_stmt(out_node, out_child_scope, scope, while_node); |
| 3056 | } | 3063 | } |
| 3057 | case Stmt::ForStmtClass: { | 3064 | case Stmt::ForStmtClass: { |
| 3058 | AstNode *while_node = trans_for_loop(c, scope, (const ForStmt *)stmt); | 3065 | AstNode *node = trans_for_loop(c, scope, (const ForStmt *)stmt); |
| 3059 | if (while_node->data.while_expr.body == nullptr) { | 3066 | return wrap_stmt(out_node, out_child_scope, scope, node); |
| 3060 | while_node->data.while_expr.body = trans_create_node(c, NodeTypeBlock); | | |
| 3061 | } | | |
| 3062 | return wrap_stmt(out_node, out_child_scope, scope, while_node); | | |
| 3063 | } | 3067 | } |
| 3064 | case Stmt::StringLiteralClass: | 3068 | case Stmt::StringLiteralClass: |
| 3065 | return wrap_stmt(out_node, out_child_scope, scope, | 3069 | return wrap_stmt(out_node, out_child_scope, scope, |