aboutsummaryrefslogtreecommitdiff
path: root/src/types.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-02-23 11:03:48 +0000
committergingerBill <bill@gingerbill.org>2022-02-23 11:03:48 +0000
commit4b9324ff76cdbf067e800633136c9e63510bddd2 (patch)
tree8d002b2a2db6dd4ec7f69a247de00c5c9dadcea2 /src/types.cpp
parent3e5c60f74672651044d70303e8b0a8e56ca765f2 (diff)
parente81ed9a9601f6a7761dec5b0f96cc8680a16f166 (diff)
Merge branch 'master' into freestanding_amd64
Diffstat (limited to 'src/types.cpp')
-rw-r--r--src/types.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/types.cpp b/src/types.cpp
index 2c1e6162f..74080334a 100644
--- a/src/types.cpp
+++ b/src/types.cpp
@@ -2623,6 +2623,17 @@ i64 union_tag_size(Type *u) {
// TODO(bill): Is this an okay approach?
i64 max_align = 1;
+
+ if (u->Union.variants.count < 1ull<<8) {
+ max_align = 1;
+ } else if (u->Union.variants.count < 1ull<<16) {
+ max_align = 2;
+ } else if (u->Union.variants.count < 1ull<<32) {
+ max_align = 4;
+ } else {
+ GB_PANIC("how many variants do you have?!");
+ }
+
for_array(i, u->Union.variants) {
Type *variant_type = u->Union.variants[i];
i64 align = type_align_of(variant_type);