authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2024-05-21 19:51:08+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2024-05-21 19:52:25+03:00
logf776e70c3967da637d5488b6a8efaa8377680208
tree1cd5595095f7c404ea38f22ce39b255ccd0b7aca
parent167854c19c8072270187b91314a5481363af4e12

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,6 +3775,7 @@ pub const Object = struct {
3775 .float,3775 .float,
3776 .enum_tag,3776 .enum_tag,
3777 => {},3777 => {},
3778 .opt => {}, // pointer like optional expected
3778 else => unreachable,3779 else => unreachable,
3779 }3780 }
3780 const bits = ty.bitSize(mod);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,3 +1304,10 @@ test "2-byte packed struct argument in C calling convention" {
1304 try S.bar(s);1304 try S.bar(s);
1305 }1305 }
1306}1306}
1307
1308test "packed struct contains optional pointer" {
1309 const foo: packed struct {
1310 a: ?*@This() = null,
1311 } = .{};
1312 try expect(foo.a == null);
1313}