Skip to content

Commit

Permalink
LLVM lowerDebugType: Lower union types without a layout into an empty…
Browse files Browse the repository at this point in the history
… namespace
  • Loading branch information
antlilja authored Mar 17, 2024
1 parent f88a971 commit 294f518
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/codegen/llvm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2598,7 +2598,10 @@ pub const Object = struct {
defer gpa.free(name);

const union_type = ip.loadUnionType(ty.toIntern());
if (!union_type.haveFieldTypes(ip) or !ty.hasRuntimeBitsIgnoreComptime(mod)) {
if (!union_type.haveFieldTypes(ip) or
!ty.hasRuntimeBitsIgnoreComptime(mod) or
!union_type.haveLayout(ip))
{
const debug_union_type = try o.makeEmptyNamespaceDebugType(owner_decl_index);
try o.debug_type_map.put(gpa, ty, debug_union_type);
return debug_union_type;
Expand Down
15 changes: 15 additions & 0 deletions test/cases/union_unresolved_layout.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const std = @import("std");

const U = union(enum) {
foo: u8,
bar: f64,
};

pub fn main() !void {
const t = U.foo;
_ = t;
}

// run
// backend=llvm
//

0 comments on commit 294f518

Please sign in to comment.