authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-09-10 02:03:37-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-09-20 18:33:01-07:00
log725dec6aa7a7ec48625d16e5ea4e2c730f73d9dd
treec2f9f26afa8d0a9dc765cd7f63cdf38514f8ad81
parent7ffe068a79577b516d54996b8bc46ce48b8eb8bf

Sema: add missed logic to checkPtrAttributes

It wasn't checking bit pointer data.

3 files changed, 19 insertions(+), 4 deletions(-)

src/Sema.zig+13
...@@ -30670,6 +30670,19 @@ fn checkPtrAttributes(sema: *Sema, dest_ty: Type, inst_ty: Type, in_memory_resul...@@ -30670,6 +30670,19 @@ fn checkPtrAttributes(sema: *Sema, dest_ty: Type, inst_ty: Type, in_memory_resul
30670 } };30670 } };
30671 return false;30671 return false;
30672 }30672 }
30673
30674 if (inst_info.packed_offset.host_size != dest_info.packed_offset.host_size or
30675 inst_info.packed_offset.bit_offset != dest_info.packed_offset.bit_offset)
30676 {
30677 in_memory_result.* = .{ .ptr_bit_range = .{
30678 .actual_host = inst_info.packed_offset.host_size,
30679 .wanted_host = dest_info.packed_offset.host_size,
30680 .actual_offset = inst_info.packed_offset.bit_offset,
30681 .wanted_offset = dest_info.packed_offset.bit_offset,
30682 } };
30683 return false;
30684 }
30685
30673 return true;30686 return true;
30674}30687}
3067530688
test/cases/compile_errors/implicitly_increasing_pointer_alignment.zig+3-2
...@@ -14,6 +14,7 @@ fn bar(x: *u32) void {...@@ -14,6 +14,7 @@ fn bar(x: *u32) void {
1414
15// error15// error
16//16//
17// :8:9: error: expected type '*u32', found '*align(1) u32'17// :8:9: error: expected type '*u32', found '*align(8:8:8) u32'
18// :8:9: note: pointer alignment '1' cannot cast into pointer alignment '4'18// :8:9: note: pointer host size '8' cannot cast into pointer host size '0'
19// :8:9: note: pointer bit offset '8' cannot cast into pointer bit offset '0'
19// :11:11: note: parameter type declared here20// :11:11: note: parameter type declared here
test/cases/compile_errors/implicitly_increasing_slice_alignment.zig+3-2
...@@ -15,5 +15,6 @@ fn bar(x: []u32) void {...@@ -15,5 +15,6 @@ fn bar(x: []u32) void {
1515
16// error16// error
17//17//
18// :9:22: error: expected type '*[1]u32', found '*align(1) u32'18// :9:22: error: expected type '*[1]u32', found '*align(8:8:8) u32'
19// :9:22: note: pointer alignment '1' cannot cast into pointer alignment '4'19// :9:22: note: pointer host size '8' cannot cast into pointer host size '0'
20// :9:22: note: pointer bit offset '8' cannot cast into pointer bit offset '0'