| ... | ... | @@ -2136,3 +2136,21 @@ test "field access through mem ptr arg" { |
| 2136 | 2136 | &.{ .field = 0x0ced271f }, |
| 2137 | 2137 | ) == 0x0ced271f); |
| 2138 | 2138 | } |
| 2139 | |
| 2140 | test "align 1 struct parameter dereferenced and returned" { |
| 2141 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 2142 | |
| 2143 | const S = extern struct { |
| 2144 | a: u32, |
| 2145 | |
| 2146 | fn gimme(p: *align(1) @This()) @This() { |
| 2147 | return p.*; |
| 2148 | } |
| 2149 | }; |
| 2150 | var buffer: [5]u8 align(4) = .{ 1, 2, 3, 4, 5 }; |
| 2151 | const s = S.gimme(@ptrCast(buffer[1..])); |
| 2152 | switch (native_endian) { |
| 2153 | .big => try expect(s.a == 0x02030405), |
| 2154 | .little => try expect(s.a == 0x05040302), |
| 2155 | } |
| 2156 | } |