authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-12-29 12:47:11+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-12-29 12:47:11+02:00
loge0b6140009eb3e2e53b8c90fe3973d80991bd9b8
tree0914af9cead7fabc104382bba2eb467cf5a2b702
parent8a6295fcba80be9a145d59b103b6ec8d19636b38

Type: fix printing of default alignment on non-byte aligned pointers


3 files changed, 8 insertions(+), 3 deletions(-)

src/type.zig+6-1
......@@ -2195,7 +2195,12 @@ pub const Type = extern union {
21952195 .Slice => try writer.writeAll("[]"),
21962196 }
21972197 if (info.@"align" != 0 or info.host_size != 0 or info.vector_index != .none) {
2198 try writer.print("align({d}", .{info.@"align"});
2198 if (info.@"align" != 0) {
2199 try writer.print("align({d}", .{info.@"align"});
2200 } else {
2201 const alignment = info.pointee_type.abiAlignment(mod.getTarget());
2202 try writer.print("align({d}", .{alignment});
2203 }
21992204
22002205 if (info.bit_offset != 0 or info.host_size != 0) {
22012206 try writer.print(":{d}:{d}", .{ info.bit_offset, info.host_size });
test/cases/compile_errors/casting_bit_offset_pointer_to_regular_pointer.zig+1-1
......@@ -18,7 +18,7 @@ export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
1818// backend=stage2
1919// target=native
2020//
21// :8:16: error: expected type '*const u3', found '*align(0:3:1) const u3'
21// :8:16: error: expected type '*const u3', found '*align(1:3:1) const u3'
2222// :8:16: note: pointer host size '1' cannot cast into pointer host size '0'
2323// :8:16: note: pointer bit offset '3' cannot cast into pointer bit offset '0'
2424// :11:11: note: parameter type declared here
test/cases/compile_errors/incompatible sub-byte fields.zig +1-1
......@@ -24,4 +24,4 @@ export fn entry() void {
2424// backend=stage2
2525// target=native
2626//
27// :14:17: error: incompatible types: '*align(0:0:1) u2' and '*align(2:8:2) u2'
27// :14:17: error: incompatible types: '*align(1:0:1) u2' and '*align(2:8:2) u2'