aboutsummaryrefslogtreecommitdiff
path: root/src/types.cpp
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-08-12 20:04:35 +0100
committerGinger Bill <bill@gingerbill.org>2017-08-12 20:04:35 +0100
commit4262c125c5c56db61c57e090ea76db61c16bcebc (patch)
treedae5f6d6d6bb3c4a8bfb3cf0744419919db3370d /src/types.cpp
parentd7bd3f8402e86d020ff5bb9dda3f9a2da2d3a07c (diff)
Fix struct #packed alignment calculation
Diffstat (limited to 'src/types.cpp')
-rw-r--r--src/types.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/types.cpp b/src/types.cpp
index dd05f3238..dec7428eb 100644
--- a/src/types.cpp
+++ b/src/types.cpp
@@ -1864,21 +1864,20 @@ i64 type_align_of_internal(gbAllocator allocator, Type *t, TypePath *path) {
return max;
} else if (t->Struct.fields.count > 0) {
i64 max = 1;
- if (t->Struct.is_packed) {
- max = build_context.word_size;
- }
+ // NOTE(bill): Check the fields to check for cyclic definitions
for_array(i, t->Struct.fields) {
Type *field_type = t->Struct.fields[i]->type;
type_path_push(path, field_type);
- if (path->failure) {
- return FAILURE_ALIGNMENT;
- }
+ if (path->failure) return FAILURE_ALIGNMENT;
i64 align = type_align_of_internal(allocator, field_type, path);
type_path_pop(path);
if (max < align) {
max = align;
}
}
+ if (t->Struct.is_packed) {
+ return 1;
+ }
return max;
}
} break;