Merge pull request #20023 from Vexu/fixes

Minor LLVM backend fixes
This commit is contained in:
Veikka Tuominen 2024-05-22 11:54:38 +03:00 committed by GitHub
commit 5fe9f88b13
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -3775,6 +3775,7 @@ pub const Object = struct {
.float,
.enum_tag,
=> {},
.opt => {}, // pointer like optional expected
else => unreachable,
}
const bits = ty.bitSize(mod);
@ -4376,7 +4377,7 @@ pub const Object = struct {
.int => try o.builder.castConst(
.inttoptr,
try o.builder.intConst(try o.lowerType(Type.usize), offset),
.ptr,
try o.lowerType(Type.fromInterned(ptr.ty)),
),
.eu_payload => |eu_ptr| try o.lowerPtr(
eu_ptr,

View File

@ -1304,3 +1304,10 @@ test "2-byte packed struct argument in C calling convention" {
try S.bar(s);
}
}
test "packed struct contains optional pointer" {
const foo: packed struct {
a: ?*@This() = null,
} = .{};
try expect(foo.a == null);
}