diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-02-03 11:39:24 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-02-03 11:39:24 -0500 |
| commit | 71d335e5ccc5c7c37ac40debf78ad3aa096b22d3 (patch) | |
| tree | b64024a77a76bf26ed77596125c046321edfb4ff /src/analyze.cpp | |
| parent | cd7713b1788aeeadf6c46def38d4ef4fa313fe75 (diff) | |
| download | zig-71d335e5ccc5c7c37ac40debf78ad3aa096b22d3.tar.gz zig-71d335e5ccc5c7c37ac40debf78ad3aa096b22d3.zip | |
implement packed structs
closes #183
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
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<ZigLLVMDIType*>(gen_field_count); |
