Generate default return with the right # of operands.
@@ -12291,18 +12291,21 @@ static op_t gen (c2m_ctx_t c2m_ctx, node_t r, MIR_label_t true_label, MIR_label_
gen (c2m_ctx, stmt, NULL, NULL, FALSE, NULL);
if ((insn = DLIST_TAIL (MIR_insn_t, curr_func->u.func->insns)) == NULL
|| (insn->code != MIR_RET && insn->code != MIR_JMP)) {
- if (res_type == MIR_T_UNDEF)
+ if (res_type == MIR_T_UNDEF) {
emit_insn (c2m_ctx, MIR_new_ret_insn (ctx, 0));
- else if (res_type == MIR_T_D)
+ } else if (res_type == MIR_T_D) {
emit_insn (c2m_ctx, MIR_new_ret_insn (ctx, 1, MIR_new_double_op (ctx, 0.0)));
- else if (res_type == MIR_T_LD)
+ } else if (res_type == MIR_T_LD) {
emit_insn (c2m_ctx, MIR_new_ret_insn (ctx, 1, MIR_new_ldouble_op (ctx, 0.0)));
- else if (res_type == MIR_T_F)
+ } else if (res_type == MIR_T_F) {
emit_insn (c2m_ctx, MIR_new_ret_insn (ctx, 1, MIR_new_float_op (ctx, 0.0)));
- else if (scalar_type_p (adjust_type (c2m_ctx, decl->decl_spec.type->u.func_type->ret_type)))
- emit_insn (c2m_ctx, MIR_new_ret_insn (ctx, 1, MIR_new_int_op (ctx, 0)));
- else
- assert (FALSE); /* ??? not implemented */
+ } else {
+ VARR_TRUNC (MIR_op_t, ret_ops, 0);
+ for (size_t i = 0; i < VARR_LENGTH (MIR_type_t, proto_info.ret_types); i++)
+ VARR_PUSH (MIR_op_t, ret_ops, MIR_new_int_op (ctx, 0));
+ emit_insn (c2m_ctx, MIR_new_insn_arr (ctx, MIR_RET, VARR_LENGTH (MIR_op_t, ret_ops),
+ VARR_ADDR (MIR_op_t, ret_ops)));
+ }
}
MIR_finish_func (ctx);
if (decl->decl_spec.linkage == N_EXTERN)
