From 71d335e5ccc5c7c37ac40debf78ad3aa096b22d3 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 3 Feb 2017 11:39:24 -0500 Subject: implement packed structs closes #183 --- src/analyze.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/analyze.cpp') diff --git a/src/analyze.cpp b/src/analyze.cpp index 506d5e1db3..280fc94214 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -823,22 +823,24 @@ static TypeTableEntryId container_to_type(ContainerKind kind) { zig_unreachable(); } -TypeTableEntry *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKind kind, AstNode *decl_node, const char *name, bool is_extern) { +TypeTableEntry *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKind kind, + AstNode *decl_node, const char *name, ContainerLayout layout) +{ TypeTableEntryId type_id = container_to_type(kind); TypeTableEntry *entry = new_container_type_entry(type_id, decl_node, scope); switch (kind) { case ContainerKindStruct: entry->data.structure.decl_node = decl_node; - entry->data.structure.is_extern = is_extern; + entry->data.structure.layout = layout; break; case ContainerKindEnum: entry->data.enumeration.decl_node = decl_node; - entry->data.enumeration.is_extern = is_extern; + entry->data.enumeration.layout = layout; break; case ContainerKindUnion: entry->data.unionation.decl_node = decl_node; - entry->data.unionation.is_extern = is_extern; + entry->data.unionation.layout = layout; break; } @@ -1328,7 +1330,8 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) { } assert(struct_type->di_type); - LLVMStructSetBody(struct_type->type_ref, element_types, gen_field_count, false); + bool packed = (struct_type->data.structure.layout == ContainerLayoutPacked); + LLVMStructSetBody(struct_type->type_ref, element_types, gen_field_count, packed); assert(LLVMStoreSizeOfType(g->target_data_ref, struct_type->type_ref) > 0); ZigLLVMDIType **di_element_types = allocate(gen_field_count); -- cgit v1.2.3