1var alignment: u29 = 4;
2
3var global: u8 align(alignment) = 0;
4export fn globalWithRuntimeAlign() u8 {
5 return global;
6}
7
8export fn localWithRuntimeAlign() u8 {
9 const local: u8 align(alignment) = 0;
10 return local;
11}
12
13export fn destructureWithRuntimeAlign() u8 {
14 const de: u8 align(alignment), const structure align(alignment) = .{ 0, 0 };
15 return de | structure;
16}
17
18export fn structFieldWithRuntimeAlign() u8 {
19 const @"struct": struct { field: u8 align(alignment) } = .{ .field = 0 };
20 return @"struct".field;
21}
22
23export fn unionFieldWithRuntimeAlign() u8 {
24 const @"union": union { field: u8 align(alignment) } = .{ .field = 0 };
25 return @"union".field;
26}
27
28export fn pointerWithRuntimeAlign() u8 {
29 const ptr: *align(alignment) u8 = &global;
30 return ptr.*;
31}
32
33// error
34//
35// :3:22: error: unable to resolve comptime value
36// :3:22: note: alignment must be comptime-known
37// :9:27: error: unable to resolve comptime value
38// :9:27: note: alignment must be comptime-known
39// :14:24: error: unable to resolve comptime value
40// :14:24: note: alignment must be comptime-known
41// :19:47: error: unable to resolve comptime value
42// :19:47: note: alignment must be comptime-known
43// :24:45: error: unable to resolve comptime value
44// :24:45: note: alignment must be comptime-known
45// :29:23: error: unable to resolve comptime value
46// :29:23: note: alignment must be comptime-known