From 5bc877017ede3b85361a112987757ee277b9c889 Mon Sep 17 00:00:00 2001 From: scurest Date: Sat, 17 Jun 2017 11:30:29 -0500 Subject: use most_aligned_member+padding to represent enum unions --- src/codegen.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/codegen.cpp') diff --git a/src/codegen.cpp b/src/codegen.cpp index ad014e9e19..ac4f94e133 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -3663,13 +3663,13 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) { if (type_entry->data.enumeration.gen_field_count == 0) { return tag_value; } else { - TypeTableEntry *union_type = type_entry->data.enumeration.union_type; + LLVMTypeRef union_type_ref = type_entry->data.enumeration.union_type_ref; TypeEnumField *enum_field = &type_entry->data.enumeration.fields[const_val->data.x_enum.tag]; assert(enum_field->value == const_val->data.x_enum.tag); LLVMValueRef union_value; if (type_has_bits(enum_field->type_entry)) { uint64_t union_type_bytes = LLVMStoreSizeOfType(g->target_data_ref, - union_type->type_ref); + union_type_ref); uint64_t field_type_bytes = LLVMStoreSizeOfType(g->target_data_ref, enum_field->type_entry->type_ref); uint64_t pad_bytes = union_type_bytes - field_type_bytes; @@ -3685,7 +3685,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) { union_value = LLVMConstStruct(fields, 2, false); } } else { - union_value = LLVMGetUndef(union_type->type_ref); + union_value = LLVMGetUndef(union_type_ref); } LLVMValueRef fields[] = { tag_value, -- cgit v1.2.3