Commit 37afab2add
Changed files (2)
src
test
behavior
src/Sema.zig
@@ -26005,6 +26005,7 @@ fn analyzeDeclRef(sema: *Sema, decl_index: Decl.Index) CompileError!Air.Inst.Ref
.pointee_type = decl_tv.ty,
.mutable = false,
.@"addrspace" = decl.@"addrspace",
+ .@"align" = decl.@"align",
}),
try Value.Tag.decl_ref.create(sema.arena, decl_index),
);
test/behavior/pointers.zig
@@ -486,3 +486,14 @@ test "array slicing to slice" {
try S.doTheTest();
comptime try S.doTheTest();
}
+
+test "pointer to constant decl preserves alignment" {
+ const S = struct {
+ a: u8,
+ b: u8,
+ const aligned align(8) = @This(){ .a = 3, .b = 4 };
+ };
+
+ const alignment = @typeInfo(@TypeOf(&S.aligned)).Pointer.alignment;
+ try std.testing.expect(alignment == 8);
+}