authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-03 18:15:01-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-03 18:15:01-04:00
loga81e4351a20f836d88f455843d875e45a1c73b71
tree462e53bd4cc63c091b324d015b1dabc95d3c802e
parentfc0f8d0359777580c771848361166f97a85deddd
parent1b19c28c79ac20c4b8880742172834f881b47dea
signaturelock-open Commit is signed but in an unrecognized format.

Merge branch 'fixSegfault' of https://github.com/marler8997/zig into marler8997-fixSegfault


2 files changed, 17 insertions(+), 2 deletions(-)

src/analyze.cpp+7-2
......@@ -7687,8 +7687,13 @@ static void resolve_llvm_types_union(CodeGen *g, ZigType *union_type, ResolveSta
76877687 ZigType *tag_type = union_type->data.unionation.tag_type;
76887688 uint32_t gen_field_count = union_type->data.unionation.gen_field_count;
76897689 if (gen_field_count == 0) {
7690 union_type->llvm_type = get_llvm_type(g, tag_type);
7691 union_type->llvm_di_type = get_llvm_di_type(g, tag_type);
7690 if (tag_type == nullptr) {
7691 union_type->llvm_type = g->builtin_types.entry_void->llvm_type;
7692 union_type->llvm_di_type = g->builtin_types.entry_void->llvm_di_type;
7693 } else {
7694 union_type->llvm_type = get_llvm_type(g, tag_type);
7695 union_type->llvm_di_type = get_llvm_di_type(g, tag_type);
7696 }
76927697 union_type->data.unionation.resolve_status = ResolveStatusLLVMFull;
76937698 return;
76947699 }
test/stage1/behavior/union.zig+10
......@@ -457,3 +457,13 @@ test "@unionInit can modify a pointer value" {
457457 value_ptr.* = @unionInit(UnionInitEnum, "Byte", 2);
458458 expect(value.Byte == 2);
459459}
460
461test "union no tag with struct member" {
462 const Struct = struct {};
463 const Union = union {
464 s: Struct,
465 pub fn foo(self: *@This()) void {}
466 };
467 var u = Union{ .s = Struct{} };
468 u.foo();
469}