aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/struct.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2024-03-18 15:00:27 +0100
committerJacob Young <jacobly0@users.noreply.github.com>2024-03-30 20:50:48 -0400
commit9b2345e182090e2f4c57e7684ec9739f195fdb1d (patch)
tree291857693683d092b886a59fb2fa37fefee981ec /test/behavior/struct.zig
parent5a41704f7ec2c472897f955ecfe1feafa697ff68 (diff)
downloadzig-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.zig12
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);
}
}