mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
stage2: fix type printing of sub-byte pointers
This commit is contained in:
parent
93d7fd9547
commit
434226c89d
@ -1843,7 +1843,7 @@ pub const Type = extern union {
|
||||
if (payload.@"align" != 0 or payload.host_size != 0) {
|
||||
try writer.print("align({d}", .{payload.@"align"});
|
||||
|
||||
if (payload.bit_offset != 0) {
|
||||
if (payload.bit_offset != 0 or payload.host_size != 0) {
|
||||
try writer.print(":{d}:{d}", .{ payload.bit_offset, payload.host_size });
|
||||
}
|
||||
try writer.writeAll(") ");
|
||||
@ -2167,7 +2167,7 @@ pub const Type = extern union {
|
||||
if (info.@"align" != 0 or info.host_size != 0) {
|
||||
try writer.print("align({d}", .{info.@"align"});
|
||||
|
||||
if (info.bit_offset != 0) {
|
||||
if (info.bit_offset != 0 or info.host_size != 0) {
|
||||
try writer.print(":{d}:{d}", .{ info.bit_offset, info.host_size });
|
||||
}
|
||||
try writer.writeAll(") ");
|
||||
|
||||
@ -27,7 +27,6 @@ test {
|
||||
_ = @import("behavior/bugs/1025.zig");
|
||||
_ = @import("behavior/bugs/1076.zig");
|
||||
_ = @import("behavior/bugs/1111.zig");
|
||||
_ = @import("behavior/bugs/1120.zig");
|
||||
_ = @import("behavior/bugs/1277.zig");
|
||||
_ = @import("behavior/bugs/1310.zig");
|
||||
_ = @import("behavior/bugs/1381.zig");
|
||||
|
||||
@ -1,6 +1,3 @@
|
||||
const std = @import("std");
|
||||
const expect = std.testing.expect;
|
||||
|
||||
const A = packed struct {
|
||||
a: u2,
|
||||
b: u6,
|
||||
@ -10,9 +7,7 @@ const B = packed struct {
|
||||
a: u2,
|
||||
b: u6,
|
||||
};
|
||||
test "bug 1120" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
|
||||
export fn entry() void {
|
||||
var a = A{ .a = 2, .b = 2 };
|
||||
var b = B{ .q = 22, .a = 3, .b = 2 };
|
||||
var t: usize = 0;
|
||||
@ -21,5 +16,12 @@ test "bug 1120" {
|
||||
1 => &b.a,
|
||||
else => unreachable,
|
||||
};
|
||||
try expect(ptr.* == 2);
|
||||
if (ptr.* == 2) {
|
||||
@compileError("wrong compile error");
|
||||
}
|
||||
}
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :14:17: error: incompatible types: '*align(0:0:1) u2' and '*align(2:8:2) u2'
|
||||
Loading…
x
Reference in New Issue
Block a user