llvm: fix lowering of packed structs with optional pointers
Closes #20022
2 files changed, 8 insertions(+), 0 deletions(-)
src/codegen/llvm.zig+1
| ... | ... | @@ -3775,6 +3775,7 @@ pub const Object = struct { |
| 3775 | 3775 | .float, |
| 3776 | 3776 | .enum_tag, |
| 3777 | 3777 | => {}, |
| 3778 | .opt => {}, // pointer like optional expected |
| 3778 | 3779 | else => unreachable, |
| 3779 | 3780 | } |
| 3780 | 3781 | const bits = ty.bitSize(mod); |
test/behavior/packed-struct.zig+7
| ... | ... | @@ -1304,3 +1304,10 @@ test "2-byte packed struct argument in C calling convention" { |
| 1304 | 1304 | try S.bar(s); |
| 1305 | 1305 | } |
| 1306 | 1306 | } |
| 1307 | |
| 1308 | test "packed struct contains optional pointer" { |
| 1309 | const foo: packed struct { |
| 1310 | a: ?*@This() = null, |
| 1311 | } = .{}; |
| 1312 | try expect(foo.a == null); |
| 1313 | } |