| ... | @@ -1116,21 +1116,20 @@ pub const DeclGen = struct { | ... | @@ -1116,21 +1116,20 @@ pub const DeclGen = struct { |
| 1116 | return self.todo("packed union types", .{}); | 1116 | return self.todo("packed union types", .{}); |
| 1117 | } | 1117 | } |
| 1118 | | 1118 | |
| 1119 | const tag_ty_ref = try self.resolveType(union_ty.tag_ty, .indirect); | | |
| 1120 | if (layout.payload_size == 0) { | 1119 | if (layout.payload_size == 0) { |
| 1121 | // No payload, so represent this as just the tag type. | 1120 | // No payload, so represent this as just the tag type. |
| 1122 | return tag_ty_ref; | 1121 | return try self.resolveType(union_ty.tag_ty, .indirect); |
| 1123 | } | 1122 | } |
| 1124 | | 1123 | |
| 1125 | var members = std.BoundedArray(SpvType.Payload.Struct.Member, 4){}; | 1124 | var members = std.BoundedArray(SpvType.Payload.Struct.Member, 4){}; |
| 1126 | | 1125 | |
| 1127 | const has_tag = layout.tag_size != 0; | 1126 | const has_tag = layout.tag_size != 0; |
| 1128 | const tag_first = layout.tag_align >= layout.payload_align; | 1127 | const tag_first = layout.tag_align >= layout.payload_align; |
| 1129 | const tag_member = .{ .name = "tag", .ty = tag_ty_ref }; | | |
| 1130 | const u8_ty_ref = try self.intType(.unsigned, 8); // TODO: What if Int8Type is not enabled? | 1128 | const u8_ty_ref = try self.intType(.unsigned, 8); // TODO: What if Int8Type is not enabled? |
| 1131 | | 1129 | |
| 1132 | if (has_tag and tag_first) { | 1130 | if (has_tag and tag_first) { |
| 1133 | members.appendAssumeCapacity(tag_member); | 1131 | const tag_ty_ref = try self.resolveType(union_ty.tag_ty, .indirect); |
| | 1132 | members.appendAssumeCapacity(.{ .name = "tag", .ty = tag_ty_ref }); |
| 1134 | } | 1133 | } |
| 1135 | | 1134 | |
| 1136 | const active_field = maybe_active_field orelse layout.most_aligned_field; | 1135 | const active_field = maybe_active_field orelse layout.most_aligned_field; |
| ... | @@ -1149,7 +1148,8 @@ pub const DeclGen = struct { | ... | @@ -1149,7 +1148,8 @@ pub const DeclGen = struct { |
| 1149 | } | 1148 | } |
| 1150 | | 1149 | |
| 1151 | if (has_tag and !tag_first) { | 1150 | if (has_tag and !tag_first) { |
| 1152 | members.appendAssumeCapacity(tag_member); | 1151 | const tag_ty_ref = try self.resolveType(union_ty.tag_ty, .indirect); |
| | 1152 | members.appendAssumeCapacity(.{ .name = "tag", .ty = tag_ty_ref }); |
| 1153 | } | 1153 | } |
| 1154 | | 1154 | |
| 1155 | if (layout.padding != 0) { | 1155 | if (layout.padding != 0) { |