diff --git a/src/type.zig b/src/type.zig index 43a3636ba3..632be95438 100644 --- a/src/type.zig +++ b/src/type.zig @@ -2195,7 +2195,12 @@ pub const Type = extern union { .Slice => try writer.writeAll("[]"), } if (info.@"align" != 0 or info.host_size != 0 or info.vector_index != .none) { - try writer.print("align({d}", .{info.@"align"}); + if (info.@"align" != 0) { + try writer.print("align({d}", .{info.@"align"}); + } else { + const alignment = info.pointee_type.abiAlignment(mod.getTarget()); + try writer.print("align({d}", .{alignment}); + } if (info.bit_offset != 0 or info.host_size != 0) { try writer.print(":{d}:{d}", .{ info.bit_offset, info.host_size }); diff --git a/test/cases/compile_errors/casting_bit_offset_pointer_to_regular_pointer.zig b/test/cases/compile_errors/casting_bit_offset_pointer_to_regular_pointer.zig index 7fd38280c6..f9df19802a 100644 --- a/test/cases/compile_errors/casting_bit_offset_pointer_to_regular_pointer.zig +++ b/test/cases/compile_errors/casting_bit_offset_pointer_to_regular_pointer.zig @@ -18,7 +18,7 @@ export fn entry() usize { return @sizeOf(@TypeOf(&foo)); } // backend=stage2 // target=native // -// :8:16: error: expected type '*const u3', found '*align(0:3:1) const u3' +// :8:16: error: expected type '*const u3', found '*align(1:3:1) const u3' // :8:16: note: pointer host size '1' cannot cast into pointer host size '0' // :8:16: note: pointer bit offset '3' cannot cast into pointer bit offset '0' // :11:11: note: parameter type declared here diff --git a/test/cases/compile_errors/incompatible sub-byte fields.zig b/test/cases/compile_errors/incompatible sub-byte fields.zig index 20fbf5e30c..d765b7cf45 100644 --- a/test/cases/compile_errors/incompatible sub-byte fields.zig +++ b/test/cases/compile_errors/incompatible sub-byte fields.zig @@ -24,4 +24,4 @@ export fn entry() void { // backend=stage2 // target=native // -// :14:17: error: incompatible types: '*align(0:0:1) u2' and '*align(2:8:2) u2' +// :14:17: error: incompatible types: '*align(1:0:1) u2' and '*align(2:8:2) u2'