aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/pointers.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2023-01-19 16:30:25 +0200
committerVeikka Tuominen <git@vexu.eu>2023-01-22 00:12:37 +0200
commita492a607d5410b1136db3a63fabd01c10827144c (patch)
tree03b8a57ab199edd346ae666e890000d80721f5b3 /test/behavior/pointers.zig
parentd284c00fda45b943f4ed5244ae1cb9e7f90f481f (diff)
downloadzig-a492a607d5410b1136db3a63fabd01c10827144c.tar.gz
zig-a492a607d5410b1136db3a63fabd01c10827144c.zip
type: correct condition for eliding pointer alignment canonicalization
Closes #14373
Diffstat (limited to 'test/behavior/pointers.zig')
-rw-r--r--test/behavior/pointers.zig15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/behavior/pointers.zig b/test/behavior/pointers.zig
index c8879453ad..d93e991889 100644
--- a/test/behavior/pointers.zig
+++ b/test/behavior/pointers.zig
@@ -532,3 +532,18 @@ test "pointer alignment and element type include call expression" {
};
try expect(@alignOf(S.P) > 0);
}
+
+test "pointer to array has explicit alignment" {
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
+
+ const S = struct {
+ const Base = extern struct { a: u8 };
+ const Base2 = extern struct { a: u8 };
+ fn func(ptr: *[4]Base) *align(1) [4]Base2 {
+ return @alignCast(1, @ptrCast(*[4]Base2, ptr));
+ }
+ };
+ var bases = [_]S.Base{.{ .a = 2 }} ** 4;
+ const casted = S.func(&bases);
+ try expect(casted[0].a == 2);
+}