authorgravatar for micah.switzer.dev@outlook.comMicah Switzer <micah.switzer.dev@outlook.com> 2022-11-03 19:56:23-04:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-11-04 15:48:08+02:00
logea54c9a375ef8f419694b39b9f14f181fa0b82ee
treecbee514ea87c5603088ef8bba6db030bea2527dd
parentcbed6bb08555222008e87cfb071adeed97b3f8a4

Sema: resolve lazy align in zirReify for union fields

Closes #13435

3 files changed, 24 insertions(+), 1 deletions(-)

src/Sema.zig+1-1
......@@ -18232,7 +18232,7 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in
1823218232 var buffer: Value.ToTypeBuffer = undefined;
1823318233 gop.value_ptr.* = .{
1823418234 .ty = try field_type_val.toType(&buffer).copy(new_decl_arena_allocator),
18235 .abi_align = @intCast(u32, alignment_val.toUnsignedInt(target)),
18235 .abi_align = @intCast(u32, (try alignment_val.getUnsignedIntAdvanced(target, sema.kit(block, src))).?),
1823618236 };
1823718237 }
1823818238
test/behavior.zig+1
......@@ -111,6 +111,7 @@ test {
111111 _ = @import("behavior/bugs/13159.zig");
112112 _ = @import("behavior/bugs/13171.zig");
113113 _ = @import("behavior/bugs/13285.zig");
114 _ = @import("behavior/bugs/13435.zig");
114115 _ = @import("behavior/byteswap.zig");
115116 _ = @import("behavior/byval_arg_var.zig");
116117 _ = @import("behavior/call.zig");
test/behavior/bugs/13435.zig created+22
......@@ -0,0 +1,22 @@
1const std = @import("std");
2
3fn CreateUnion(comptime T: type) type {
4 return @Type(.{
5 .Union = .{
6 .layout = .Auto,
7 .tag_type = null,
8 .fields = &[_]std.builtin.Type.UnionField{
9 .{
10 .name = "field",
11 .field_type = T,
12 .alignment = @alignOf(T),
13 },
14 },
15 .decls = &[_]std.builtin.Type.Declaration{},
16 },
17 });
18}
19
20test {
21 _ = CreateUnion(struct {});
22}