authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2024-05-22 11:54:38+03:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-05-22 11:54:38+03:00
log5fe9f88b13f37e14fcb91e155e3e686eccb89dfc
tree1f53670faa2339589215047c9ffd6d39449c81e1
parent6635360dbdbd6793b741648d51d25f12550e01db
parentf776e70c3967da637d5488b6a8efaa8377680208
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #20023 from Vexu/fixes

Minor LLVM backend fixes

2 files changed, 9 insertions(+), 1 deletions(-)

src/codegen/llvm.zig+2-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);
...@@ -4376,7 +4377,7 @@ pub const Object = struct {...@@ -4376,7 +4377,7 @@ pub const Object = struct {
4376 .int => try o.builder.castConst(4377 .int => try o.builder.castConst(
4377 .inttoptr,4378 .inttoptr,
4378 try o.builder.intConst(try o.lowerType(Type.usize), offset),4379 try o.builder.intConst(try o.lowerType(Type.usize), offset),
4379 .ptr,4380 try o.lowerType(Type.fromInterned(ptr.ty)),
4380 ),4381 ),
4381 .eu_payload => |eu_ptr| try o.lowerPtr(4382 .eu_payload => |eu_ptr| try o.lowerPtr(
4382 eu_ptr,4383 eu_ptr,
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}