aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/spirv.zig
diff options
context:
space:
mode:
authorkcbanner <kcbanner@gmail.com>2023-09-20 23:53:06 -0400
committerkcbanner <kcbanner@gmail.com>2023-09-23 13:04:56 -0400
commit2fddd767ba20374e7677003c101e60f470c3804c (patch)
tree91ffbed5086771488201cebd82be6e1554ac14b5 /src/codegen/spirv.zig
parentce919ccf45951856a762ffdb8ef850301cd8c588 (diff)
downloadzig-2fddd767ba20374e7677003c101e60f470c3804c.tar.gz
zig-2fddd767ba20374e7677003c101e60f470c3804c.zip
sema: add support for unions in readFromMemory and writeToMemory
Diffstat (limited to 'src/codegen/spirv.zig')
-rw-r--r--src/codegen/spirv.zig5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig
index 33a864ea0a..8fb6153938 100644
--- a/src/codegen/spirv.zig
+++ b/src/codegen/spirv.zig
@@ -838,7 +838,10 @@ pub const DeclGen = struct {
return dg.todo("packed union constants", .{});
}
- const active_field = ty.unionTagFieldIndex(un.tag.toValue(), dg.module).?;
+ const active_field = ty.unionTagFieldIndex(un.tag.toValue(), dg.module) orelse f: {
+ assert(union_obj.getLayout(ip) == .Extern);
+ break :f mod.unionLargestField(union_obj).index;
+ };
const active_field_ty = union_obj.field_types.get(ip)[active_field].toType();
const has_tag = layout.tag_size != 0;