Generate the right code for conditional with void result type.
@@ -9711,17 +9711,21 @@ static op_t gen (node_t r, MIR_label_t true_label, MIR_label_t false_label, int
node_t false_expr = NL_NEXT (true_expr);
MIR_label_t true_label = MIR_new_label (ctx), false_label = MIR_new_label (ctx);
MIR_label_t end_label = MIR_new_label (ctx);
+ struct type *type = ((struct expr *) r->attr)->type;
+ int void_p = type->mode == TM_BASIC && type->u.basic_type == TP_VOID;
- t = get_mir_type (((struct expr *) r->attr)->type);
+ if (!void_p) {
+ t = get_mir_type (type);
res = get_new_temp (t);
+ }
gen (cond, true_label, false_label, FALSE);
emit_insn (true_label);
op1 = gen (true_expr, NULL, NULL, TRUE);
- emit2 (tp_mov (t), res.mir_op, op1.mir_op);
+ if (!void_p) emit2 (tp_mov (t), res.mir_op, op1.mir_op);
emit1 (MIR_JMP, MIR_new_label_op (ctx, end_label));
emit_insn (false_label);
op1 = gen (false_expr, NULL, NULL, TRUE);
- emit2 (tp_mov (t), res.mir_op, op1.mir_op);
+ if (!void_p) emit2 (tp_mov (t), res.mir_op, op1.mir_op);
emit_insn (end_label);
break;
}
