diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2024-03-18 15:00:27 +0100 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2024-03-30 20:50:48 -0400 |
| commit | 9b2345e182090e2f4c57e7684ec9739f195fdb1d (patch) | |
| tree | 291857693683d092b886a59fb2fa37fefee981ec /test/behavior/struct.zig | |
| parent | 5a41704f7ec2c472897f955ecfe1feafa697ff68 (diff) | |
| download | zig-9b2345e182090e2f4c57e7684ec9739f195fdb1d.tar.gz zig-9b2345e182090e2f4c57e7684ec9739f195fdb1d.zip | |
Sema: rework `@fieldParentPtr` to accept a pointer type
There is no way to know the expected parent pointer attributes (most
notably alignment) from the type of the field pointer, so provide them
in the first argument.
Diffstat (limited to 'test/behavior/struct.zig')
| -rw-r--r-- | test/behavior/struct.zig | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/test/behavior/struct.zig b/test/behavior/struct.zig index f85e783342..cbf7493b86 100644 --- a/test/behavior/struct.zig +++ b/test/behavior/struct.zig @@ -1392,13 +1392,13 @@ test "fieldParentPtr of a zero-bit field" { { const a = A{ .u = 0 }; const b_ptr = &a.b; - const a_ptr = @fieldParentPtr(A, "b", b_ptr); + const a_ptr = @fieldParentPtr(*const A, "b", b_ptr); try std.testing.expectEqual(&a, a_ptr); } { var a = A{ .u = 0 }; const b_ptr = &a.b; - const a_ptr = @fieldParentPtr(A, "b", b_ptr); + const a_ptr = @fieldParentPtr(*const A, "b", b_ptr); try std.testing.expectEqual(&a, a_ptr); } } @@ -1406,17 +1406,17 @@ test "fieldParentPtr of a zero-bit field" { { const a = A{ .u = 0 }; const c_ptr = &a.b.c; - const b_ptr = @fieldParentPtr(@TypeOf(a.b), "c", c_ptr); + const b_ptr = @fieldParentPtr(*const @TypeOf(a.b), "c", c_ptr); try std.testing.expectEqual(&a.b, b_ptr); - const a_ptr = @fieldParentPtr(A, "b", b_ptr); + const a_ptr = @fieldParentPtr(*const A, "b", b_ptr); try std.testing.expectEqual(&a, a_ptr); } { var a = A{ .u = 0 }; const c_ptr = &a.b.c; - const b_ptr = @fieldParentPtr(@TypeOf(a.b), "c", c_ptr); + const b_ptr = @fieldParentPtr(*const @TypeOf(a.b), "c", c_ptr); try std.testing.expectEqual(&a.b, b_ptr); - const a_ptr = @fieldParentPtr(A, "b", b_ptr); + const a_ptr = @fieldParentPtr(*const A, "b", b_ptr); try std.testing.expectEqual(&a, a_ptr); } } |
