authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-07-27 14:29:24+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-07-27 17:11:46+03:00
log3818d63dd8b29596e4c3d2499463b7519258a611
treea51ae09640492b69a7843a4e0860989ba779fdb2
parente4a36a4cec12efe8a0128229a839dcd8b95b298d

Sema: resolve pointee type in zirReify

Closes #12223

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

src/Sema.zig+13-4
...@@ -15441,8 +15441,17 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I...@@ -15441,8 +15441,17 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
15441 const is_allowzero_val = struct_val[6];15441 const is_allowzero_val = struct_val[6];
15442 const sentinel_val = struct_val[7];15442 const sentinel_val = struct_val[7];
1544315443
15444 const abi_align = @intCast(u29, alignment_val.toUnsignedInt(target)); // TODO: Validate this value.
15445
15444 var buffer: Value.ToTypeBuffer = undefined;15446 var buffer: Value.ToTypeBuffer = undefined;
15445 const child_ty = child_val.toType(&buffer);15447 const unresolved_elem_ty = child_val.toType(&buffer);
15448 const elem_ty = if (abi_align == 0)
15449 unresolved_elem_ty
15450 else t: {
15451 const elem_ty = try sema.resolveTypeFields(block, src, unresolved_elem_ty);
15452 try sema.resolveTypeLayout(block, src, elem_ty);
15453 break :t elem_ty;
15454 };
1544615455
15447 const ptr_size = size_val.toEnum(std.builtin.Type.Pointer.Size);15456 const ptr_size = size_val.toEnum(std.builtin.Type.Pointer.Size);
1544815457
...@@ -15454,7 +15463,7 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I...@@ -15454,7 +15463,7 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
15454 const sentinel_ptr_val = sentinel_val.castTag(.opt_payload).?.data;15463 const sentinel_ptr_val = sentinel_val.castTag(.opt_payload).?.data;
15455 const ptr_ty = try Type.ptr(sema.arena, mod, .{15464 const ptr_ty = try Type.ptr(sema.arena, mod, .{
15456 .@"addrspace" = .generic,15465 .@"addrspace" = .generic,
15457 .pointee_type = child_ty,15466 .pointee_type = try elem_ty.copy(sema.arena),
15458 });15467 });
15459 actual_sentinel = (try sema.pointerDeref(block, src, sentinel_ptr_val, ptr_ty)).?;15468 actual_sentinel = (try sema.pointerDeref(block, src, sentinel_ptr_val, ptr_ty)).?;
15460 }15469 }
...@@ -15463,9 +15472,9 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I...@@ -15463,9 +15472,9 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
15463 .size = ptr_size,15472 .size = ptr_size,
15464 .mutable = !is_const_val.toBool(),15473 .mutable = !is_const_val.toBool(),
15465 .@"volatile" = is_volatile_val.toBool(),15474 .@"volatile" = is_volatile_val.toBool(),
15466 .@"align" = @intCast(u29, alignment_val.toUnsignedInt(target)), // TODO: Validate this value.15475 .@"align" = abi_align,
15467 .@"addrspace" = address_space_val.toEnum(std.builtin.AddressSpace),15476 .@"addrspace" = address_space_val.toEnum(std.builtin.AddressSpace),
15468 .pointee_type = try child_ty.copy(sema.arena),15477 .pointee_type = try elem_ty.copy(sema.arena),
15469 .@"allowzero" = is_allowzero_val.toBool(),15478 .@"allowzero" = is_allowzero_val.toBool(),
15470 .sentinel = actual_sentinel,15479 .sentinel = actual_sentinel,
15471 });15480 });
test/standalone.zig+1-3
...@@ -60,9 +60,7 @@ pub fn addCases(cases: *tests.StandaloneContext) void {...@@ -60,9 +60,7 @@ pub fn addCases(cases: *tests.StandaloneContext) void {
60 }60 }
61 // Try to build and run a PIE executable.61 // Try to build and run a PIE executable.
62 if (builtin.os.tag == .linux) {62 if (builtin.os.tag == .linux) {
63 if (builtin.zig_backend == .stage1) { // https://github.com/ziglang/zig/issues/1222363 cases.addBuildFile("test/standalone/pie/build.zig", .{});
64 cases.addBuildFile("test/standalone/pie/build.zig", .{});
65 }
66 }64 }
6765
68 // Ensure the development tools are buildable.66 // Ensure the development tools are buildable.