authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-09-23 16:38:27+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-09-23 17:39:21+03:00
logede379848525dce72c6e903b1895ac3e4acaf3ef
treea9434d54936cf7fae4a8762013db8277e7f6ebc9
parent581df942e1150dc2108bef1d91f0a77ba9c32e23

Sema: resolve struct layout in `zirStructInit`

Closes #12911

3 files changed, 14 insertions(+), 2 deletions(-)

src/Sema.zig+2-2
...@@ -15966,8 +15966,8 @@ fn zirStructInit(...@@ -15966,8 +15966,8 @@ fn zirStructInit(
15966 const first_item = sema.code.extraData(Zir.Inst.StructInit.Item, extra.end).data;15966 const first_item = sema.code.extraData(Zir.Inst.StructInit.Item, extra.end).data;
15967 const first_field_type_data = zir_datas[first_item.field_type].pl_node;15967 const first_field_type_data = zir_datas[first_item.field_type].pl_node;
15968 const first_field_type_extra = sema.code.extraData(Zir.Inst.FieldType, first_field_type_data.payload_index).data;15968 const first_field_type_extra = sema.code.extraData(Zir.Inst.FieldType, first_field_type_data.payload_index).data;
15969 const unresolved_struct_type = try sema.resolveType(block, src, first_field_type_extra.container_type);15969 const resolved_ty = try sema.resolveType(block, src, first_field_type_extra.container_type);
15970 const resolved_ty = try sema.resolveTypeFields(block, src, unresolved_struct_type);15970 try sema.resolveTypeLayout(block, src, resolved_ty);
1597115971
15972 if (resolved_ty.zigTypeTag() == .Struct) {15972 if (resolved_ty.zigTypeTag() == .Struct) {
15973 // This logic must be synchronized with that in `zirStructInitEmpty`.15973 // This logic must be synchronized with that in `zirStructInitEmpty`.
test/behavior.zig+1
...@@ -93,6 +93,7 @@ test {...@@ -93,6 +93,7 @@ test {
93 _ = @import("behavior/bugs/12794.zig");93 _ = @import("behavior/bugs/12794.zig");
94 _ = @import("behavior/bugs/12801-1.zig");94 _ = @import("behavior/bugs/12801-1.zig");
95 _ = @import("behavior/bugs/12801-2.zig");95 _ = @import("behavior/bugs/12801-2.zig");
96 _ = @import("behavior/bugs/12911.zig");
96 _ = @import("behavior/bugs/12928.zig");97 _ = @import("behavior/bugs/12928.zig");
97 _ = @import("behavior/byteswap.zig");98 _ = @import("behavior/byteswap.zig");
98 _ = @import("behavior/byval_arg_var.zig");99 _ = @import("behavior/byval_arg_var.zig");
test/behavior/bugs/12911.zig created+11
...@@ -0,0 +1,11 @@
1const builtin = @import("builtin");
2
3const Item = struct { field: u8 };
4const Thing = struct {
5 array: [1]Item,
6};
7test {
8 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
9
10 _ = Thing{ .array = undefined };
11}