x86_64: fix incorrect handling of unreusable operands

Closes #23448
This commit is contained in:
Jacob Young
2025-04-03 12:09:07 -04:00
committed by Andrew Kelley
parent 95fdbc579f
commit 9827ffe1de
2 changed files with 55 additions and 4 deletions
+43 -1
View File
@@ -1527,7 +1527,7 @@ test "optional generic function label struct field" {
}
test "struct fields get automatically reordered" {
if (builtin.zig_backend != .stage2_llvm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
const S1 = struct {
a: u32,
@@ -2137,3 +2137,45 @@ test "anonymous struct equivalence" {
comptime assert(A != C);
comptime assert(B != C);
}
test "field access through mem ptr arg" {
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
const S = struct {
fn nestedFieldAccess(
_: usize,
_: usize,
_: usize,
_: usize,
_: usize,
_: usize,
_: usize,
_: usize,
ptr_struct: *const struct { field: u32 },
) u32 {
return ptr_struct.field;
}
};
try expect(S.nestedFieldAccess(
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
&.{ .field = 0x6b00a2eb },
) == 0x6b00a2eb);
comptime assert(S.nestedFieldAccess(
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
&.{ .field = 0x0ced271f },
) == 0x0ced271f);
}