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
1544115441 const is_allowzero_val = struct_val[6];
1544215442 const sentinel_val = struct_val[7];
1544315443
15444 const abi_align = @intCast(u29, alignment_val.toUnsignedInt(target)); // TODO: Validate this value.
15445
1544415446 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
1544715456 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
1545415463 const sentinel_ptr_val = sentinel_val.castTag(.opt_payload).?.data;
1545515464 const ptr_ty = try Type.ptr(sema.arena, mod, .{
1545615465 .@"addrspace" = .generic,
15457 .pointee_type = child_ty,
15466 .pointee_type = try elem_ty.copy(sema.arena),
1545815467 });
1545915468 actual_sentinel = (try sema.pointerDeref(block, src, sentinel_ptr_val, ptr_ty)).?;
1546015469 }
......@@ -15463,9 +15472,9 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
1546315472 .size = ptr_size,
1546415473 .mutable = !is_const_val.toBool(),
1546515474 .@"volatile" = is_volatile_val.toBool(),
15466 .@"align" = @intCast(u29, alignment_val.toUnsignedInt(target)), // TODO: Validate this value.
15475 .@"align" = abi_align,
1546715476 .@"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),
1546915478 .@"allowzero" = is_allowzero_val.toBool(),
1547015479 .sentinel = actual_sentinel,
1547115480 });
test/standalone.zig+1-3
......@@ -60,9 +60,7 @@ pub fn addCases(cases: *tests.StandaloneContext) void {
6060 }
6161 // Try to build and run a PIE executable.
6262 if (builtin.os.tag == .linux) {
63 if (builtin.zig_backend == .stage1) { // https://github.com/ziglang/zig/issues/12223
64 cases.addBuildFile("test/standalone/pie/build.zig", .{});
65 }
63 cases.addBuildFile("test/standalone/pie/build.zig", .{});
6664 }
6765
6866 // Ensure the development tools are buildable.