aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/c.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-08-21 12:25:19 +0300
committerVeikka Tuominen <git@vexu.eu>2022-08-21 12:51:40 +0300
commitd48af541c7aa235948621cdbc250d983af303977 (patch)
tree8dbe65a62e708f182371b207896ebe33cf1586b4 /src/codegen/c.zig
parente8102d8738eafb969e03b0609c60be73326610eb (diff)
downloadzig-d48af541c7aa235948621cdbc250d983af303977.tar.gz
zig-d48af541c7aa235948621cdbc250d983af303977.zip
Sema: handle union and enum field order being different
Closes #12543
Diffstat (limited to 'src/codegen/c.zig')
-rw-r--r--src/codegen/c.zig3
1 files changed, 1 insertions, 2 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()) {