diff options
| author | Laytan <laytanlaats@hotmail.com> | 2025-06-20 22:31:31 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-20 22:31:31 +0200 |
| commit | 2995557394f77909156f65afdf8d76c1806f1d32 (patch) | |
| tree | 5b84c8367762868ead4ab905cfe1890310facc83 /src/types.cpp | |
| parent | 7d8f41b938371ec231e27ed3dde0fd713c4b1258 (diff) | |
| parent | 717b9f157889cdcdd60253eb656648e9251d3be7 (diff) | |
Merge pull request #5211 from Barinzaya/union-custom-align-tag-size
Consider custom `#align` when determining union tag size
Diffstat (limited to 'src/types.cpp')
| -rw-r--r-- | src/types.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/types.cpp b/src/types.cpp index c7573173c..d7d26f9a3 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -3093,11 +3093,15 @@ gb_internal i64 union_tag_size(Type *u) { compiler_error("how many variants do you have?! %lld", cast(long long)u->Union.variants.count); } - for_array(i, u->Union.variants) { - Type *variant_type = u->Union.variants[i]; - i64 align = type_align_of(variant_type); - if (max_align < align) { - max_align = align; + if (u->Union.custom_align > 0) { + max_align = gb_max(max_align, u->Union.custom_align); + } else { + for_array(i, u->Union.variants) { + Type *variant_type = u->Union.variants[i]; + i64 align = type_align_of(variant_type); + if (max_align < align) { + max_align = align; + } } } |