mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 16:18:52 +00:00
Fix #2594 zero sized union code generation
This commit is contained in:
@@ -218,7 +218,9 @@ gb_internal lbValue lb_equal_proc_for_type(lbModule *m, Type *type) {
|
|||||||
|
|
||||||
LLVMBuildRet(p->builder, LLVMConstInt(lb_type(m, t_bool), 0, false));
|
LLVMBuildRet(p->builder, LLVMConstInt(lb_type(m, t_bool), 0, false));
|
||||||
} else if (type->kind == Type_Union) {
|
} else if (type->kind == Type_Union) {
|
||||||
if (is_type_union_maybe_pointer(type)) {
|
if (type_size_of(type) == 0) {
|
||||||
|
LLVMBuildRet(p->builder, LLVMConstInt(lb_type(m, t_bool), 1, false));
|
||||||
|
} else if (is_type_union_maybe_pointer(type)) {
|
||||||
Type *v = type->Union.variants[0];
|
Type *v = type->Union.variants[0];
|
||||||
Type *pv = alloc_type_pointer(v);
|
Type *pv = alloc_type_pointer(v);
|
||||||
|
|
||||||
|
|||||||
@@ -1323,6 +1323,7 @@ gb_internal lbValue lb_emit_union_tag_value(lbProcedure *p, lbValue u) {
|
|||||||
|
|
||||||
gb_internal void lb_emit_store_union_variant_tag(lbProcedure *p, lbValue parent, Type *variant_type) {
|
gb_internal void lb_emit_store_union_variant_tag(lbProcedure *p, lbValue parent, Type *variant_type) {
|
||||||
Type *t = type_deref(parent.type);
|
Type *t = type_deref(parent.type);
|
||||||
|
GB_ASSERT(is_type_union(t));
|
||||||
|
|
||||||
if (is_type_union_maybe_pointer(t) || type_size_of(t) == 0) {
|
if (is_type_union_maybe_pointer(t) || type_size_of(t) == 0) {
|
||||||
// No tag needed!
|
// No tag needed!
|
||||||
|
|||||||
@@ -655,9 +655,8 @@ gb_internal void lb_setup_type_info_data(lbProcedure *p) { // NOTE(bill): Setup
|
|||||||
vals[0] = llvm_const_slice(m, memory_types, count);
|
vals[0] = llvm_const_slice(m, memory_types, count);
|
||||||
|
|
||||||
i64 tag_size = union_tag_size(t);
|
i64 tag_size = union_tag_size(t);
|
||||||
i64 tag_offset = align_formula(t->Union.variant_block_size, tag_size);
|
|
||||||
|
|
||||||
if (tag_size > 0) {
|
if (tag_size > 0) {
|
||||||
|
i64 tag_offset = align_formula(t->Union.variant_block_size, tag_size);
|
||||||
vals[1] = lb_const_int(m, t_uintptr, tag_offset).value;
|
vals[1] = lb_const_int(m, t_uintptr, tag_offset).value;
|
||||||
vals[2] = lb_type_info(m, union_tag_type(t)).value;
|
vals[2] = lb_type_info(m, union_tag_type(t)).value;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user