mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-29 17:34:34 +00:00
Merge pull request #4058 from laytan/fix-cvararg-bitset
fix c_vararg bit_set
This commit is contained in:
@@ -2469,6 +2469,17 @@ gb_internal lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) {
|
||||
return {};
|
||||
}
|
||||
|
||||
gb_internal lbValue lb_emit_c_vararg(lbProcedure *p, lbValue arg, Type *type) {
|
||||
Type *core = core_type(type);
|
||||
if (core->kind == Type_BitSet) {
|
||||
core = core_type(bit_set_to_int(core));
|
||||
arg = lb_emit_transmute(p, arg, core);
|
||||
}
|
||||
|
||||
Type *promoted = c_vararg_promote_type(core);
|
||||
return lb_emit_conv(p, arg, promoted);
|
||||
}
|
||||
|
||||
gb_internal lbValue lb_compare_records(lbProcedure *p, TokenKind op_kind, lbValue left, lbValue right, Type *type) {
|
||||
GB_ASSERT((is_type_struct(type) || is_type_union(type)) && is_type_comparable(type));
|
||||
lbValue left_ptr = lb_address_from_load_or_generate_local(p, left);
|
||||
|
||||
@@ -3569,9 +3569,9 @@ gb_internal lbValue lb_build_call_expr_internal(lbProcedure *p, Ast *expr) {
|
||||
if (is_type_untyped_nil(arg.type)) {
|
||||
arg = lb_const_nil(p->module, t_rawptr);
|
||||
}
|
||||
array_add(&args, lb_emit_conv(p, arg, c_vararg_promote_type(default_type(arg.type))));
|
||||
array_add(&args, lb_emit_c_vararg(p, arg, arg.type));
|
||||
} else {
|
||||
array_add(&args, lb_emit_conv(p, arg, c_vararg_promote_type(elem_type)));
|
||||
array_add(&args, lb_emit_c_vararg(p, arg, elem_type));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -3697,15 +3697,15 @@ gb_internal lbValue lb_build_call_expr_internal(lbProcedure *p, Ast *expr) {
|
||||
if (is_type_untyped_nil(arg.type)) {
|
||||
arg = lb_const_nil(p->module, t_rawptr);
|
||||
}
|
||||
array_add(&args, lb_emit_conv(p, arg, c_vararg_promote_type(default_type(arg.type))));
|
||||
array_add(&args, lb_emit_c_vararg(p, arg, arg.type));
|
||||
} else {
|
||||
array_add(&args, lb_emit_conv(p, arg, c_vararg_promote_type(elem_type)));
|
||||
array_add(&args, lb_emit_c_vararg(p, arg, elem_type));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lbValue value = lb_build_expr(p, fv->value);
|
||||
GB_ASSERT(!is_type_tuple(value.type));
|
||||
array_add(&args, lb_emit_conv(p, value, c_vararg_promote_type(value.type)));
|
||||
array_add(&args, lb_emit_c_vararg(p, value, value.type));
|
||||
}
|
||||
} else {
|
||||
lbValue value = lb_build_expr(p, fv->value);
|
||||
|
||||
@@ -2960,10 +2960,7 @@ gb_internal Type *c_vararg_promote_type(Type *type) {
|
||||
GB_ASSERT(type != nullptr);
|
||||
|
||||
Type *core = core_type(type);
|
||||
|
||||
if (core->kind == Type_BitSet) {
|
||||
core = core_type(bit_set_to_int(core));
|
||||
}
|
||||
GB_ASSERT(core->kind != Type_BitSet);
|
||||
|
||||
if (core->kind == Type_Basic) {
|
||||
switch (core->Basic.kind) {
|
||||
|
||||
Reference in New Issue
Block a user