Sema: resolve lazy align in reifyStruct

Closes #12786
This commit is contained in:
Veikka Tuominen 2022-09-09 15:23:36 +03:00
parent de24cea2cf
commit 930f904aaa
3 changed files with 30 additions and 1 deletions

View File

@ -17406,7 +17406,7 @@ fn reifyStruct(
if (!try sema.intFitsInType(block, src, alignment_val, Type.u32, null)) {
return sema.fail(block, src, "alignment must fit in 'u32'", .{});
}
const abi_align = @intCast(u29, alignment_val.toUnsignedInt(target));
const abi_align = @intCast(u29, (try alignment_val.getUnsignedIntAdvanced(target, sema.kit(block, src))).?);
const field_name = try name_val.toAllocatedBytes(
Type.initTag(.const_slice_u8),

View File

@ -87,6 +87,7 @@ test {
_ = @import("behavior/bugs/12486.zig");
_ = @import("behavior/bugs/12680.zig");
_ = @import("behavior/bugs/12776.zig");
_ = @import("behavior/bugs/12786.zig");
_ = @import("behavior/bugs/12794.zig");
_ = @import("behavior/byteswap.zig");
_ = @import("behavior/byval_arg_var.zig");

View File

@ -0,0 +1,28 @@
const std = @import("std");
fn NamespacedGlobals(comptime modules: anytype) type {
return @Type(.{
.Struct = .{
.layout = .Auto,
.is_tuple = false,
.fields = &.{
.{
.name = "globals",
.field_type = modules.mach.globals,
.default_value = null,
.is_comptime = false,
.alignment = @alignOf(modules.mach.globals),
},
},
.decls = &[_]std.builtin.Type.Declaration{},
},
});
}
test {
_ = NamespacedGlobals(.{
.mach = .{
.globals = struct {},
},
});
}