diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-08-21 12:25:19 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-08-21 12:51:40 +0300 |
| commit | d48af541c7aa235948621cdbc250d983af303977 (patch) | |
| tree | 8dbe65a62e708f182371b207896ebe33cf1586b4 /src/codegen | |
| parent | e8102d8738eafb969e03b0609c60be73326610eb (diff) | |
| download | zig-d48af541c7aa235948621cdbc250d983af303977.tar.gz zig-d48af541c7aa235948621cdbc250d983af303977.zip | |
Sema: handle union and enum field order being different
Closes #12543
Diffstat (limited to 'src/codegen')
| -rw-r--r-- | src/codegen/c.zig | 3 | ||||
| -rw-r--r-- | src/codegen/llvm.zig | 2 |
2 files changed, 2 insertions, 3 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 81a892183f..4a09c09cc9 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -835,7 +835,6 @@ pub const DeclGen = struct { }, .Union => { const union_obj = val.castTag(.@"union").?.data; - const union_ty = ty.cast(Type.Payload.Union).?.data; const layout = ty.unionGetLayout(target); try writer.writeAll("("); @@ -851,7 +850,7 @@ pub const DeclGen = struct { try writer.writeAll(".payload = {"); } - const index = union_ty.tag_ty.enumTagFieldIndex(union_obj.tag, dg.module).?; + const index = ty.unionTagFieldIndex(union_obj.tag, dg.module).?; const field_ty = ty.unionFields().values()[index].ty; const field_name = ty.unionFields().keys()[index]; if (field_ty.hasRuntimeBits()) { diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index d50b463606..5c537cd5bc 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -3502,7 +3502,7 @@ pub const DeclGen = struct { }); } const union_obj = tv.ty.cast(Type.Payload.Union).?.data; - const field_index = union_obj.tag_ty.enumTagFieldIndex(tag_and_val.tag, dg.module).?; + const field_index = tv.ty.unionTagFieldIndex(tag_and_val.tag, dg.module).?; assert(union_obj.haveFieldTypes()); // Sometimes we must make an unnamed struct because LLVM does |
