authorgravatar for tristan.ross@midstall.comTristan Ross <tristan.ross@midstall.com> 2024-02-18 18:28:39-08:00
committergravatar for tristan.ross@midstall.comTristan Ross <tristan.ross@midstall.com> 2024-03-11 07:09:07-07:00
log099f3c4039d5702b073639ef8b55881973b71c80
tree2be1bb7abc86fb4c9148b82314718eac6a01e895
parentd0c06ca7127110a8afeb0ef524a197049892db21
signaturelock-open Commit is signed but in an unrecognized format.

std.builtin: make container layout fields lowercase


45 files changed, 291 insertions(+), 293 deletions(-)

lib/compiler/aro/aro/Attribute.zig+1-1
...@@ -653,7 +653,7 @@ pub const Arguments = blk: {...@@ -653,7 +653,7 @@ pub const Arguments = blk: {
653653
654 break :blk @Type(.{654 break :blk @Type(.{
655 .Union = .{655 .Union = .{
656 .layout = .Auto,656 .layout = .auto,
657 .tag_type = null,657 .tag_type = null,
658 .fields = &union_fields,658 .fields = &union_fields,
659 .decls = &.{},659 .decls = &.{},
lib/std/builtin.zig+4-4
...@@ -334,9 +334,9 @@ pub const Type = union(enum) {...@@ -334,9 +334,9 @@ pub const Type = union(enum) {
334 /// This data structure is used by the Zig language code generation and334 /// This data structure is used by the Zig language code generation and
335 /// therefore must be kept in sync with the compiler implementation.335 /// therefore must be kept in sync with the compiler implementation.
336 pub const ContainerLayout = enum(u2) {336 pub const ContainerLayout = enum(u2) {
337 Auto,337 auto,
338 Extern,338 @"extern",
339 Packed,339 @"packed",
340 };340 };
341341
342 /// This data structure is used by the Zig language code generation and342 /// This data structure is used by the Zig language code generation and
...@@ -353,7 +353,7 @@ pub const Type = union(enum) {...@@ -353,7 +353,7 @@ pub const Type = union(enum) {
353 /// therefore must be kept in sync with the compiler implementation.353 /// therefore must be kept in sync with the compiler implementation.
354 pub const Struct = struct {354 pub const Struct = struct {
355 layout: ContainerLayout,355 layout: ContainerLayout,
356 /// Only valid if layout is .Packed356 /// Only valid if layout is .@"packed"
357 backing_integer: ?type = null,357 backing_integer: ?type = null,
358 fields: []const StructField,358 fields: []const StructField,
359 decls: []const Declaration,359 decls: []const Declaration,
lib/std/enums.zig+1-1
...@@ -22,7 +22,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def...@@ -22,7 +22,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def
22 }};22 }};
23 }23 }
24 return @Type(.{ .Struct = .{24 return @Type(.{ .Struct = .{
25 .layout = .Auto,25 .layout = .auto,
26 .fields = fields,26 .fields = fields,
27 .decls = &.{},27 .decls = &.{},
28 .is_tuple = false,28 .is_tuple = false,
lib/std/io.zig+1-1
...@@ -688,7 +688,7 @@ pub fn PollFiles(comptime StreamEnum: type) type {...@@ -688,7 +688,7 @@ pub fn PollFiles(comptime StreamEnum: type) type {
688 };688 };
689 }689 }
690 return @Type(.{ .Struct = .{690 return @Type(.{ .Struct = .{
691 .layout = .Auto,691 .layout = .auto,
692 .fields = &struct_fields,692 .fields = &struct_fields,
693 .decls = &.{},693 .decls = &.{},
694 .is_tuple = false,694 .is_tuple = false,
lib/std/io/Reader.zig+1-1
...@@ -326,7 +326,7 @@ pub fn isBytes(self: Self, slice: []const u8) anyerror!bool {...@@ -326,7 +326,7 @@ pub fn isBytes(self: Self, slice: []const u8) anyerror!bool {
326326
327pub fn readStruct(self: Self, comptime T: type) anyerror!T {327pub fn readStruct(self: Self, comptime T: type) anyerror!T {
328 // Only extern and packed structs have defined in-memory layout.328 // Only extern and packed structs have defined in-memory layout.
329 comptime assert(@typeInfo(T).Struct.layout != .Auto);329 comptime assert(@typeInfo(T).Struct.layout != .auto);
330 var res: [1]T = undefined;330 var res: [1]T = undefined;
331 try self.readNoEof(mem.sliceAsBytes(res[0..]));331 try self.readNoEof(mem.sliceAsBytes(res[0..]));
332 return res[0];332 return res[0];
lib/std/io/Writer.zig+1-1
...@@ -55,7 +55,7 @@ pub inline fn writeInt(self: Self, comptime T: type, value: T, endian: std.built...@@ -55,7 +55,7 @@ pub inline fn writeInt(self: Self, comptime T: type, value: T, endian: std.built
5555
56pub fn writeStruct(self: Self, value: anytype) anyerror!void {56pub fn writeStruct(self: Self, value: anytype) anyerror!void {
57 // Only extern and packed structs have defined in-memory layout.57 // Only extern and packed structs have defined in-memory layout.
58 comptime assert(@typeInfo(@TypeOf(value)).Struct.layout != .Auto);58 comptime assert(@typeInfo(@TypeOf(value)).Struct.layout != .auto);
59 return self.writeAll(mem.asBytes(&value));59 return self.writeAll(mem.asBytes(&value));
60}60}
6161
lib/std/mem.zig+3-3
...@@ -238,7 +238,7 @@ pub fn zeroes(comptime T: type) T {...@@ -238,7 +238,7 @@ pub fn zeroes(comptime T: type) T {
238 },238 },
239 .Struct => |struct_info| {239 .Struct => |struct_info| {
240 if (@sizeOf(T) == 0) return undefined;240 if (@sizeOf(T) == 0) return undefined;
241 if (struct_info.layout == .Extern) {241 if (struct_info.layout == .@"extern") {
242 var item: T = undefined;242 var item: T = undefined;
243 @memset(asBytes(&item), 0);243 @memset(asBytes(&item), 0);
244 return item;244 return item;
...@@ -284,7 +284,7 @@ pub fn zeroes(comptime T: type) T {...@@ -284,7 +284,7 @@ pub fn zeroes(comptime T: type) T {
284 return @splat(zeroes(info.child));284 return @splat(zeroes(info.child));
285 },285 },
286 .Union => |info| {286 .Union => |info| {
287 if (info.layout == .Extern) {287 if (info.layout == .@"extern") {
288 var item: T = undefined;288 var item: T = undefined;
289 @memset(asBytes(&item), 0);289 @memset(asBytes(&item), 0);
290 return item;290 return item;
...@@ -429,7 +429,7 @@ pub fn zeroInit(comptime T: type, init: anytype) T {...@@ -429,7 +429,7 @@ pub fn zeroInit(comptime T: type, init: anytype) T {
429 }429 }
430 }430 }
431431
432 var value: T = if (struct_info.layout == .Extern) zeroes(T) else undefined;432 var value: T = if (struct_info.layout == .@"extern") zeroes(T) else undefined;
433433
434 inline for (struct_info.fields, 0..) |field, i| {434 inline for (struct_info.fields, 0..) |field, i| {
435 if (field.is_comptime) {435 if (field.is_comptime) {
lib/std/meta.zig+7-7
...@@ -269,12 +269,12 @@ test containerLayout {...@@ -269,12 +269,12 @@ test containerLayout {
269 a: u8,269 a: u8,
270 };270 };
271271
272 try testing.expect(containerLayout(S1) == .Auto);272 try testing.expect(containerLayout(S1) == .auto);
273 try testing.expect(containerLayout(S2) == .Packed);273 try testing.expect(containerLayout(S2) == .@"packed");
274 try testing.expect(containerLayout(S3) == .Extern);274 try testing.expect(containerLayout(S3) == .@"extern");
275 try testing.expect(containerLayout(U1) == .Auto);275 try testing.expect(containerLayout(U1) == .auto);
276 try testing.expect(containerLayout(U2) == .Packed);276 try testing.expect(containerLayout(U2) == .@"packed");
277 try testing.expect(containerLayout(U3) == .Extern);277 try testing.expect(containerLayout(U3) == .@"extern");
278}278}
279279
280/// Instead of this function, prefer to use e.g. `@typeInfo(foo).Struct.decls`280/// Instead of this function, prefer to use e.g. `@typeInfo(foo).Struct.decls`
...@@ -1025,7 +1025,7 @@ fn CreateUniqueTuple(comptime N: comptime_int, comptime types: [N]type) type {...@@ -1025,7 +1025,7 @@ fn CreateUniqueTuple(comptime N: comptime_int, comptime types: [N]type) type {
1025 return @Type(.{1025 return @Type(.{
1026 .Struct = .{1026 .Struct = .{
1027 .is_tuple = true,1027 .is_tuple = true,
1028 .layout = .Auto,1028 .layout = .auto,
1029 .decls = &.{},1029 .decls = &.{},
1030 .fields = &tuple_fields,1030 .fields = &tuple_fields,
1031 },1031 },
lib/std/meta/trailer_flags.zig+1-1
...@@ -32,7 +32,7 @@ pub fn TrailerFlags(comptime Fields: type) type {...@@ -32,7 +32,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
32 }32 }
33 break :blk @Type(.{33 break :blk @Type(.{
34 .Struct = .{34 .Struct = .{
35 .layout = .Auto,35 .layout = .auto,
36 .fields = &fields,36 .fields = &fields,
37 .decls = &.{},37 .decls = &.{},
38 .is_tuple = false,38 .is_tuple = false,
lib/std/multi_array_list.zig+1-1
...@@ -558,7 +558,7 @@ pub fn MultiArrayList(comptime T: type) type {...@@ -558,7 +558,7 @@ pub fn MultiArrayList(comptime T: type) type {
558 .alignment = fields[i].alignment,558 .alignment = fields[i].alignment,
559 };559 };
560 break :entry @Type(.{ .Struct = .{560 break :entry @Type(.{ .Struct = .{
561 .layout = .Extern,561 .layout = .@"extern",
562 .fields = &entry_fields,562 .fields = &entry_fields,
563 .decls = &.{},563 .decls = &.{},
564 .is_tuple = false,564 .is_tuple = false,
lib/std/zig/AstGen.zig+20-21
...@@ -175,7 +175,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {...@@ -175,7 +175,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {
175 &gen_scope.base,175 &gen_scope.base,
176 0,176 0,
177 tree.containerDeclRoot(),177 tree.containerDeclRoot(),
178 .Auto,178 .auto,
179 0,179 0,
180 )) |struct_decl_ref| {180 )) |struct_decl_ref| {
181 assert(struct_decl_ref.toIndex().? == .main_struct_inst);181 assert(struct_decl_ref.toIndex().? == .main_struct_inst);
...@@ -4907,7 +4907,7 @@ fn structDeclInner(...@@ -4907,7 +4907,7 @@ fn structDeclInner(
4907 var backing_int_body_len: usize = 0;4907 var backing_int_body_len: usize = 0;
4908 const backing_int_ref: Zir.Inst.Ref = blk: {4908 const backing_int_ref: Zir.Inst.Ref = blk: {
4909 if (backing_int_node != 0) {4909 if (backing_int_node != 0) {
4910 if (layout != .Packed) {4910 if (layout != .@"packed") {
4911 return astgen.failNode(backing_int_node, "non-packed struct does not support backing integer type", .{});4911 return astgen.failNode(backing_int_node, "non-packed struct does not support backing integer type", .{});
4912 } else {4912 } else {
4913 const backing_int_ref = try typeExpr(&block_scope, &namespace.base, backing_int_node);4913 const backing_int_ref = try typeExpr(&block_scope, &namespace.base, backing_int_node);
...@@ -4958,9 +4958,9 @@ fn structDeclInner(...@@ -4958,9 +4958,9 @@ fn structDeclInner(
4958 } else false;4958 } else false;
49594959
4960 if (is_tuple) switch (layout) {4960 if (is_tuple) switch (layout) {
4961 .Auto => {},4961 .auto => {},
4962 .Extern => return astgen.failNode(node, "extern tuples are not supported", .{}),4962 .@"extern" => return astgen.failNode(node, "extern tuples are not supported", .{}),
4963 .Packed => return astgen.failNode(node, "packed tuples are not supported", .{}),4963 .@"packed" => return astgen.failNode(node, "packed tuples are not supported", .{}),
4964 };4964 };
49654965
4966 if (is_tuple) for (container_decl.ast.members) |member_node| {4966 if (is_tuple) for (container_decl.ast.members) |member_node| {
...@@ -5055,9 +5055,9 @@ fn structDeclInner(...@@ -5055,9 +5055,9 @@ fn structDeclInner(
50555055
5056 if (is_comptime) {5056 if (is_comptime) {
5057 switch (layout) {5057 switch (layout) {
5058 .Packed => return astgen.failTok(member.comptime_token.?, "packed struct fields cannot be marked comptime", .{}),5058 .@"packed" => return astgen.failTok(member.comptime_token.?, "packed struct fields cannot be marked comptime", .{}),
5059 .Extern => return astgen.failTok(member.comptime_token.?, "extern struct fields cannot be marked comptime", .{}),5059 .@"extern" => return astgen.failTok(member.comptime_token.?, "extern struct fields cannot be marked comptime", .{}),
5060 .Auto => any_comptime_fields = true,5060 .auto => any_comptime_fields = true,
5061 }5061 }
5062 } else {5062 } else {
5063 known_non_opv = known_non_opv or5063 known_non_opv = known_non_opv or
...@@ -5082,7 +5082,7 @@ fn structDeclInner(...@@ -5082,7 +5082,7 @@ fn structDeclInner(
5082 }5082 }
50835083
5084 if (have_align) {5084 if (have_align) {
5085 if (layout == .Packed) {5085 if (layout == .@"packed") {
5086 try astgen.appendErrorNode(member.ast.align_expr, "unable to override alignment of packed struct fields", .{});5086 try astgen.appendErrorNode(member.ast.align_expr, "unable to override alignment of packed struct fields", .{});
5087 }5087 }
5088 any_aligned_fields = true;5088 any_aligned_fields = true;
...@@ -5229,12 +5229,11 @@ fn unionDeclInner(...@@ -5229,12 +5229,11 @@ fn unionDeclInner(
5229 const decl_count = try astgen.scanDecls(&namespace, members);5229 const decl_count = try astgen.scanDecls(&namespace, members);
5230 const field_count: u32 = @intCast(members.len - decl_count);5230 const field_count: u32 = @intCast(members.len - decl_count);
52315231
5232 if (layout != .Auto and (auto_enum_tok != null or arg_node != 0)) {5232 if (layout != .auto and (auto_enum_tok != null or arg_node != 0)) {
5233 const layout_str = if (layout == .Extern) "extern" else "packed";
5234 if (arg_node != 0) {5233 if (arg_node != 0) {
5235 return astgen.failNode(arg_node, "{s} union does not support enum tag type", .{layout_str});5234 return astgen.failNode(arg_node, "{s} union does not support enum tag type", .{@tagName(layout)});
5236 } else {5235 } else {
5237 return astgen.failTok(auto_enum_tok.?, "{s} union does not support enum tag type", .{layout_str});5236 return astgen.failTok(auto_enum_tok.?, "{s} union does not support enum tag type", .{@tagName(layout)});
5238 }5237 }
5239 }5238 }
52405239
...@@ -5429,21 +5428,21 @@ fn containerDecl(...@@ -5429,21 +5428,21 @@ fn containerDecl(
54295428
5430 switch (token_tags[container_decl.ast.main_token]) {5429 switch (token_tags[container_decl.ast.main_token]) {
5431 .keyword_struct => {5430 .keyword_struct => {
5432 const layout = if (container_decl.layout_token) |t| switch (token_tags[t]) {5431 const layout: std.builtin.Type.ContainerLayout = if (container_decl.layout_token) |t| switch (token_tags[t]) {
5433 .keyword_packed => std.builtin.Type.ContainerLayout.Packed,5432 .keyword_packed => .@"packed",
5434 .keyword_extern => std.builtin.Type.ContainerLayout.Extern,5433 .keyword_extern => .@"extern",
5435 else => unreachable,5434 else => unreachable,
5436 } else std.builtin.Type.ContainerLayout.Auto;5435 } else .auto;
54375436
5438 const result = try structDeclInner(gz, scope, node, container_decl, layout, container_decl.ast.arg);5437 const result = try structDeclInner(gz, scope, node, container_decl, layout, container_decl.ast.arg);
5439 return rvalue(gz, ri, result, node);5438 return rvalue(gz, ri, result, node);
5440 },5439 },
5441 .keyword_union => {5440 .keyword_union => {
5442 const layout = if (container_decl.layout_token) |t| switch (token_tags[t]) {5441 const layout: std.builtin.Type.ContainerLayout = if (container_decl.layout_token) |t| switch (token_tags[t]) {
5443 .keyword_packed => std.builtin.Type.ContainerLayout.Packed,5442 .keyword_packed => .@"packed",
5444 .keyword_extern => std.builtin.Type.ContainerLayout.Extern,5443 .keyword_extern => .@"extern",
5445 else => unreachable,5444 else => unreachable,
5446 } else std.builtin.Type.ContainerLayout.Auto;5445 } else .auto;
54475446
5448 const result = try unionDeclInner(gz, scope, node, container_decl.ast.members, layout, container_decl.ast.arg, container_decl.ast.enum_token);5447 const result = try unionDeclInner(gz, scope, node, container_decl.ast.members, layout, container_decl.ast.arg, container_decl.ast.enum_token);
5449 return rvalue(gz, ri, result, node);5448 return rvalue(gz, ri, result, node);
lib/std/zig/Server.zig+3-3
...@@ -250,18 +250,18 @@ fn bswap(x: anytype) @TypeOf(x) {...@@ -250,18 +250,18 @@ fn bswap(x: anytype) @TypeOf(x) {
250 .Enum => return @as(T, @enumFromInt(@byteSwap(@intFromEnum(x)))),250 .Enum => return @as(T, @enumFromInt(@byteSwap(@intFromEnum(x)))),
251 .Int => return @byteSwap(x),251 .Int => return @byteSwap(x),
252 .Struct => |info| switch (info.layout) {252 .Struct => |info| switch (info.layout) {
253 .Extern => {253 .@"extern" => {
254 var result: T = undefined;254 var result: T = undefined;
255 inline for (info.fields) |field| {255 inline for (info.fields) |field| {
256 @field(result, field.name) = bswap(@field(x, field.name));256 @field(result, field.name) = bswap(@field(x, field.name));
257 }257 }
258 return result;258 return result;
259 },259 },
260 .Packed => {260 .@"packed" => {
261 const I = info.backing_integer.?;261 const I = info.backing_integer.?;
262 return @as(T, @bitCast(@byteSwap(@as(I, @bitCast(x)))));262 return @as(T, @bitCast(@byteSwap(@as(I, @bitCast(x)))));
263 },263 },
264 .Auto => @compileError("auto layout struct"),264 .auto => @compileError("auto layout struct"),
265 },265 },
266 else => @compileError("bswap on type " ++ @typeName(T)),266 else => @compileError("bswap on type " ++ @typeName(T)),
267 }267 }
src/InternPool.zig+35-36
...@@ -2025,15 +2025,15 @@ pub const LoadedStructType = struct {...@@ -2025,15 +2025,15 @@ pub const LoadedStructType = struct {
2025 /// complicated logic.2025 /// complicated logic.
2026 pub fn knownNonOpv(s: @This(), ip: *InternPool) bool {2026 pub fn knownNonOpv(s: @This(), ip: *InternPool) bool {
2027 return switch (s.layout) {2027 return switch (s.layout) {
2028 .Packed => false,2028 .@"packed" => false,
2029 .Auto, .Extern => s.flagsPtr(ip).known_non_opv,2029 .auto, .@"extern" => s.flagsPtr(ip).known_non_opv,
2030 };2030 };
2031 }2031 }
20322032
2033 /// The returned pointer expires with any addition to the `InternPool`.2033 /// The returned pointer expires with any addition to the `InternPool`.
2034 /// Asserts the struct is not packed.2034 /// Asserts the struct is not packed.
2035 pub fn flagsPtr(self: @This(), ip: *const InternPool) *Tag.TypeStruct.Flags {2035 pub fn flagsPtr(self: @This(), ip: *const InternPool) *Tag.TypeStruct.Flags {
2036 assert(self.layout != .Packed);2036 assert(self.layout != .@"packed");
2037 const flags_field_index = std.meta.fieldIndex(Tag.TypeStruct, "flags").?;2037 const flags_field_index = std.meta.fieldIndex(Tag.TypeStruct, "flags").?;
2038 return @ptrCast(&ip.extra.items[self.extra_index + flags_field_index]);2038 return @ptrCast(&ip.extra.items[self.extra_index + flags_field_index]);
2039 }2039 }
...@@ -2041,13 +2041,13 @@ pub const LoadedStructType = struct {...@@ -2041,13 +2041,13 @@ pub const LoadedStructType = struct {
2041 /// The returned pointer expires with any addition to the `InternPool`.2041 /// The returned pointer expires with any addition to the `InternPool`.
2042 /// Asserts that the struct is packed.2042 /// Asserts that the struct is packed.
2043 pub fn packedFlagsPtr(self: @This(), ip: *const InternPool) *Tag.TypeStructPacked.Flags {2043 pub fn packedFlagsPtr(self: @This(), ip: *const InternPool) *Tag.TypeStructPacked.Flags {
2044 assert(self.layout == .Packed);2044 assert(self.layout == .@"packed");
2045 const flags_field_index = std.meta.fieldIndex(Tag.TypeStructPacked, "flags").?;2045 const flags_field_index = std.meta.fieldIndex(Tag.TypeStructPacked, "flags").?;
2046 return @ptrCast(&ip.extra.items[self.extra_index + flags_field_index]);2046 return @ptrCast(&ip.extra.items[self.extra_index + flags_field_index]);
2047 }2047 }
20482048
2049 pub fn assumeRuntimeBitsIfFieldTypesWip(s: @This(), ip: *InternPool) bool {2049 pub fn assumeRuntimeBitsIfFieldTypesWip(s: @This(), ip: *InternPool) bool {
2050 if (s.layout == .Packed) return false;2050 if (s.layout == .@"packed") return false;
2051 const flags_ptr = s.flagsPtr(ip);2051 const flags_ptr = s.flagsPtr(ip);
2052 if (flags_ptr.field_types_wip) {2052 if (flags_ptr.field_types_wip) {
2053 flags_ptr.assumed_runtime_bits = true;2053 flags_ptr.assumed_runtime_bits = true;
...@@ -2057,7 +2057,7 @@ pub const LoadedStructType = struct {...@@ -2057,7 +2057,7 @@ pub const LoadedStructType = struct {
2057 }2057 }
20582058
2059 pub fn setTypesWip(s: @This(), ip: *InternPool) bool {2059 pub fn setTypesWip(s: @This(), ip: *InternPool) bool {
2060 if (s.layout == .Packed) return false;2060 if (s.layout == .@"packed") return false;
2061 const flags_ptr = s.flagsPtr(ip);2061 const flags_ptr = s.flagsPtr(ip);
2062 if (flags_ptr.field_types_wip) return true;2062 if (flags_ptr.field_types_wip) return true;
2063 flags_ptr.field_types_wip = true;2063 flags_ptr.field_types_wip = true;
...@@ -2065,12 +2065,12 @@ pub const LoadedStructType = struct {...@@ -2065,12 +2065,12 @@ pub const LoadedStructType = struct {
2065 }2065 }
20662066
2067 pub fn clearTypesWip(s: @This(), ip: *InternPool) void {2067 pub fn clearTypesWip(s: @This(), ip: *InternPool) void {
2068 if (s.layout == .Packed) return;2068 if (s.layout == .@"packed") return;
2069 s.flagsPtr(ip).field_types_wip = false;2069 s.flagsPtr(ip).field_types_wip = false;
2070 }2070 }
20712071
2072 pub fn setLayoutWip(s: @This(), ip: *InternPool) bool {2072 pub fn setLayoutWip(s: @This(), ip: *InternPool) bool {
2073 if (s.layout == .Packed) return false;2073 if (s.layout == .@"packed") return false;
2074 const flags_ptr = s.flagsPtr(ip);2074 const flags_ptr = s.flagsPtr(ip);
2075 if (flags_ptr.layout_wip) return true;2075 if (flags_ptr.layout_wip) return true;
2076 flags_ptr.layout_wip = true;2076 flags_ptr.layout_wip = true;
...@@ -2078,12 +2078,12 @@ pub const LoadedStructType = struct {...@@ -2078,12 +2078,12 @@ pub const LoadedStructType = struct {
2078 }2078 }
20792079
2080 pub fn clearLayoutWip(s: @This(), ip: *InternPool) void {2080 pub fn clearLayoutWip(s: @This(), ip: *InternPool) void {
2081 if (s.layout == .Packed) return;2081 if (s.layout == .@"packed") return;
2082 s.flagsPtr(ip).layout_wip = false;2082 s.flagsPtr(ip).layout_wip = false;
2083 }2083 }
20842084
2085 pub fn setAlignmentWip(s: @This(), ip: *InternPool) bool {2085 pub fn setAlignmentWip(s: @This(), ip: *InternPool) bool {
2086 if (s.layout == .Packed) return false;2086 if (s.layout == .@"packed") return false;
2087 const flags_ptr = s.flagsPtr(ip);2087 const flags_ptr = s.flagsPtr(ip);
2088 if (flags_ptr.alignment_wip) return true;2088 if (flags_ptr.alignment_wip) return true;
2089 flags_ptr.alignment_wip = true;2089 flags_ptr.alignment_wip = true;
...@@ -2091,19 +2091,19 @@ pub const LoadedStructType = struct {...@@ -2091,19 +2091,19 @@ pub const LoadedStructType = struct {
2091 }2091 }
20922092
2093 pub fn clearAlignmentWip(s: @This(), ip: *InternPool) void {2093 pub fn clearAlignmentWip(s: @This(), ip: *InternPool) void {
2094 if (s.layout == .Packed) return;2094 if (s.layout == .@"packed") return;
2095 s.flagsPtr(ip).alignment_wip = false;2095 s.flagsPtr(ip).alignment_wip = false;
2096 }2096 }
20972097
2098 pub fn setInitsWip(s: @This(), ip: *InternPool) bool {2098 pub fn setInitsWip(s: @This(), ip: *InternPool) bool {
2099 switch (s.layout) {2099 switch (s.layout) {
2100 .Packed => {2100 .@"packed" => {
2101 const flag = &s.packedFlagsPtr(ip).field_inits_wip;2101 const flag = &s.packedFlagsPtr(ip).field_inits_wip;
2102 if (flag.*) return true;2102 if (flag.*) return true;
2103 flag.* = true;2103 flag.* = true;
2104 return false;2104 return false;
2105 },2105 },
2106 .Auto, .Extern => {2106 .auto, .@"extern" => {
2107 const flag = &s.flagsPtr(ip).field_inits_wip;2107 const flag = &s.flagsPtr(ip).field_inits_wip;
2108 if (flag.*) return true;2108 if (flag.*) return true;
2109 flag.* = true;2109 flag.* = true;
...@@ -2114,13 +2114,13 @@ pub const LoadedStructType = struct {...@@ -2114,13 +2114,13 @@ pub const LoadedStructType = struct {
21142114
2115 pub fn clearInitsWip(s: @This(), ip: *InternPool) void {2115 pub fn clearInitsWip(s: @This(), ip: *InternPool) void {
2116 switch (s.layout) {2116 switch (s.layout) {
2117 .Packed => s.packedFlagsPtr(ip).field_inits_wip = false,2117 .@"packed" => s.packedFlagsPtr(ip).field_inits_wip = false,
2118 .Auto, .Extern => s.flagsPtr(ip).field_inits_wip = false,2118 .auto, .@"extern" => s.flagsPtr(ip).field_inits_wip = false,
2119 }2119 }
2120 }2120 }
21212121
2122 pub fn setFullyResolved(s: @This(), ip: *InternPool) bool {2122 pub fn setFullyResolved(s: @This(), ip: *InternPool) bool {
2123 if (s.layout == .Packed) return true;2123 if (s.layout == .@"packed") return true;
2124 const flags_ptr = s.flagsPtr(ip);2124 const flags_ptr = s.flagsPtr(ip);
2125 if (flags_ptr.fully_resolved) return true;2125 if (flags_ptr.fully_resolved) return true;
2126 flags_ptr.fully_resolved = true;2126 flags_ptr.fully_resolved = true;
...@@ -2134,7 +2134,7 @@ pub const LoadedStructType = struct {...@@ -2134,7 +2134,7 @@ pub const LoadedStructType = struct {
2134 /// The returned pointer expires with any addition to the `InternPool`.2134 /// The returned pointer expires with any addition to the `InternPool`.
2135 /// Asserts the struct is not packed.2135 /// Asserts the struct is not packed.
2136 pub fn size(self: @This(), ip: *InternPool) *u32 {2136 pub fn size(self: @This(), ip: *InternPool) *u32 {
2137 assert(self.layout != .Packed);2137 assert(self.layout != .@"packed");
2138 const size_field_index = std.meta.fieldIndex(Tag.TypeStruct, "size").?;2138 const size_field_index = std.meta.fieldIndex(Tag.TypeStruct, "size").?;
2139 return @ptrCast(&ip.extra.items[self.extra_index + size_field_index]);2139 return @ptrCast(&ip.extra.items[self.extra_index + size_field_index]);
2140 }2140 }
...@@ -2144,14 +2144,14 @@ pub const LoadedStructType = struct {...@@ -2144,14 +2144,14 @@ pub const LoadedStructType = struct {
2144 /// set to `none` until the layout is resolved.2144 /// set to `none` until the layout is resolved.
2145 /// Asserts the struct is packed.2145 /// Asserts the struct is packed.
2146 pub fn backingIntType(s: @This(), ip: *const InternPool) *Index {2146 pub fn backingIntType(s: @This(), ip: *const InternPool) *Index {
2147 assert(s.layout == .Packed);2147 assert(s.layout == .@"packed");
2148 const field_index = std.meta.fieldIndex(Tag.TypeStructPacked, "backing_int_ty").?;2148 const field_index = std.meta.fieldIndex(Tag.TypeStructPacked, "backing_int_ty").?;
2149 return @ptrCast(&ip.extra.items[s.extra_index + field_index]);2149 return @ptrCast(&ip.extra.items[s.extra_index + field_index]);
2150 }2150 }
21512151
2152 /// Asserts the struct is not packed.2152 /// Asserts the struct is not packed.
2153 pub fn setZirIndex(s: @This(), ip: *InternPool, new_zir_index: TrackedInst.Index.Optional) void {2153 pub fn setZirIndex(s: @This(), ip: *InternPool, new_zir_index: TrackedInst.Index.Optional) void {
2154 assert(s.layout != .Packed);2154 assert(s.layout != .@"packed");
2155 const field_index = std.meta.fieldIndex(Tag.TypeStruct, "zir_index").?;2155 const field_index = std.meta.fieldIndex(Tag.TypeStruct, "zir_index").?;
2156 ip.extra.items[s.extra_index + field_index] = @intFromEnum(new_zir_index);2156 ip.extra.items[s.extra_index + field_index] = @intFromEnum(new_zir_index);
2157 }2157 }
...@@ -2163,31 +2163,31 @@ pub const LoadedStructType = struct {...@@ -2163,31 +2163,31 @@ pub const LoadedStructType = struct {
21632163
2164 pub fn haveFieldInits(s: @This(), ip: *const InternPool) bool {2164 pub fn haveFieldInits(s: @This(), ip: *const InternPool) bool {
2165 return switch (s.layout) {2165 return switch (s.layout) {
2166 .Packed => s.packedFlagsPtr(ip).inits_resolved,2166 .@"packed" => s.packedFlagsPtr(ip).inits_resolved,
2167 .Auto, .Extern => s.flagsPtr(ip).inits_resolved,2167 .auto, .@"extern" => s.flagsPtr(ip).inits_resolved,
2168 };2168 };
2169 }2169 }
21702170
2171 pub fn setHaveFieldInits(s: @This(), ip: *InternPool) void {2171 pub fn setHaveFieldInits(s: @This(), ip: *InternPool) void {
2172 switch (s.layout) {2172 switch (s.layout) {
2173 .Packed => s.packedFlagsPtr(ip).inits_resolved = true,2173 .@"packed" => s.packedFlagsPtr(ip).inits_resolved = true,
2174 .Auto, .Extern => s.flagsPtr(ip).inits_resolved = true,2174 .auto, .@"extern" => s.flagsPtr(ip).inits_resolved = true,
2175 }2175 }
2176 }2176 }
21772177
2178 pub fn haveLayout(s: @This(), ip: *InternPool) bool {2178 pub fn haveLayout(s: @This(), ip: *InternPool) bool {
2179 return switch (s.layout) {2179 return switch (s.layout) {
2180 .Packed => s.backingIntType(ip).* != .none,2180 .@"packed" => s.backingIntType(ip).* != .none,
2181 .Auto, .Extern => s.flagsPtr(ip).layout_resolved,2181 .auto, .@"extern" => s.flagsPtr(ip).layout_resolved,
2182 };2182 };
2183 }2183 }
21842184
2185 pub fn isTuple(s: @This(), ip: *InternPool) bool {2185 pub fn isTuple(s: @This(), ip: *InternPool) bool {
2186 return s.layout != .Packed and s.flagsPtr(ip).is_tuple;2186 return s.layout != .@"packed" and s.flagsPtr(ip).is_tuple;
2187 }2187 }
21882188
2189 pub fn hasReorderedFields(s: @This()) bool {2189 pub fn hasReorderedFields(s: @This()) bool {
2190 return s.layout == .Auto;2190 return s.layout == .auto;
2191 }2191 }
21922192
2193 pub const RuntimeOrderIterator = struct {2193 pub const RuntimeOrderIterator = struct {
...@@ -2221,7 +2221,7 @@ pub const LoadedStructType = struct {...@@ -2221,7 +2221,7 @@ pub const LoadedStructType = struct {
2221 /// May or may not include zero-bit fields.2221 /// May or may not include zero-bit fields.
2222 /// Asserts the struct is not packed.2222 /// Asserts the struct is not packed.
2223 pub fn iterateRuntimeOrder(s: @This(), ip: *InternPool) RuntimeOrderIterator {2223 pub fn iterateRuntimeOrder(s: @This(), ip: *InternPool) RuntimeOrderIterator {
2224 assert(s.layout != .Packed);2224 assert(s.layout != .@"packed");
2225 return .{2225 return .{
2226 .ip = ip,2226 .ip = ip,
2227 .field_index = 0,2227 .field_index = 0,
...@@ -2239,7 +2239,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {...@@ -2239,7 +2239,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {
2239 .decl = .none,2239 .decl = .none,
2240 .namespace = .none,2240 .namespace = .none,
2241 .zir_index = .none,2241 .zir_index = .none,
2242 .layout = .Auto,2242 .layout = .auto,
2243 .field_names = .{ .start = 0, .len = 0 },2243 .field_names = .{ .start = 0, .len = 0 },
2244 .field_types = .{ .start = 0, .len = 0 },2244 .field_types = .{ .start = 0, .len = 0 },
2245 .field_inits = .{ .start = 0, .len = 0 },2245 .field_inits = .{ .start = 0, .len = 0 },
...@@ -2314,7 +2314,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {...@@ -2314,7 +2314,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {
2314 .decl = extra.data.decl.toOptional(),2314 .decl = extra.data.decl.toOptional(),
2315 .namespace = namespace,2315 .namespace = namespace,
2316 .zir_index = extra.data.zir_index.toOptional(),2316 .zir_index = extra.data.zir_index.toOptional(),
2317 .layout = if (extra.data.flags.is_extern) .Extern else .Auto,2317 .layout = if (extra.data.flags.is_extern) .@"extern" else .auto,
2318 .field_names = names,2318 .field_names = names,
2319 .field_types = field_types,2319 .field_types = field_types,
2320 .field_inits = inits,2320 .field_inits = inits,
...@@ -2367,7 +2367,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {...@@ -2367,7 +2367,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {
2367 .decl = extra.data.decl.toOptional(),2367 .decl = extra.data.decl.toOptional(),
2368 .namespace = extra.data.namespace,2368 .namespace = extra.data.namespace,
2369 .zir_index = extra.data.zir_index.toOptional(),2369 .zir_index = extra.data.zir_index.toOptional(),
2370 .layout = .Packed,2370 .layout = .@"packed",
2371 .field_names = field_names,2371 .field_names = field_names,
2372 .field_types = field_types,2372 .field_types = field_types,
2373 .field_inits = field_inits,2373 .field_inits = field_inits,
...@@ -4455,7 +4455,6 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {...@@ -4455,7 +4455,6 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
4455 } else .{ .start = 0, .len = 0 } },4455 } else .{ .start = 0, .len = 0 } },
4456 } };4456 } };
4457 } },4457 } },
4458
4459 .type_struct_anon => .{ .anon_struct_type = extraTypeStructAnon(ip, data) },4458 .type_struct_anon => .{ .anon_struct_type = extraTypeStructAnon(ip, data) },
4460 .type_tuple_anon => .{ .anon_struct_type = extraTypeTupleAnon(ip, data) },4459 .type_tuple_anon => .{ .anon_struct_type = extraTypeTupleAnon(ip, data) },
4461 .type_union => .{ .union_type = ns: {4460 .type_union => .{ .union_type = ns: {
...@@ -6009,9 +6008,9 @@ pub fn getStructType(...@@ -6009,9 +6008,9 @@ pub fn getStructType(
6009 };6008 };
60106009
6011 const is_extern = switch (ini.layout) {6010 const is_extern = switch (ini.layout) {
6012 .Auto => false,6011 .auto => false,
6013 .Extern => true,6012 .@"extern" => true,
6014 .Packed => {6013 .@"packed" => {
6015 try ip.extra.ensureUnusedCapacity(gpa, @typeInfo(Tag.TypeStructPacked).Struct.fields.len +6014 try ip.extra.ensureUnusedCapacity(gpa, @typeInfo(Tag.TypeStructPacked).Struct.fields.len +
6016 // TODO: fmt bug6015 // TODO: fmt bug
6017 // zig fmt: off6016 // zig fmt: off
...@@ -6140,7 +6139,7 @@ pub fn getStructType(...@@ -6140,7 +6139,7 @@ pub fn getStructType(
6140 if (ini.any_comptime_fields) {6139 if (ini.any_comptime_fields) {
6141 ip.extra.appendNTimesAssumeCapacity(0, comptime_elements_len);6140 ip.extra.appendNTimesAssumeCapacity(0, comptime_elements_len);
6142 }6141 }
6143 if (ini.layout == .Auto) {6142 if (ini.layout == .auto) {
6144 ip.extra.appendNTimesAssumeCapacity(@intFromEnum(LoadedStructType.RuntimeOrder.unresolved), ini.fields_len);6143 ip.extra.appendNTimesAssumeCapacity(@intFromEnum(LoadedStructType.RuntimeOrder.unresolved), ini.fields_len);
6145 }6144 }
6146 ip.extra.appendNTimesAssumeCapacity(std.math.maxInt(u32), ini.fields_len);6145 ip.extra.appendNTimesAssumeCapacity(std.math.maxInt(u32), ini.fields_len);
src/Module.zig+8-8
...@@ -3310,7 +3310,7 @@ fn getFileRootStruct(zcu: *Zcu, decl_index: Decl.Index, namespace_index: Namespa...@@ -3310,7 +3310,7 @@ fn getFileRootStruct(zcu: *Zcu, decl_index: Decl.Index, namespace_index: Namespa
3310 const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small);3310 const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small);
3311 assert(!small.has_captures_len);3311 assert(!small.has_captures_len);
3312 assert(!small.has_backing_int);3312 assert(!small.has_backing_int);
3313 assert(small.layout == .Auto);3313 assert(small.layout == .auto);
3314 var extra_index: usize = extended.operand + @typeInfo(Zir.Inst.StructDecl).Struct.fields.len;3314 var extra_index: usize = extended.operand + @typeInfo(Zir.Inst.StructDecl).Struct.fields.len;
3315 const fields_len = if (small.has_fields_len) blk: {3315 const fields_len = if (small.has_fields_len) blk: {
3316 const fields_len = file.zir.extra[extra_index];3316 const fields_len = file.zir.extra[extra_index];
...@@ -3327,7 +3327,7 @@ fn getFileRootStruct(zcu: *Zcu, decl_index: Decl.Index, namespace_index: Namespa...@@ -3327,7 +3327,7 @@ fn getFileRootStruct(zcu: *Zcu, decl_index: Decl.Index, namespace_index: Namespa
33273327
3328 const tracked_inst = try ip.trackZir(gpa, file, .main_struct_inst);3328 const tracked_inst = try ip.trackZir(gpa, file, .main_struct_inst);
3329 const wip_ty = switch (try ip.getStructType(gpa, .{3329 const wip_ty = switch (try ip.getStructType(gpa, .{
3330 .layout = .Auto,3330 .layout = .auto,
3331 .fields_len = fields_len,3331 .fields_len = fields_len,
3332 .known_non_opv = small.known_non_opv,3332 .known_non_opv = small.known_non_opv,
3333 .requires_comptime = if (small.known_comptime_only) .yes else .unknown,3333 .requires_comptime = if (small.known_comptime_only) .yes else .unknown,
...@@ -5969,7 +5969,7 @@ pub fn typeToStruct(mod: *Module, ty: Type) ?InternPool.LoadedStructType {...@@ -5969,7 +5969,7 @@ pub fn typeToStruct(mod: *Module, ty: Type) ?InternPool.LoadedStructType {
59695969
5970pub fn typeToPackedStruct(mod: *Module, ty: Type) ?InternPool.LoadedStructType {5970pub fn typeToPackedStruct(mod: *Module, ty: Type) ?InternPool.LoadedStructType {
5971 const s = mod.typeToStruct(ty) orelse return null;5971 const s = mod.typeToStruct(ty) orelse return null;
5972 if (s.layout != .Packed) return null;5972 if (s.layout != .@"packed") return null;
5973 return s;5973 return s;
5974}5974}
59755975
...@@ -6185,18 +6185,18 @@ pub fn structFieldAlignment(...@@ -6185,18 +6185,18 @@ pub fn structFieldAlignment(
6185 field_ty: Type,6185 field_ty: Type,
6186 layout: std.builtin.Type.ContainerLayout,6186 layout: std.builtin.Type.ContainerLayout,
6187) Alignment {6187) Alignment {
6188 assert(layout != .Packed);6188 assert(layout != .@"packed");
6189 if (explicit_alignment != .none) return explicit_alignment;6189 if (explicit_alignment != .none) return explicit_alignment;
6190 switch (layout) {6190 switch (layout) {
6191 .Packed => unreachable,6191 .@"packed" => unreachable,
6192 .Auto => {6192 .auto => {
6193 if (mod.getTarget().ofmt == .c) {6193 if (mod.getTarget().ofmt == .c) {
6194 return structFieldAlignmentExtern(mod, field_ty);6194 return structFieldAlignmentExtern(mod, field_ty);
6195 } else {6195 } else {
6196 return field_ty.abiAlignment(mod);6196 return field_ty.abiAlignment(mod);
6197 }6197 }
6198 },6198 },
6199 .Extern => return structFieldAlignmentExtern(mod, field_ty),6199 .@"extern" => return structFieldAlignmentExtern(mod, field_ty),
6200 }6200 }
6201}6201}
62026202
...@@ -6224,7 +6224,7 @@ pub fn structPackedFieldBitOffset(...@@ -6224,7 +6224,7 @@ pub fn structPackedFieldBitOffset(
6224 field_index: u32,6224 field_index: u32,
6225) u16 {6225) u16 {
6226 const ip = &mod.intern_pool;6226 const ip = &mod.intern_pool;
6227 assert(struct_type.layout == .Packed);6227 assert(struct_type.layout == .@"packed");
6228 assert(struct_type.haveLayout(ip));6228 assert(struct_type.haveLayout(ip));
6229 var bit_sum: u64 = 0;6229 var bit_sum: u64 = 0;
6230 for (0..struct_type.field_types.len) |i| {6230 for (0..struct_type.field_types.len) |i| {
src/Sema.zig+54-54
...@@ -3236,7 +3236,7 @@ fn zirUnionDecl(...@@ -3236,7 +3236,7 @@ fn zirUnionDecl(
3236 .status = .none,3236 .status = .none,
3237 .runtime_tag = if (small.has_tag_type or small.auto_enum_tag)3237 .runtime_tag = if (small.has_tag_type or small.auto_enum_tag)
3238 .tagged3238 .tagged
3239 else if (small.layout != .Auto)3239 else if (small.layout != .auto)
3240 .none3240 .none
3241 else switch (block.wantSafety()) {3241 else switch (block.wantSafety()) {
3242 true => .safety,3242 true => .safety,
...@@ -10380,7 +10380,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -10380,7 +10380,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
10380 };10380 };
10381 return sema.failWithOwnedErrorMsg(block, msg);10381 return sema.failWithOwnedErrorMsg(block, msg);
10382 },10382 },
10383 .Struct, .Union => if (dest_ty.containerLayout(mod) == .Auto) {10383 .Struct, .Union => if (dest_ty.containerLayout(mod) == .auto) {
10384 const container = switch (dest_ty.zigTypeTag(mod)) {10384 const container = switch (dest_ty.zigTypeTag(mod)) {
10385 .Struct => "struct",10385 .Struct => "struct",
10386 .Union => "union",10386 .Union => "union",
...@@ -10443,7 +10443,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -10443,7 +10443,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
10443 };10443 };
10444 return sema.failWithOwnedErrorMsg(block, msg);10444 return sema.failWithOwnedErrorMsg(block, msg);
10445 },10445 },
10446 .Struct, .Union => if (operand_ty.containerLayout(mod) == .Auto) {10446 .Struct, .Union => if (operand_ty.containerLayout(mod) == .auto) {
10447 const container = switch (operand_ty.zigTypeTag(mod)) {10447 const container = switch (operand_ty.zigTypeTag(mod)) {
10448 .Struct => "struct",10448 .Struct => "struct",
10449 .Union => "union",10449 .Union => "union",
...@@ -18131,8 +18131,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -18131,8 +18131,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
18131 };18131 };
1813218132
18133 const alignment = switch (layout) {18133 const alignment = switch (layout) {
18134 .Auto, .Extern => try sema.unionFieldAlignment(union_obj, @intCast(i)),18134 .auto, .@"extern" => try sema.unionFieldAlignment(union_obj, @intCast(i)),
18135 .Packed => .none,18135 .@"packed" => .none,
18136 };18136 };
1813718137
18138 const field_ty = union_obj.field_types.get(ip)[i];18138 const field_ty = union_obj.field_types.get(ip)[i];
...@@ -18350,7 +18350,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -18350,7 +18350,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
18350 const opt_default_val = if (field_init == .none) null else Value.fromInterned(field_init);18350 const opt_default_val = if (field_init == .none) null else Value.fromInterned(field_init);
18351 const default_val_ptr = try sema.optRefValue(opt_default_val);18351 const default_val_ptr = try sema.optRefValue(opt_default_val);
18352 const alignment = switch (struct_type.layout) {18352 const alignment = switch (struct_type.layout) {
18353 .Packed => .none,18353 .@"packed" => .none,
18354 else => try sema.structFieldAlignment(18354 else => try sema.structFieldAlignment(
18355 struct_type.fieldAlign(ip, i),18355 struct_type.fieldAlign(ip, i),
18356 field_ty,18356 field_ty,
...@@ -19906,7 +19906,7 @@ fn zirStructInit(...@@ -19906,7 +19906,7 @@ fn zirStructInit(
19906 var field_i: u32 = 0;19906 var field_i: u32 = 0;
19907 var extra_index = extra.end;19907 var extra_index = extra.end;
1990819908
19909 const is_packed = resolved_ty.containerLayout(mod) == .Packed;19909 const is_packed = resolved_ty.containerLayout(mod) == .@"packed";
19910 while (field_i < extra.data.fields_len) : (field_i += 1) {19910 while (field_i < extra.data.fields_len) : (field_i += 1) {
19911 const item = sema.code.extraData(Zir.Inst.StructInit.Item, extra_index);19911 const item = sema.code.extraData(Zir.Inst.StructInit.Item, extra_index);
19912 extra_index = item.end;19912 extra_index = item.end;
...@@ -21302,7 +21302,7 @@ fn zirReify(...@@ -21302,7 +21302,7 @@ fn zirReify(
21302 return sema.fail(block, src, "reified structs must have no decls", .{});21302 return sema.fail(block, src, "reified structs must have no decls", .{});
21303 }21303 }
2130421304
21305 if (layout != .Packed and !backing_integer_val.isNull(mod)) {21305 if (layout != .@"packed" and !backing_integer_val.isNull(mod)) {
21306 return sema.fail(block, src, "non-packed struct does not support backing integer type", .{});21306 return sema.fail(block, src, "non-packed struct does not support backing integer type", .{});
21307 }21307 }
2130821308
...@@ -21665,7 +21665,7 @@ fn reifyUnion(...@@ -21665,7 +21665,7 @@ fn reifyUnion(
21665 .status = .none,21665 .status = .none,
21666 .runtime_tag = if (opt_tag_type_val.optionalValue(mod) != null)21666 .runtime_tag = if (opt_tag_type_val.optionalValue(mod) != null)
21667 .tagged21667 .tagged
21668 else if (layout != .Auto)21668 else if (layout != .auto)
21669 .none21669 .none
21670 else switch (block.wantSafety()) {21670 else switch (block.wantSafety()) {
21671 true => .safety,21671 true => .safety,
...@@ -21804,7 +21804,7 @@ fn reifyUnion(...@@ -21804,7 +21804,7 @@ fn reifyUnion(
21804 break :msg msg;21804 break :msg msg;
21805 });21805 });
21806 }21806 }
21807 if (layout == .Extern and !try sema.validateExternType(field_ty, .union_field)) {21807 if (layout == .@"extern" and !try sema.validateExternType(field_ty, .union_field)) {
21808 return sema.failWithOwnedErrorMsg(block, msg: {21808 return sema.failWithOwnedErrorMsg(block, msg: {
21809 const msg = try sema.errMsg(block, src, "extern unions cannot contain fields of type '{}'", .{field_ty.fmt(mod)});21809 const msg = try sema.errMsg(block, src, "extern unions cannot contain fields of type '{}'", .{field_ty.fmt(mod)});
21810 errdefer msg.destroy(gpa);21810 errdefer msg.destroy(gpa);
...@@ -21815,7 +21815,7 @@ fn reifyUnion(...@@ -21815,7 +21815,7 @@ fn reifyUnion(
21815 try sema.addDeclaredHereNote(msg, field_ty);21815 try sema.addDeclaredHereNote(msg, field_ty);
21816 break :msg msg;21816 break :msg msg;
21817 });21817 });
21818 } else if (layout == .Packed and !try sema.validatePackedType(field_ty)) {21818 } else if (layout == .@"packed" and !try sema.validatePackedType(field_ty)) {
21819 return sema.failWithOwnedErrorMsg(block, msg: {21819 return sema.failWithOwnedErrorMsg(block, msg: {
21820 const msg = try sema.errMsg(block, src, "packed unions cannot contain fields of type '{}'", .{field_ty.fmt(mod)});21820 const msg = try sema.errMsg(block, src, "packed unions cannot contain fields of type '{}'", .{field_ty.fmt(mod)});
21821 errdefer msg.destroy(gpa);21821 errdefer msg.destroy(gpa);
...@@ -21938,9 +21938,9 @@ fn reifyStruct(...@@ -21938,9 +21938,9 @@ fn reifyStruct(
21938 errdefer wip_ty.cancel(ip);21938 errdefer wip_ty.cancel(ip);
2193921939
21940 if (is_tuple) switch (layout) {21940 if (is_tuple) switch (layout) {
21941 .Extern => return sema.fail(block, src, "extern tuples are not supported", .{}),21941 .@"extern" => return sema.fail(block, src, "extern tuples are not supported", .{}),
21942 .Packed => return sema.fail(block, src, "packed tuples are not supported", .{}),21942 .@"packed" => return sema.fail(block, src, "packed tuples are not supported", .{}),
21943 .Auto => {},21943 .auto => {},
21944 };21944 };
2194521945
21946 const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{21946 const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{
...@@ -21990,11 +21990,11 @@ fn reifyStruct(...@@ -21990,11 +21990,11 @@ fn reifyStruct(
2199021990
21991 const byte_align = try field_alignment_val.toUnsignedIntAdvanced(sema);21991 const byte_align = try field_alignment_val.toUnsignedIntAdvanced(sema);
21992 if (byte_align == 0) {21992 if (byte_align == 0) {
21993 if (layout != .Packed) {21993 if (layout != .@"packed") {
21994 struct_type.field_aligns.get(ip)[field_idx] = .none;21994 struct_type.field_aligns.get(ip)[field_idx] = .none;
21995 }21995 }
21996 } else {21996 } else {
21997 if (layout == .Packed) return sema.fail(block, src, "alignment in a packed struct field must be set to 0", .{});21997 if (layout == .@"packed") return sema.fail(block, src, "alignment in a packed struct field must be set to 0", .{});
21998 if (!math.isPowerOfTwo(byte_align)) return sema.fail(block, src, "alignment value '{d}' is not a power of two or zero", .{byte_align});21998 if (!math.isPowerOfTwo(byte_align)) return sema.fail(block, src, "alignment value '{d}' is not a power of two or zero", .{byte_align});
21999 struct_type.field_aligns.get(ip)[field_idx] = Alignment.fromNonzeroByteUnits(byte_align);21999 struct_type.field_aligns.get(ip)[field_idx] = Alignment.fromNonzeroByteUnits(byte_align);
22000 }22000 }
...@@ -22004,9 +22004,9 @@ fn reifyStruct(...@@ -22004,9 +22004,9 @@ fn reifyStruct(
22004 if (field_is_comptime) {22004 if (field_is_comptime) {
22005 assert(any_comptime_fields);22005 assert(any_comptime_fields);
22006 switch (layout) {22006 switch (layout) {
22007 .Extern => return sema.fail(block, src, "extern struct fields cannot be marked comptime", .{}),22007 .@"extern" => return sema.fail(block, src, "extern struct fields cannot be marked comptime", .{}),
22008 .Packed => return sema.fail(block, src, "packed struct fields cannot be marked comptime", .{}),22008 .@"packed" => return sema.fail(block, src, "packed struct fields cannot be marked comptime", .{}),
22009 .Auto => struct_type.setFieldComptime(ip, field_idx),22009 .auto => struct_type.setFieldComptime(ip, field_idx),
22010 }22010 }
22011 }22011 }
2201222012
...@@ -22047,7 +22047,7 @@ fn reifyStruct(...@@ -22047,7 +22047,7 @@ fn reifyStruct(
22047 break :msg msg;22047 break :msg msg;
22048 });22048 });
22049 }22049 }
22050 if (layout == .Extern and !try sema.validateExternType(field_ty, .struct_field)) {22050 if (layout == .@"extern" and !try sema.validateExternType(field_ty, .struct_field)) {
22051 return sema.failWithOwnedErrorMsg(block, msg: {22051 return sema.failWithOwnedErrorMsg(block, msg: {
22052 const msg = try sema.errMsg(block, src, "extern structs cannot contain fields of type '{}'", .{field_ty.fmt(sema.mod)});22052 const msg = try sema.errMsg(block, src, "extern structs cannot contain fields of type '{}'", .{field_ty.fmt(sema.mod)});
22053 errdefer msg.destroy(gpa);22053 errdefer msg.destroy(gpa);
...@@ -22058,7 +22058,7 @@ fn reifyStruct(...@@ -22058,7 +22058,7 @@ fn reifyStruct(
22058 try sema.addDeclaredHereNote(msg, field_ty);22058 try sema.addDeclaredHereNote(msg, field_ty);
22059 break :msg msg;22059 break :msg msg;
22060 });22060 });
22061 } else if (layout == .Packed and !try sema.validatePackedType(field_ty)) {22061 } else if (layout == .@"packed" and !try sema.validatePackedType(field_ty)) {
22062 return sema.failWithOwnedErrorMsg(block, msg: {22062 return sema.failWithOwnedErrorMsg(block, msg: {
22063 const msg = try sema.errMsg(block, src, "packed structs cannot contain fields of type '{}'", .{field_ty.fmt(sema.mod)});22063 const msg = try sema.errMsg(block, src, "packed structs cannot contain fields of type '{}'", .{field_ty.fmt(sema.mod)});
22064 errdefer msg.destroy(gpa);22064 errdefer msg.destroy(gpa);
...@@ -22072,7 +22072,7 @@ fn reifyStruct(...@@ -22072,7 +22072,7 @@ fn reifyStruct(
22072 }22072 }
22073 }22073 }
2207422074
22075 if (layout == .Packed) {22075 if (layout == .@"packed") {
22076 var fields_bit_sum: u64 = 0;22076 var fields_bit_sum: u64 = 0;
22077 for (0..struct_type.field_types.len) |field_idx| {22077 for (0..struct_type.field_types.len) |field_idx| {
22078 const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[field_idx]);22078 const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[field_idx]);
...@@ -23311,7 +23311,7 @@ fn bitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!u6...@@ -23311,7 +23311,7 @@ fn bitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!u6
23311 }23311 }
2331223312
23313 switch (ty.containerLayout(mod)) {23313 switch (ty.containerLayout(mod)) {
23314 .Packed => {23314 .@"packed" => {
23315 var bit_sum: u64 = 0;23315 var bit_sum: u64 = 0;
23316 const struct_type = ip.loadStructType(ty.toIntern());23316 const struct_type = ip.loadStructType(ty.toIntern());
23317 for (0..struct_type.field_types.len) |i| {23317 for (0..struct_type.field_types.len) |i| {
...@@ -24710,7 +24710,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr...@@ -24710,7 +24710,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr
24710 },24710 },
24711 };24711 };
2471224712
24713 if (parent_ty.containerLayout(mod) == .Packed) {24713 if (parent_ty.containerLayout(mod) == .@"packed") {
24714 return sema.fail(block, src, "TODO handle packed structs/unions with @fieldParentPtr", .{});24714 return sema.fail(block, src, "TODO handle packed structs/unions with @fieldParentPtr", .{});
24715 } else {24715 } else {
24716 ptr_ty_data.flags.alignment = blk: {24716 ptr_ty_data.flags.alignment = blk: {
...@@ -26328,15 +26328,15 @@ fn validateExternType(...@@ -26328,15 +26328,15 @@ fn validateExternType(
26328 return sema.validateExternType(ty.intTagType(mod), position);26328 return sema.validateExternType(ty.intTagType(mod), position);
26329 },26329 },
26330 .Struct, .Union => switch (ty.containerLayout(mod)) {26330 .Struct, .Union => switch (ty.containerLayout(mod)) {
26331 .Extern => return true,26331 .@"extern" => return true,
26332 .Packed => {26332 .@"packed" => {
26333 const bit_size = try ty.bitSizeAdvanced(mod, sema);26333 const bit_size = try ty.bitSizeAdvanced(mod, sema);
26334 switch (bit_size) {26334 switch (bit_size) {
26335 0, 8, 16, 32, 64, 128 => return true,26335 0, 8, 16, 32, 64, 128 => return true,
26336 else => return false,26336 else => return false,
26337 }26337 }
26338 },26338 },
26339 .Auto => return !(try sema.typeHasRuntimeBits(ty)),26339 .auto => return !(try sema.typeHasRuntimeBits(ty)),
26340 },26340 },
26341 .Array => {26341 .Array => {
26342 if (position == .ret_ty or position == .param_ty) return false;26342 if (position == .ret_ty or position == .param_ty) return false;
...@@ -26456,7 +26456,7 @@ fn validatePackedType(sema: *Sema, ty: Type) !bool {...@@ -26456,7 +26456,7 @@ fn validatePackedType(sema: *Sema, ty: Type) !bool {
26456 .Enum,26456 .Enum,
26457 => return true,26457 => return true,
26458 .Pointer => return !ty.isSlice(mod) and !try sema.typeRequiresComptime(ty),26458 .Pointer => return !ty.isSlice(mod) and !try sema.typeRequiresComptime(ty),
26459 .Struct, .Union => return ty.containerLayout(mod) == .Packed,26459 .Struct, .Union => return ty.containerLayout(mod) == .@"packed",
26460 }26460 }
26461}26461}
2646226462
...@@ -27596,7 +27596,7 @@ fn structFieldPtrByIndex(...@@ -27596,7 +27596,7 @@ fn structFieldPtrByIndex(
27596 else27596 else
27597 try sema.typeAbiAlignment(Type.fromInterned(struct_ptr_ty_info.child));27597 try sema.typeAbiAlignment(Type.fromInterned(struct_ptr_ty_info.child));
2759827598
27599 if (struct_type.layout == .Packed) {27599 if (struct_type.layout == .@"packed") {
27600 comptime assert(Type.packed_struct_layout_version == 2);27600 comptime assert(Type.packed_struct_layout_version == 2);
2760127601
27602 var running_bits: u16 = 0;27602 var running_bits: u16 = 0;
...@@ -27641,7 +27641,7 @@ fn structFieldPtrByIndex(...@@ -27641,7 +27641,7 @@ fn structFieldPtrByIndex(
27641 ptr_ty_data.packed_offset = .{ .host_size = 0, .bit_offset = 0 };27641 ptr_ty_data.packed_offset = .{ .host_size = 0, .bit_offset = 0 };
27642 }27642 }
27643 }27643 }
27644 } else if (struct_type.layout == .Extern) {27644 } else if (struct_type.layout == .@"extern") {
27645 // For extern structs, field alignment might be bigger than type's27645 // For extern structs, field alignment might be bigger than type's
27646 // natural alignment. Eg, in `extern struct { x: u32, y: u16 }` the27646 // natural alignment. Eg, in `extern struct { x: u32, y: u16 }` the
27647 // second field is aligned as u32.27647 // second field is aligned as u32.
...@@ -27846,7 +27846,7 @@ fn unionFieldPtr(...@@ -27846,7 +27846,7 @@ fn unionFieldPtr(
27846 .is_const = union_ptr_info.flags.is_const,27846 .is_const = union_ptr_info.flags.is_const,
27847 .is_volatile = union_ptr_info.flags.is_volatile,27847 .is_volatile = union_ptr_info.flags.is_volatile,
27848 .address_space = union_ptr_info.flags.address_space,27848 .address_space = union_ptr_info.flags.address_space,
27849 .alignment = if (union_obj.getLayout(ip) == .Auto) blk: {27849 .alignment = if (union_obj.getLayout(ip) == .auto) blk: {
27850 const union_align = if (union_ptr_info.flags.alignment != .none)27850 const union_align = if (union_ptr_info.flags.alignment != .none)
27851 union_ptr_info.flags.alignment27851 union_ptr_info.flags.alignment
27852 else27852 else
...@@ -27875,7 +27875,7 @@ fn unionFieldPtr(...@@ -27875,7 +27875,7 @@ fn unionFieldPtr(
2787527875
27876 if (try sema.resolveDefinedValue(block, src, union_ptr)) |union_ptr_val| ct: {27876 if (try sema.resolveDefinedValue(block, src, union_ptr)) |union_ptr_val| ct: {
27877 switch (union_obj.getLayout(ip)) {27877 switch (union_obj.getLayout(ip)) {
27878 .Auto => if (!initializing) {27878 .auto => if (!initializing) {
27879 const union_val = (try sema.pointerDeref(block, src, union_ptr_val, union_ptr_ty)) orelse27879 const union_val = (try sema.pointerDeref(block, src, union_ptr_val, union_ptr_ty)) orelse
27880 break :ct;27880 break :ct;
27881 if (union_val.isUndef(mod)) {27881 if (union_val.isUndef(mod)) {
...@@ -27899,7 +27899,7 @@ fn unionFieldPtr(...@@ -27899,7 +27899,7 @@ fn unionFieldPtr(
27899 return sema.failWithOwnedErrorMsg(block, msg);27899 return sema.failWithOwnedErrorMsg(block, msg);
27900 }27900 }
27901 },27901 },
27902 .Packed, .Extern => {},27902 .@"packed", .@"extern" => {},
27903 }27903 }
27904 return Air.internedToRef((try mod.intern(.{ .ptr = .{27904 return Air.internedToRef((try mod.intern(.{ .ptr = .{
27905 .ty = ptr_field_ty.toIntern(),27905 .ty = ptr_field_ty.toIntern(),
...@@ -27911,7 +27911,7 @@ fn unionFieldPtr(...@@ -27911,7 +27911,7 @@ fn unionFieldPtr(
27911 }27911 }
2791227912
27913 try sema.requireRuntimeBlock(block, src, null);27913 try sema.requireRuntimeBlock(block, src, null);
27914 if (!initializing and union_obj.getLayout(ip) == .Auto and block.wantSafety() and27914 if (!initializing and union_obj.getLayout(ip) == .auto and block.wantSafety() and
27915 union_ty.unionTagTypeSafety(mod) != null and union_obj.field_types.len > 1)27915 union_ty.unionTagTypeSafety(mod) != null and union_obj.field_types.len > 1)
27916 {27916 {
27917 const wanted_tag_val = try mod.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index);27917 const wanted_tag_val = try mod.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index);
...@@ -27954,7 +27954,7 @@ fn unionFieldVal(...@@ -27954,7 +27954,7 @@ fn unionFieldVal(
27954 const field_tag = try mod.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index);27954 const field_tag = try mod.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index);
27955 const tag_matches = un.tag == field_tag.toIntern();27955 const tag_matches = un.tag == field_tag.toIntern();
27956 switch (union_obj.getLayout(ip)) {27956 switch (union_obj.getLayout(ip)) {
27957 .Auto => {27957 .auto => {
27958 if (tag_matches) {27958 if (tag_matches) {
27959 return Air.internedToRef(un.val);27959 return Air.internedToRef(un.val);
27960 } else {27960 } else {
...@@ -27971,7 +27971,7 @@ fn unionFieldVal(...@@ -27971,7 +27971,7 @@ fn unionFieldVal(
27971 return sema.failWithOwnedErrorMsg(block, msg);27971 return sema.failWithOwnedErrorMsg(block, msg);
27972 }27972 }
27973 },27973 },
27974 .Packed, .Extern => |layout| {27974 .@"packed", .@"extern" => |layout| {
27975 if (tag_matches) {27975 if (tag_matches) {
27976 return Air.internedToRef(un.val);27976 return Air.internedToRef(un.val);
27977 } else {27977 } else {
...@@ -27989,7 +27989,7 @@ fn unionFieldVal(...@@ -27989,7 +27989,7 @@ fn unionFieldVal(
27989 }27989 }
2799027990
27991 try sema.requireRuntimeBlock(block, src, null);27991 try sema.requireRuntimeBlock(block, src, null);
27992 if (union_obj.getLayout(ip) == .Auto and block.wantSafety() and27992 if (union_obj.getLayout(ip) == .auto and block.wantSafety() and
27993 union_ty.unionTagTypeSafety(mod) != null and union_obj.field_types.len > 1)27993 union_ty.unionTagTypeSafety(mod) != null and union_obj.field_types.len > 1)
27994 {27994 {
27995 const wanted_tag_val = try mod.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index);27995 const wanted_tag_val = try mod.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index);
...@@ -30961,7 +30961,7 @@ fn beginComptimePtrMutation(...@@ -30961,7 +30961,7 @@ fn beginComptimePtrMutation(
3096130961
30962 const tag_type = base_child_ty.unionTagTypeHypothetical(mod);30962 const tag_type = base_child_ty.unionTagTypeHypothetical(mod);
30963 const hypothetical_tag = try mod.enumValueFieldIndex(tag_type, field_index);30963 const hypothetical_tag = try mod.enumValueFieldIndex(tag_type, field_index);
30964 if (layout == .Auto or (payload.tag != null and hypothetical_tag.eql(payload.tag.?, tag_type, mod))) {30964 if (layout == .auto or (payload.tag != null and hypothetical_tag.eql(payload.tag.?, tag_type, mod))) {
30965 // We need to set the active field of the union.30965 // We need to set the active field of the union.
30966 payload.tag = hypothetical_tag;30966 payload.tag = hypothetical_tag;
3096730967
...@@ -30988,7 +30988,7 @@ fn beginComptimePtrMutation(...@@ -30988,7 +30988,7 @@ fn beginComptimePtrMutation(
30988 .pointee = .{ .reinterpret = .{30988 .pointee = .{ .reinterpret = .{
30989 .val_ptr = val_ptr,30989 .val_ptr = val_ptr,
30990 .byte_offset = 0,30990 .byte_offset = 0,
30991 .write_packed = layout == .Packed,30991 .write_packed = layout == .@"packed",
30992 } },30992 } },
30993 .ty = parent.ty,30993 .ty = parent.ty,
30994 };30994 };
...@@ -31395,7 +31395,7 @@ fn beginComptimePtrLoad(...@@ -31395,7 +31395,7 @@ fn beginComptimePtrLoad(
3139531395
31396 if (container_ty.hasWellDefinedLayout(mod)) {31396 if (container_ty.hasWellDefinedLayout(mod)) {
31397 const struct_obj = mod.typeToStruct(container_ty);31397 const struct_obj = mod.typeToStruct(container_ty);
31398 if (struct_obj != null and struct_obj.?.layout == .Packed) {31398 if (struct_obj != null and struct_obj.?.layout == .@"packed") {
31399 // packed structs are not byte addressable31399 // packed structs are not byte addressable
31400 deref.parent = null;31400 deref.parent = null;
31401 } else if (deref.parent) |*parent| {31401 } else if (deref.parent) |*parent| {
...@@ -31551,7 +31551,7 @@ fn bitCastUnionFieldVal(...@@ -31551,7 +31551,7 @@ fn bitCastUnionFieldVal(
3155131551
31552 // Reading a larger value means we need to reinterpret from undefined bytes.31552 // Reading a larger value means we need to reinterpret from undefined bytes.
31553 const offset = switch (layout) {31553 const offset = switch (layout) {
31554 .Extern => offset: {31554 .@"extern" => offset: {
31555 if (field_size > old_size) @memset(buffer[old_size..], 0xaa);31555 if (field_size > old_size) @memset(buffer[old_size..], 0xaa);
31556 val.writeToMemory(old_ty, mod, buffer) catch |err| switch (err) {31556 val.writeToMemory(old_ty, mod, buffer) catch |err| switch (err) {
31557 error.OutOfMemory => return error.OutOfMemory,31557 error.OutOfMemory => return error.OutOfMemory,
...@@ -31561,7 +31561,7 @@ fn bitCastUnionFieldVal(...@@ -31561,7 +31561,7 @@ fn bitCastUnionFieldVal(
31561 };31561 };
31562 break :offset 0;31562 break :offset 0;
31563 },31563 },
31564 .Packed => offset: {31564 .@"packed" => offset: {
31565 if (field_size > old_size) {31565 if (field_size > old_size) {
31566 const min_size = @max(old_size, 1);31566 const min_size = @max(old_size, 1);
31567 switch (endian) {31567 switch (endian) {
...@@ -31577,7 +31577,7 @@ fn bitCastUnionFieldVal(...@@ -31577,7 +31577,7 @@ fn bitCastUnionFieldVal(
3157731577
31578 break :offset if (endian == .big) buffer.len - field_size else 0;31578 break :offset if (endian == .big) buffer.len - field_size else 0;
31579 },31579 },
31580 .Auto => unreachable,31580 .auto => unreachable,
31581 };31581 };
3158231582
31583 return Value.readFromMemory(field_ty, mod, buffer[offset..], sema.arena) catch |err| switch (err) {31583 return Value.readFromMemory(field_ty, mod, buffer[offset..], sema.arena) catch |err| switch (err) {
...@@ -35608,7 +35608,7 @@ pub fn resolveStructAlignment(...@@ -35608,7 +35608,7 @@ pub fn resolveStructAlignment(
35608 const target = mod.getTarget();35608 const target = mod.getTarget();
3560935609
35610 assert(struct_type.flagsPtr(ip).alignment == .none);35610 assert(struct_type.flagsPtr(ip).alignment == .none);
35611 assert(struct_type.layout != .Packed);35611 assert(struct_type.layout != .@"packed");
3561235612
35613 if (struct_type.flagsPtr(ip).field_types_wip) {35613 if (struct_type.flagsPtr(ip).field_types_wip) {
35614 // We'll guess "pointer-aligned", if the struct has an35614 // We'll guess "pointer-aligned", if the struct has an
...@@ -35661,7 +35661,7 @@ fn resolveStructLayout(sema: *Sema, ty: Type) CompileError!void {...@@ -35661,7 +35661,7 @@ fn resolveStructLayout(sema: *Sema, ty: Type) CompileError!void {
3566135661
35662 try sema.resolveTypeFields(ty);35662 try sema.resolveTypeFields(ty);
3566335663
35664 if (struct_type.layout == .Packed) {35664 if (struct_type.layout == .@"packed") {
35665 try semaBackingIntType(mod, struct_type);35665 try semaBackingIntType(mod, struct_type);
35666 return;35666 return;
35667 }35667 }
...@@ -36625,11 +36625,11 @@ fn semaStructFields(...@@ -36625,11 +36625,11 @@ fn semaStructFields(
36625 const fields_len, const small, var extra_index = structZirInfo(zir, zir_index);36625 const fields_len, const small, var extra_index = structZirInfo(zir, zir_index);
3662636626
36627 if (fields_len == 0) switch (struct_type.layout) {36627 if (fields_len == 0) switch (struct_type.layout) {
36628 .Packed => {36628 .@"packed" => {
36629 try semaBackingIntType(mod, struct_type);36629 try semaBackingIntType(mod, struct_type);
36630 return;36630 return;
36631 },36631 },
36632 .Auto, .Extern => {36632 .auto, .@"extern" => {
36633 struct_type.size(ip).* = 0;36633 struct_type.size(ip).* = 0;
36634 struct_type.flagsPtr(ip).layout_resolved = true;36634 struct_type.flagsPtr(ip).layout_resolved = true;
36635 return;36635 return;
...@@ -36810,7 +36810,7 @@ fn semaStructFields(...@@ -36810,7 +36810,7 @@ fn semaStructFields(
36810 return sema.failWithOwnedErrorMsg(&block_scope, msg);36810 return sema.failWithOwnedErrorMsg(&block_scope, msg);
36811 }36811 }
36812 switch (struct_type.layout) {36812 switch (struct_type.layout) {
36813 .Extern => if (!try sema.validateExternType(field_ty, .struct_field)) {36813 .@"extern" => if (!try sema.validateExternType(field_ty, .struct_field)) {
36814 const msg = msg: {36814 const msg = msg: {
36815 const ty_src = mod.fieldSrcLoc(decl_index, .{36815 const ty_src = mod.fieldSrcLoc(decl_index, .{
36816 .index = field_i,36816 .index = field_i,
...@@ -36826,7 +36826,7 @@ fn semaStructFields(...@@ -36826,7 +36826,7 @@ fn semaStructFields(
36826 };36826 };
36827 return sema.failWithOwnedErrorMsg(&block_scope, msg);36827 return sema.failWithOwnedErrorMsg(&block_scope, msg);
36828 },36828 },
36829 .Packed => if (!try sema.validatePackedType(field_ty)) {36829 .@"packed" => if (!try sema.validatePackedType(field_ty)) {
36830 const msg = msg: {36830 const msg = msg: {
36831 const ty_src = mod.fieldSrcLoc(decl_index, .{36831 const ty_src = mod.fieldSrcLoc(decl_index, .{
36832 .index = field_i,36832 .index = field_i,
...@@ -37350,7 +37350,7 @@ fn semaUnionFields(mod: *Module, arena: Allocator, union_type: InternPool.Loaded...@@ -37350,7 +37350,7 @@ fn semaUnionFields(mod: *Module, arena: Allocator, union_type: InternPool.Loaded
37350 return sema.failWithOwnedErrorMsg(&block_scope, msg);37350 return sema.failWithOwnedErrorMsg(&block_scope, msg);
37351 }37351 }
37352 const layout = union_type.getLayout(ip);37352 const layout = union_type.getLayout(ip);
37353 if (layout == .Extern and37353 if (layout == .@"extern" and
37354 !try sema.validateExternType(field_ty, .union_field))37354 !try sema.validateExternType(field_ty, .union_field))
37355 {37355 {
37356 const msg = msg: {37356 const msg = msg: {
...@@ -37367,7 +37367,7 @@ fn semaUnionFields(mod: *Module, arena: Allocator, union_type: InternPool.Loaded...@@ -37367,7 +37367,7 @@ fn semaUnionFields(mod: *Module, arena: Allocator, union_type: InternPool.Loaded
37367 break :msg msg;37367 break :msg msg;
37368 };37368 };
37369 return sema.failWithOwnedErrorMsg(&block_scope, msg);37369 return sema.failWithOwnedErrorMsg(&block_scope, msg);
37370 } else if (layout == .Packed and !try sema.validatePackedType(field_ty)) {37370 } else if (layout == .@"packed" and !try sema.validatePackedType(field_ty)) {
37371 const msg = msg: {37371 const msg = msg: {
37372 const ty_src = mod.fieldSrcLoc(union_type.decl, .{37372 const ty_src = mod.fieldSrcLoc(union_type.decl, .{
37373 .index = field_i,37373 .index = field_i,
...@@ -38286,9 +38286,9 @@ fn structFieldAlignment(...@@ -38286,9 +38286,9 @@ fn structFieldAlignment(
38286 return explicit_alignment;38286 return explicit_alignment;
38287 const mod = sema.mod;38287 const mod = sema.mod;
38288 switch (layout) {38288 switch (layout) {
38289 .Packed => return .none,38289 .@"packed" => return .none,
38290 .Auto => if (mod.getTarget().ofmt != .c) return sema.typeAbiAlignment(field_ty),38290 .auto => if (mod.getTarget().ofmt != .c) return sema.typeAbiAlignment(field_ty),
38291 .Extern => {},38291 .@"extern" => {},
38292 }38292 }
38293 // extern38293 // extern
38294 const ty_abi_align = try sema.typeAbiAlignment(field_ty);38294 const ty_abi_align = try sema.typeAbiAlignment(field_ty);
src/Value.zig+18-18
...@@ -676,8 +676,8 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{...@@ -676,8 +676,8 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{
676 .Struct => {676 .Struct => {
677 const struct_type = mod.typeToStruct(ty) orelse return error.IllDefinedMemoryLayout;677 const struct_type = mod.typeToStruct(ty) orelse return error.IllDefinedMemoryLayout;
678 switch (struct_type.layout) {678 switch (struct_type.layout) {
679 .Auto => return error.IllDefinedMemoryLayout,679 .auto => return error.IllDefinedMemoryLayout,
680 .Extern => for (0..struct_type.field_types.len) |i| {680 .@"extern" => for (0..struct_type.field_types.len) |i| {
681 const off: usize = @intCast(ty.structFieldOffset(i, mod));681 const off: usize = @intCast(ty.structFieldOffset(i, mod));
682 const field_val = switch (val.ip_index) {682 const field_val = switch (val.ip_index) {
683 .none => switch (val.tag()) {683 .none => switch (val.tag()) {
...@@ -701,7 +701,7 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{...@@ -701,7 +701,7 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{
701 const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]);701 const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]);
702 try writeToMemory(field_val, field_ty, mod, buffer[off..]);702 try writeToMemory(field_val, field_ty, mod, buffer[off..]);
703 },703 },
704 .Packed => {704 .@"packed" => {
705 const byte_count = (@as(usize, @intCast(ty.bitSize(mod))) + 7) / 8;705 const byte_count = (@as(usize, @intCast(ty.bitSize(mod))) + 7) / 8;
706 return writeToPackedMemory(val, ty, mod, buffer[0..byte_count], 0);706 return writeToPackedMemory(val, ty, mod, buffer[0..byte_count], 0);
707 },707 },
...@@ -724,8 +724,8 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{...@@ -724,8 +724,8 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{
724 bigint.writeTwosComplement(buffer[0..byte_count], endian);724 bigint.writeTwosComplement(buffer[0..byte_count], endian);
725 },725 },
726 .Union => switch (ty.containerLayout(mod)) {726 .Union => switch (ty.containerLayout(mod)) {
727 .Auto => return error.IllDefinedMemoryLayout, // Sema is supposed to have emitted a compile error already727 .auto => return error.IllDefinedMemoryLayout, // Sema is supposed to have emitted a compile error already
728 .Extern => {728 .@"extern" => {
729 if (val.unionTag(mod)) |union_tag| {729 if (val.unionTag(mod)) |union_tag| {
730 const union_obj = mod.typeToUnion(ty).?;730 const union_obj = mod.typeToUnion(ty).?;
731 const field_index = mod.unionTagFieldIndex(union_obj, union_tag).?;731 const field_index = mod.unionTagFieldIndex(union_obj, union_tag).?;
...@@ -739,7 +739,7 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{...@@ -739,7 +739,7 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{
739 return writeToMemory(val.unionValue(mod), backing_ty, mod, buffer[0..byte_count]);739 return writeToMemory(val.unionValue(mod), backing_ty, mod, buffer[0..byte_count]);
740 }740 }
741 },741 },
742 .Packed => {742 .@"packed" => {
743 const backing_ty = try ty.unionBackingType(mod);743 const backing_ty = try ty.unionBackingType(mod);
744 const byte_count: usize = @intCast(backing_ty.abiSize(mod));744 const byte_count: usize = @intCast(backing_ty.abiSize(mod));
745 return writeToPackedMemory(val, ty, mod, buffer[0..byte_count], 0);745 return writeToPackedMemory(val, ty, mod, buffer[0..byte_count], 0);
...@@ -841,7 +841,7 @@ pub fn writeToPackedMemory(...@@ -841,7 +841,7 @@ pub fn writeToPackedMemory(
841 const struct_type = ip.loadStructType(ty.toIntern());841 const struct_type = ip.loadStructType(ty.toIntern());
842 // Sema is supposed to have emitted a compile error already in the case of Auto,842 // Sema is supposed to have emitted a compile error already in the case of Auto,
843 // and Extern is handled in non-packed writeToMemory.843 // and Extern is handled in non-packed writeToMemory.
844 assert(struct_type.layout == .Packed);844 assert(struct_type.layout == .@"packed");
845 var bits: u16 = 0;845 var bits: u16 = 0;
846 for (0..struct_type.field_types.len) |i| {846 for (0..struct_type.field_types.len) |i| {
847 const field_val = switch (val.ip_index) {847 const field_val = switch (val.ip_index) {
...@@ -866,8 +866,8 @@ pub fn writeToPackedMemory(...@@ -866,8 +866,8 @@ pub fn writeToPackedMemory(
866 .Union => {866 .Union => {
867 const union_obj = mod.typeToUnion(ty).?;867 const union_obj = mod.typeToUnion(ty).?;
868 switch (union_obj.getLayout(ip)) {868 switch (union_obj.getLayout(ip)) {
869 .Auto, .Extern => unreachable, // Handled in non-packed writeToMemory869 .auto, .@"extern" => unreachable, // Handled in non-packed writeToMemory
870 .Packed => {870 .@"packed" => {
871 if (val.unionTag(mod)) |union_tag| {871 if (val.unionTag(mod)) |union_tag| {
872 const field_index = mod.unionTagFieldIndex(union_obj, union_tag).?;872 const field_index = mod.unionTagFieldIndex(union_obj, union_tag).?;
873 const field_type = Type.fromInterned(union_obj.field_types.get(ip)[field_index]);873 const field_type = Type.fromInterned(union_obj.field_types.get(ip)[field_index]);
...@@ -991,8 +991,8 @@ pub fn readFromMemory(...@@ -991,8 +991,8 @@ pub fn readFromMemory(
991 .Struct => {991 .Struct => {
992 const struct_type = mod.typeToStruct(ty).?;992 const struct_type = mod.typeToStruct(ty).?;
993 switch (struct_type.layout) {993 switch (struct_type.layout) {
994 .Auto => unreachable, // Sema is supposed to have emitted a compile error already994 .auto => unreachable, // Sema is supposed to have emitted a compile error already
995 .Extern => {995 .@"extern" => {
996 const field_types = struct_type.field_types;996 const field_types = struct_type.field_types;
997 const field_vals = try arena.alloc(InternPool.Index, field_types.len);997 const field_vals = try arena.alloc(InternPool.Index, field_types.len);
998 for (field_vals, 0..) |*field_val, i| {998 for (field_vals, 0..) |*field_val, i| {
...@@ -1006,7 +1006,7 @@ pub fn readFromMemory(...@@ -1006,7 +1006,7 @@ pub fn readFromMemory(
1006 .storage = .{ .elems = field_vals },1006 .storage = .{ .elems = field_vals },
1007 } })));1007 } })));
1008 },1008 },
1009 .Packed => {1009 .@"packed" => {
1010 const byte_count = (@as(usize, @intCast(ty.bitSize(mod))) + 7) / 8;1010 const byte_count = (@as(usize, @intCast(ty.bitSize(mod))) + 7) / 8;
1011 return readFromPackedMemory(ty, mod, buffer[0..byte_count], 0, arena);1011 return readFromPackedMemory(ty, mod, buffer[0..byte_count], 0, arena);
1012 },1012 },
...@@ -1025,8 +1025,8 @@ pub fn readFromMemory(...@@ -1025,8 +1025,8 @@ pub fn readFromMemory(
1025 } })));1025 } })));
1026 },1026 },
1027 .Union => switch (ty.containerLayout(mod)) {1027 .Union => switch (ty.containerLayout(mod)) {
1028 .Auto => return error.IllDefinedMemoryLayout,1028 .auto => return error.IllDefinedMemoryLayout,
1029 .Extern => {1029 .@"extern" => {
1030 const union_size = ty.abiSize(mod);1030 const union_size = ty.abiSize(mod);
1031 const array_ty = try mod.arrayType(.{ .len = union_size, .child = .u8_type });1031 const array_ty = try mod.arrayType(.{ .len = union_size, .child = .u8_type });
1032 const val = try (try readFromMemory(array_ty, mod, buffer, arena)).intern(array_ty, mod);1032 const val = try (try readFromMemory(array_ty, mod, buffer, arena)).intern(array_ty, mod);
...@@ -1036,7 +1036,7 @@ pub fn readFromMemory(...@@ -1036,7 +1036,7 @@ pub fn readFromMemory(
1036 .val = val,1036 .val = val,
1037 } })));1037 } })));
1038 },1038 },
1039 .Packed => {1039 .@"packed" => {
1040 const byte_count = (@as(usize, @intCast(ty.bitSize(mod))) + 7) / 8;1040 const byte_count = (@as(usize, @intCast(ty.bitSize(mod))) + 7) / 8;
1041 return readFromPackedMemory(ty, mod, buffer[0..byte_count], 0, arena);1041 return readFromPackedMemory(ty, mod, buffer[0..byte_count], 0, arena);
1042 },1042 },
...@@ -1177,8 +1177,8 @@ pub fn readFromPackedMemory(...@@ -1177,8 +1177,8 @@ pub fn readFromPackedMemory(
1177 } })));1177 } })));
1178 },1178 },
1179 .Union => switch (ty.containerLayout(mod)) {1179 .Union => switch (ty.containerLayout(mod)) {
1180 .Auto, .Extern => unreachable, // Handled by non-packed readFromMemory1180 .auto, .@"extern" => unreachable, // Handled by non-packed readFromMemory
1181 .Packed => {1181 .@"packed" => {
1182 const backing_ty = try ty.unionBackingType(mod);1182 const backing_ty = try ty.unionBackingType(mod);
1183 const val = (try readFromPackedMemory(backing_ty, mod, buffer, bit_offset, arena)).toIntern();1183 const val = (try readFromPackedMemory(backing_ty, mod, buffer, bit_offset, arena)).toIntern();
1184 return Value.fromInterned((try mod.intern(.{ .un = .{1184 return Value.fromInterned((try mod.intern(.{ .un = .{
...@@ -4064,7 +4064,7 @@ fn dbHelper(self: *Value, tag_to_payload_map: *map: {...@@ -4064,7 +4064,7 @@ fn dbHelper(self: *Value, tag_to_payload_map: *map: {
4064 .alignment = 0,4064 .alignment = 0,
4065 };4065 };
4066 break :map @Type(.{ .Struct = .{4066 break :map @Type(.{ .Struct = .{
4067 .layout = .Extern,4067 .layout = .@"extern",
4068 .fields = &fields,4068 .fields = &fields,
4069 .decls = &.{},4069 .decls = &.{},
4070 .is_tuple = false,4070 .is_tuple = false,
src/arch/aarch64/abi.zig+2-2
...@@ -21,7 +21,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class {...@@ -21,7 +21,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class {
21 var maybe_float_bits: ?u16 = null;21 var maybe_float_bits: ?u16 = null;
22 switch (ty.zigTypeTag(mod)) {22 switch (ty.zigTypeTag(mod)) {
23 .Struct => {23 .Struct => {
24 if (ty.containerLayout(mod) == .Packed) return .byval;24 if (ty.containerLayout(mod) == .@"packed") return .byval;
25 const float_count = countFloats(ty, mod, &maybe_float_bits);25 const float_count = countFloats(ty, mod, &maybe_float_bits);
26 if (float_count <= sret_float_count) return .{ .float_array = float_count };26 if (float_count <= sret_float_count) return .{ .float_array = float_count };
2727
...@@ -31,7 +31,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class {...@@ -31,7 +31,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class {
31 return .integer;31 return .integer;
32 },32 },
33 .Union => {33 .Union => {
34 if (ty.containerLayout(mod) == .Packed) return .byval;34 if (ty.containerLayout(mod) == .@"packed") return .byval;
35 const float_count = countFloats(ty, mod, &maybe_float_bits);35 const float_count = countFloats(ty, mod, &maybe_float_bits);
36 if (float_count <= sret_float_count) return .{ .float_array = float_count };36 if (float_count <= sret_float_count) return .{ .float_array = float_count };
3737
src/arch/arm/abi.zig+2-2
...@@ -33,7 +33,7 @@ pub fn classifyType(ty: Type, mod: *Module, ctx: Context) Class {...@@ -33,7 +33,7 @@ pub fn classifyType(ty: Type, mod: *Module, ctx: Context) Class {
33 switch (ty.zigTypeTag(mod)) {33 switch (ty.zigTypeTag(mod)) {
34 .Struct => {34 .Struct => {
35 const bit_size = ty.bitSize(mod);35 const bit_size = ty.bitSize(mod);
36 if (ty.containerLayout(mod) == .Packed) {36 if (ty.containerLayout(mod) == .@"packed") {
37 if (bit_size > 64) return .memory;37 if (bit_size > 64) return .memory;
38 return .byval;38 return .byval;
39 }39 }
...@@ -56,7 +56,7 @@ pub fn classifyType(ty: Type, mod: *Module, ctx: Context) Class {...@@ -56,7 +56,7 @@ pub fn classifyType(ty: Type, mod: *Module, ctx: Context) Class {
56 .Union => {56 .Union => {
57 const bit_size = ty.bitSize(mod);57 const bit_size = ty.bitSize(mod);
58 const union_obj = mod.typeToUnion(ty).?;58 const union_obj = mod.typeToUnion(ty).?;
59 if (union_obj.getLayout(ip) == .Packed) {59 if (union_obj.getLayout(ip) == .@"packed") {
60 if (bit_size > 64) return .memory;60 if (bit_size > 64) return .memory;
61 return .byval;61 return .byval;
62 }62 }
src/arch/riscv64/abi.zig+2-2
...@@ -15,7 +15,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class {...@@ -15,7 +15,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class {
15 switch (ty.zigTypeTag(mod)) {15 switch (ty.zigTypeTag(mod)) {
16 .Struct => {16 .Struct => {
17 const bit_size = ty.bitSize(mod);17 const bit_size = ty.bitSize(mod);
18 if (ty.containerLayout(mod) == .Packed) {18 if (ty.containerLayout(mod) == .@"packed") {
19 if (bit_size > max_byval_size) return .memory;19 if (bit_size > max_byval_size) return .memory;
20 return .byval;20 return .byval;
21 }21 }
...@@ -44,7 +44,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class {...@@ -44,7 +44,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class {
44 },44 },
45 .Union => {45 .Union => {
46 const bit_size = ty.bitSize(mod);46 const bit_size = ty.bitSize(mod);
47 if (ty.containerLayout(mod) == .Packed) {47 if (ty.containerLayout(mod) == .@"packed") {
48 if (bit_size > max_byval_size) return .memory;48 if (bit_size > max_byval_size) return .memory;
49 return .byval;49 return .byval;
50 }50 }
src/arch/wasm/CodeGen.zig+7-7
...@@ -1018,7 +1018,7 @@ fn typeToValtype(ty: Type, mod: *Module) wasm.Valtype {...@@ -1018,7 +1018,7 @@ fn typeToValtype(ty: Type, mod: *Module) wasm.Valtype {
1018 .unrolled => wasm.Valtype.i32,1018 .unrolled => wasm.Valtype.i32,
1019 },1019 },
1020 .Union => switch (ty.containerLayout(mod)) {1020 .Union => switch (ty.containerLayout(mod)) {
1021 .Packed => {1021 .@"packed" => {
1022 const int_ty = mod.intType(.unsigned, @as(u16, @intCast(ty.bitSize(mod)))) catch @panic("out of memory");1022 const int_ty = mod.intType(.unsigned, @as(u16, @intCast(ty.bitSize(mod)))) catch @panic("out of memory");
1023 return typeToValtype(int_ty, mod);1023 return typeToValtype(int_ty, mod);
1024 },1024 },
...@@ -1737,7 +1737,7 @@ fn isByRef(ty: Type, mod: *Module) bool {...@@ -1737,7 +1737,7 @@ fn isByRef(ty: Type, mod: *Module) bool {
1737 => return ty.hasRuntimeBitsIgnoreComptime(mod),1737 => return ty.hasRuntimeBitsIgnoreComptime(mod),
1738 .Union => {1738 .Union => {
1739 if (mod.typeToUnion(ty)) |union_obj| {1739 if (mod.typeToUnion(ty)) |union_obj| {
1740 if (union_obj.getLayout(ip) == .Packed) {1740 if (union_obj.getLayout(ip) == .@"packed") {
1741 return ty.abiSize(mod) > 8;1741 return ty.abiSize(mod) > 8;
1742 }1742 }
1743 }1743 }
...@@ -3097,7 +3097,7 @@ fn lowerParentPtr(func: *CodeGen, ptr_val: Value, offset: u32) InnerError!WValue...@@ -3097,7 +3097,7 @@ fn lowerParentPtr(func: *CodeGen, ptr_val: Value, offset: u32) InnerError!WValue
3097 break :blk parent_ty.structFieldOffset(field_index, mod);3097 break :blk parent_ty.structFieldOffset(field_index, mod);
3098 },3098 },
3099 .Union => switch (parent_ty.containerLayout(mod)) {3099 .Union => switch (parent_ty.containerLayout(mod)) {
3100 .Packed => 0,3100 .@"packed" => 0,
3101 else => blk: {3101 else => blk: {
3102 const layout: Module.UnionLayout = parent_ty.unionGetLayout(mod);3102 const layout: Module.UnionLayout = parent_ty.unionGetLayout(mod);
3103 if (layout.payload_size == 0) break :blk 0;3103 if (layout.payload_size == 0) break :blk 0;
...@@ -3358,7 +3358,7 @@ fn lowerConstant(func: *CodeGen, val: Value, ty: Type) InnerError!WValue {...@@ -3358,7 +3358,7 @@ fn lowerConstant(func: *CodeGen, val: Value, ty: Type) InnerError!WValue {
3358 const struct_type = ip.loadStructType(ty.toIntern());3358 const struct_type = ip.loadStructType(ty.toIntern());
3359 // non-packed structs are not handled in this function because they3359 // non-packed structs are not handled in this function because they
3360 // are by-ref types.3360 // are by-ref types.
3361 assert(struct_type.layout == .Packed);3361 assert(struct_type.layout == .@"packed");
3362 var buf: [8]u8 = .{0} ** 8; // zero the buffer so we do not read 0xaa as integer3362 var buf: [8]u8 = .{0} ** 8; // zero the buffer so we do not read 0xaa as integer
3363 val.writeToPackedMemory(ty, mod, &buf, 0) catch unreachable;3363 val.writeToPackedMemory(ty, mod, &buf, 0) catch unreachable;
3364 const backing_int_ty = Type.fromInterned(struct_type.backingIntType(ip).*);3364 const backing_int_ty = Type.fromInterned(struct_type.backingIntType(ip).*);
...@@ -3890,7 +3890,7 @@ fn structFieldPtr(...@@ -3890,7 +3890,7 @@ fn structFieldPtr(
3890 const struct_ptr_ty_info = struct_ptr_ty.ptrInfo(mod);3890 const struct_ptr_ty_info = struct_ptr_ty.ptrInfo(mod);
38913891
3892 const offset = switch (struct_ty.containerLayout(mod)) {3892 const offset = switch (struct_ty.containerLayout(mod)) {
3893 .Packed => switch (struct_ty.zigTypeTag(mod)) {3893 .@"packed" => switch (struct_ty.zigTypeTag(mod)) {
3894 .Struct => offset: {3894 .Struct => offset: {
3895 if (result_ty.ptrInfo(mod).packed_offset.host_size != 0) {3895 if (result_ty.ptrInfo(mod).packed_offset.host_size != 0) {
3896 break :offset @as(u32, 0);3896 break :offset @as(u32, 0);
...@@ -3928,7 +3928,7 @@ fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -3928,7 +3928,7 @@ fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
3928 if (!field_ty.hasRuntimeBitsIgnoreComptime(mod)) return func.finishAir(inst, .none, &.{struct_field.struct_operand});3928 if (!field_ty.hasRuntimeBitsIgnoreComptime(mod)) return func.finishAir(inst, .none, &.{struct_field.struct_operand});
39293929
3930 const result = switch (struct_ty.containerLayout(mod)) {3930 const result = switch (struct_ty.containerLayout(mod)) {
3931 .Packed => switch (struct_ty.zigTypeTag(mod)) {3931 .@"packed" => switch (struct_ty.zigTypeTag(mod)) {
3932 .Struct => result: {3932 .Struct => result: {
3933 const packed_struct = mod.typeToPackedStruct(struct_ty).?;3933 const packed_struct = mod.typeToPackedStruct(struct_ty).?;
3934 const offset = mod.structPackedFieldBitOffset(packed_struct, field_index);3934 const offset = mod.structPackedFieldBitOffset(packed_struct, field_index);
...@@ -5321,7 +5321,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5321,7 +5321,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5321 break :result_value result;5321 break :result_value result;
5322 },5322 },
5323 .Struct => switch (result_ty.containerLayout(mod)) {5323 .Struct => switch (result_ty.containerLayout(mod)) {
5324 .Packed => {5324 .@"packed" => {
5325 if (isByRef(result_ty, mod)) {5325 if (isByRef(result_ty, mod)) {
5326 return func.fail("TODO: airAggregateInit for packed structs larger than 64 bits", .{});5326 return func.fail("TODO: airAggregateInit for packed structs larger than 64 bits", .{});
5327 }5327 }
src/arch/wasm/abi.zig+3-3
...@@ -29,7 +29,7 @@ pub fn classifyType(ty: Type, mod: *Module) [2]Class {...@@ -29,7 +29,7 @@ pub fn classifyType(ty: Type, mod: *Module) [2]Class {
29 switch (ty.zigTypeTag(mod)) {29 switch (ty.zigTypeTag(mod)) {
30 .Struct => {30 .Struct => {
31 const struct_type = mod.typeToStruct(ty).?;31 const struct_type = mod.typeToStruct(ty).?;
32 if (struct_type.layout == .Packed) {32 if (struct_type.layout == .@"packed") {
33 if (ty.bitSize(mod) <= 64) return direct;33 if (ty.bitSize(mod) <= 64) return direct;
34 return .{ .direct, .direct };34 return .{ .direct, .direct };
35 }35 }
...@@ -70,7 +70,7 @@ pub fn classifyType(ty: Type, mod: *Module) [2]Class {...@@ -70,7 +70,7 @@ pub fn classifyType(ty: Type, mod: *Module) [2]Class {
70 },70 },
71 .Union => {71 .Union => {
72 const union_obj = mod.typeToUnion(ty).?;72 const union_obj = mod.typeToUnion(ty).?;
73 if (union_obj.getLayout(ip) == .Packed) {73 if (union_obj.getLayout(ip) == .@"packed") {
74 if (ty.bitSize(mod) <= 64) return direct;74 if (ty.bitSize(mod) <= 64) return direct;
75 return .{ .direct, .direct };75 return .{ .direct, .direct };
76 }76 }
...@@ -113,7 +113,7 @@ pub fn scalarType(ty: Type, mod: *Module) Type {...@@ -113,7 +113,7 @@ pub fn scalarType(ty: Type, mod: *Module) Type {
113 },113 },
114 .Union => {114 .Union => {
115 const union_obj = mod.typeToUnion(ty).?;115 const union_obj = mod.typeToUnion(ty).?;
116 if (union_obj.getLayout(ip) != .Packed) {116 if (union_obj.getLayout(ip) != .@"packed") {
117 const layout = mod.getUnionLayout(union_obj);117 const layout = mod.getUnionLayout(union_obj);
118 if (layout.payload_size == 0 and layout.tag_size != 0) {118 if (layout.payload_size == 0 and layout.tag_size != 0) {
119 return scalarType(ty.unionTagTypeSafety(mod).?, mod);119 return scalarType(ty.unionTagTypeSafety(mod).?, mod);
src/arch/x86_64/CodeGen.zig+3-3
...@@ -7962,8 +7962,8 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {...@@ -7962,8 +7962,8 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {
79627962
7963 const src_mcv = try self.resolveInst(operand);7963 const src_mcv = try self.resolveInst(operand);
7964 const field_off: u32 = switch (container_ty.containerLayout(mod)) {7964 const field_off: u32 = switch (container_ty.containerLayout(mod)) {
7965 .Auto, .Extern => @intCast(container_ty.structFieldOffset(index, mod) * 8),7965 .auto, .@"extern" => @intCast(container_ty.structFieldOffset(index, mod) * 8),
7966 .Packed => if (mod.typeToStruct(container_ty)) |struct_type|7966 .@"packed" => if (mod.typeToStruct(container_ty)) |struct_type|
7967 mod.structPackedFieldBitOffset(struct_type, index)7967 mod.structPackedFieldBitOffset(struct_type, index)
7968 else7968 else
7969 0,7969 0,
...@@ -17979,7 +17979,7 @@ fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {...@@ -17979,7 +17979,7 @@ fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {
17979 switch (result_ty.zigTypeTag(mod)) {17979 switch (result_ty.zigTypeTag(mod)) {
17980 .Struct => {17980 .Struct => {
17981 const frame_index = try self.allocFrameIndex(FrameAlloc.initSpill(result_ty, mod));17981 const frame_index = try self.allocFrameIndex(FrameAlloc.initSpill(result_ty, mod));
17982 if (result_ty.containerLayout(mod) == .Packed) {17982 if (result_ty.containerLayout(mod) == .@"packed") {
17983 const struct_type = mod.typeToStruct(result_ty).?;17983 const struct_type = mod.typeToStruct(result_ty).?;
17984 try self.genInlineMemset(17984 try self.genInlineMemset(
17985 .{ .lea_frame = .{ .index = frame_index } },17985 .{ .lea_frame = .{ .index = frame_index } },
src/arch/x86_64/abi.zig+3-3
...@@ -42,7 +42,7 @@ pub fn classifyWindows(ty: Type, mod: *Module) Class {...@@ -42,7 +42,7 @@ pub fn classifyWindows(ty: Type, mod: *Module) Class {
42 1, 2, 4, 8 => return .integer,42 1, 2, 4, 8 => return .integer,
43 else => switch (ty.zigTypeTag(mod)) {43 else => switch (ty.zigTypeTag(mod)) {
44 .Int => return .win_i128,44 .Int => return .win_i128,
45 .Struct, .Union => if (ty.containerLayout(mod) == .Packed) {45 .Struct, .Union => if (ty.containerLayout(mod) == .@"packed") {
46 return .win_i128;46 return .win_i128;
47 } else {47 } else {
48 return .memory;48 return .memory;
...@@ -238,7 +238,7 @@ pub fn classifySystemV(ty: Type, mod: *Module, ctx: Context) [8]Class {...@@ -238,7 +238,7 @@ pub fn classifySystemV(ty: Type, mod: *Module, ctx: Context) [8]Class {
238 // separately.".238 // separately.".
239 const struct_type = mod.typeToStruct(ty).?;239 const struct_type = mod.typeToStruct(ty).?;
240 const ty_size = ty.abiSize(mod);240 const ty_size = ty.abiSize(mod);
241 if (struct_type.layout == .Packed) {241 if (struct_type.layout == .@"packed") {
242 assert(ty_size <= 16);242 assert(ty_size <= 16);
243 result[0] = .integer;243 result[0] = .integer;
244 if (ty_size > 8) result[1] = .integer;244 if (ty_size > 8) result[1] = .integer;
...@@ -356,7 +356,7 @@ pub fn classifySystemV(ty: Type, mod: *Module, ctx: Context) [8]Class {...@@ -356,7 +356,7 @@ pub fn classifySystemV(ty: Type, mod: *Module, ctx: Context) [8]Class {
356 // separately.".356 // separately.".
357 const union_obj = mod.typeToUnion(ty).?;357 const union_obj = mod.typeToUnion(ty).?;
358 const ty_size = mod.unionAbiSize(union_obj);358 const ty_size = mod.unionAbiSize(union_obj);
359 if (union_obj.getLayout(ip) == .Packed) {359 if (union_obj.getLayout(ip) == .@"packed") {
360 assert(ty_size <= 16);360 assert(ty_size <= 16);
361 result[0] = .integer;361 result[0] = .integer;
362 if (ty_size > 8) result[1] = .integer;362 if (ty_size > 8) result[1] = .integer;
src/codegen.zig+4-4
...@@ -513,7 +513,7 @@ pub fn generateSymbol(...@@ -513,7 +513,7 @@ pub fn generateSymbol(
513 .struct_type => {513 .struct_type => {
514 const struct_type = ip.loadStructType(typed_value.ty.toIntern());514 const struct_type = ip.loadStructType(typed_value.ty.toIntern());
515 switch (struct_type.layout) {515 switch (struct_type.layout) {
516 .Packed => {516 .@"packed" => {
517 const abi_size = math.cast(usize, typed_value.ty.abiSize(mod)) orelse517 const abi_size = math.cast(usize, typed_value.ty.abiSize(mod)) orelse
518 return error.Overflow;518 return error.Overflow;
519 const current_pos = code.items.len;519 const current_pos = code.items.len;
...@@ -550,7 +550,7 @@ pub fn generateSymbol(...@@ -550,7 +550,7 @@ pub fn generateSymbol(
550 bits += @as(u16, @intCast(Type.fromInterned(field_ty).bitSize(mod)));550 bits += @as(u16, @intCast(Type.fromInterned(field_ty).bitSize(mod)));
551 }551 }
552 },552 },
553 .Auto, .Extern => {553 .auto, .@"extern" => {
554 const struct_begin = code.items.len;554 const struct_begin = code.items.len;
555 const field_types = struct_type.field_types.get(ip);555 const field_types = struct_type.field_types.get(ip);
556 const offsets = struct_type.offsets.get(ip);556 const offsets = struct_type.offsets.get(ip);
...@@ -736,11 +736,11 @@ fn lowerParentPtr(...@@ -736,11 +736,11 @@ fn lowerParentPtr(
736 .anon_struct_type,736 .anon_struct_type,
737 .union_type,737 .union_type,
738 => switch (Type.fromInterned(base_ty).containerLayout(mod)) {738 => switch (Type.fromInterned(base_ty).containerLayout(mod)) {
739 .Auto, .Extern => @intCast(Type.fromInterned(base_ty).structFieldOffset(739 .auto, .@"extern" => @intCast(Type.fromInterned(base_ty).structFieldOffset(
740 @intCast(field.index),740 @intCast(field.index),
741 mod,741 mod,
742 )),742 )),
743 .Packed => if (mod.typeToStruct(Type.fromInterned(base_ty))) |struct_obj|743 .@"packed" => if (mod.typeToStruct(Type.fromInterned(base_ty))) |struct_obj|
744 if (Type.fromInterned(ptr.ty).ptrInfo(mod).packed_offset.host_size == 0)744 if (Type.fromInterned(ptr.ty).ptrInfo(mod).packed_offset.host_size == 0)
745 @divExact(Type.fromInterned(base_ptr_ty).ptrInfo(mod)745 @divExact(Type.fromInterned(base_ptr_ty).ptrInfo(mod)
746 .packed_offset.bit_offset + mod.structPackedFieldBitOffset(746 .packed_offset.bit_offset + mod.structPackedFieldBitOffset(
src/codegen/c.zig+15-15
...@@ -890,7 +890,7 @@ pub const DeclGen = struct {...@@ -890,7 +890,7 @@ pub const DeclGen = struct {
890 return writer.writeAll(" }");890 return writer.writeAll(" }");
891 },891 },
892 .Struct => switch (ty.containerLayout(mod)) {892 .Struct => switch (ty.containerLayout(mod)) {
893 .Auto, .Extern => {893 .auto, .@"extern" => {
894 if (!location.isInitializer()) {894 if (!location.isInitializer()) {
895 try writer.writeByte('(');895 try writer.writeByte('(');
896 try dg.renderType(writer, ty);896 try dg.renderType(writer, ty);
...@@ -912,7 +912,7 @@ pub const DeclGen = struct {...@@ -912,7 +912,7 @@ pub const DeclGen = struct {
912912
913 return writer.writeByte('}');913 return writer.writeByte('}');
914 },914 },
915 .Packed => return writer.print("{x}", .{try dg.fmtIntLiteral(ty, Value.undef, .Other)}),915 .@"packed" => return writer.print("{x}", .{try dg.fmtIntLiteral(ty, Value.undef, .Other)}),
916 },916 },
917 .Union => {917 .Union => {
918 if (!location.isInitializer()) {918 if (!location.isInitializer()) {
...@@ -1379,7 +1379,7 @@ pub const DeclGen = struct {...@@ -1379,7 +1379,7 @@ pub const DeclGen = struct {
1379 .struct_type => {1379 .struct_type => {
1380 const struct_type = ip.loadStructType(ty.toIntern());1380 const struct_type = ip.loadStructType(ty.toIntern());
1381 switch (struct_type.layout) {1381 switch (struct_type.layout) {
1382 .Auto, .Extern => {1382 .auto, .@"extern" => {
1383 if (!location.isInitializer()) {1383 if (!location.isInitializer()) {
1384 try writer.writeByte('(');1384 try writer.writeByte('(');
1385 try dg.renderType(writer, ty);1385 try dg.renderType(writer, ty);
...@@ -1408,7 +1408,7 @@ pub const DeclGen = struct {...@@ -1408,7 +1408,7 @@ pub const DeclGen = struct {
1408 }1408 }
1409 try writer.writeByte('}');1409 try writer.writeByte('}');
1410 },1410 },
1411 .Packed => {1411 .@"packed" => {
1412 const int_info = ty.intInfo(mod);1412 const int_info = ty.intInfo(mod);
14131413
1414 const bits = Type.smallestUnsignedBits(int_info.bits - 1);1414 const bits = Type.smallestUnsignedBits(int_info.bits - 1);
...@@ -1517,7 +1517,7 @@ pub const DeclGen = struct {...@@ -1517,7 +1517,7 @@ pub const DeclGen = struct {
1517 if (un.tag == .none) {1517 if (un.tag == .none) {
1518 const backing_ty = try ty.unionBackingType(mod);1518 const backing_ty = try ty.unionBackingType(mod);
1519 switch (union_obj.getLayout(ip)) {1519 switch (union_obj.getLayout(ip)) {
1520 .Packed => {1520 .@"packed" => {
1521 if (!location.isInitializer()) {1521 if (!location.isInitializer()) {
1522 try writer.writeByte('(');1522 try writer.writeByte('(');
1523 try dg.renderType(writer, backing_ty);1523 try dg.renderType(writer, backing_ty);
...@@ -1525,7 +1525,7 @@ pub const DeclGen = struct {...@@ -1525,7 +1525,7 @@ pub const DeclGen = struct {
1525 }1525 }
1526 try dg.renderValue(writer, backing_ty, Value.fromInterned(un.val), initializer_type);1526 try dg.renderValue(writer, backing_ty, Value.fromInterned(un.val), initializer_type);
1527 },1527 },
1528 .Extern => {1528 .@"extern" => {
1529 if (location == .StaticInitializer) {1529 if (location == .StaticInitializer) {
1530 return dg.fail("TODO: C backend: implement extern union backing type rendering in static initializers", .{});1530 return dg.fail("TODO: C backend: implement extern union backing type rendering in static initializers", .{});
1531 }1531 }
...@@ -1551,7 +1551,7 @@ pub const DeclGen = struct {...@@ -1551,7 +1551,7 @@ pub const DeclGen = struct {
1551 const field_index = mod.unionTagFieldIndex(union_obj, Value.fromInterned(un.tag)).?;1551 const field_index = mod.unionTagFieldIndex(union_obj, Value.fromInterned(un.tag)).?;
1552 const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]);1552 const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]);
1553 const field_name = union_obj.loadTagType(ip).names.get(ip)[field_index];1553 const field_name = union_obj.loadTagType(ip).names.get(ip)[field_index];
1554 if (union_obj.getLayout(ip) == .Packed) {1554 if (union_obj.getLayout(ip) == .@"packed") {
1555 if (field_ty.hasRuntimeBits(mod)) {1555 if (field_ty.hasRuntimeBits(mod)) {
1556 if (field_ty.isPtrAtRuntime(mod)) {1556 if (field_ty.isPtrAtRuntime(mod)) {
1557 try writer.writeByte('(');1557 try writer.writeByte('(');
...@@ -5497,7 +5497,7 @@ fn fieldLocation(...@@ -5497,7 +5497,7 @@ fn fieldLocation(
5497 .Union => {5497 .Union => {
5498 const union_obj = mod.typeToUnion(container_ty).?;5498 const union_obj = mod.typeToUnion(container_ty).?;
5499 return switch (union_obj.getLayout(ip)) {5499 return switch (union_obj.getLayout(ip)) {
5500 .Auto, .Extern => {5500 .auto, .@"extern" => {
5501 const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]);5501 const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]);
5502 if (!field_ty.hasRuntimeBitsIgnoreComptime(mod))5502 if (!field_ty.hasRuntimeBitsIgnoreComptime(mod))
5503 return if (container_ty.unionTagTypeSafety(mod) != null and5503 return if (container_ty.unionTagTypeSafety(mod) != null and
...@@ -5511,7 +5511,7 @@ fn fieldLocation(...@@ -5511,7 +5511,7 @@ fn fieldLocation(
5511 else5511 else
5512 .{ .identifier = ip.stringToSlice(field_name) } };5512 .{ .identifier = ip.stringToSlice(field_name) } };
5513 },5513 },
5514 .Packed => .begin,5514 .@"packed" => .begin,
5515 };5515 };
5516 },5516 },
5517 .Pointer => switch (container_ty.ptrSize(mod)) {5517 .Pointer => switch (container_ty.ptrSize(mod)) {
...@@ -5671,11 +5671,11 @@ fn airStructFieldVal(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -5671,11 +5671,11 @@ fn airStructFieldVal(f: *Function, inst: Air.Inst.Index) !CValue {
56715671
5672 const field_name: CValue = switch (mod.intern_pool.indexToKey(struct_ty.ip_index)) {5672 const field_name: CValue = switch (mod.intern_pool.indexToKey(struct_ty.ip_index)) {
5673 .struct_type => switch (struct_ty.containerLayout(mod)) {5673 .struct_type => switch (struct_ty.containerLayout(mod)) {
5674 .Auto, .Extern => if (struct_ty.isSimpleTuple(mod))5674 .auto, .@"extern" => if (struct_ty.isSimpleTuple(mod))
5675 .{ .field = extra.field_index }5675 .{ .field = extra.field_index }
5676 else5676 else
5677 .{ .identifier = ip.stringToSlice(struct_ty.legacyStructFieldName(extra.field_index, mod)) },5677 .{ .identifier = ip.stringToSlice(struct_ty.legacyStructFieldName(extra.field_index, mod)) },
5678 .Packed => {5678 .@"packed" => {
5679 const struct_type = mod.typeToStruct(struct_ty).?;5679 const struct_type = mod.typeToStruct(struct_ty).?;
5680 const int_info = struct_ty.intInfo(mod);5680 const int_info = struct_ty.intInfo(mod);
56815681
...@@ -5740,7 +5740,7 @@ fn airStructFieldVal(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -5740,7 +5740,7 @@ fn airStructFieldVal(f: *Function, inst: Air.Inst.Index) !CValue {
57405740
5741 .union_type => field_name: {5741 .union_type => field_name: {
5742 const union_obj = ip.loadUnionType(struct_ty.toIntern());5742 const union_obj = ip.loadUnionType(struct_ty.toIntern());
5743 if (union_obj.flagsPtr(ip).layout == .Packed) {5743 if (union_obj.flagsPtr(ip).layout == .@"packed") {
5744 const operand_lval = if (struct_byval == .constant) blk: {5744 const operand_lval = if (struct_byval == .constant) blk: {
5745 const operand_local = try f.allocLocal(inst, struct_ty);5745 const operand_local = try f.allocLocal(inst, struct_ty);
5746 try f.writeCValue(writer, operand_local, .Other);5746 try f.writeCValue(writer, operand_local, .Other);
...@@ -7081,7 +7081,7 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -7081,7 +7081,7 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue {
7081 }7081 }
7082 },7082 },
7083 .Struct => switch (inst_ty.containerLayout(mod)) {7083 .Struct => switch (inst_ty.containerLayout(mod)) {
7084 .Auto, .Extern => for (resolved_elements, 0..) |element, field_index| {7084 .auto, .@"extern" => for (resolved_elements, 0..) |element, field_index| {
7085 if (inst_ty.structFieldIsComptime(field_index, mod)) continue;7085 if (inst_ty.structFieldIsComptime(field_index, mod)) continue;
7086 const field_ty = inst_ty.structFieldType(field_index, mod);7086 const field_ty = inst_ty.structFieldType(field_index, mod);
7087 if (!field_ty.hasRuntimeBitsIgnoreComptime(mod)) continue;7087 if (!field_ty.hasRuntimeBitsIgnoreComptime(mod)) continue;
...@@ -7095,7 +7095,7 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -7095,7 +7095,7 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue {
7095 try f.writeCValue(writer, element, .Other);7095 try f.writeCValue(writer, element, .Other);
7096 try a.end(f, writer);7096 try a.end(f, writer);
7097 },7097 },
7098 .Packed => {7098 .@"packed" => {
7099 try f.writeCValue(writer, local, .Other);7099 try f.writeCValue(writer, local, .Other);
7100 try writer.writeAll(" = ");7100 try writer.writeAll(" = ");
7101 const int_info = inst_ty.intInfo(mod);7101 const int_info = inst_ty.intInfo(mod);
...@@ -7181,7 +7181,7 @@ fn airUnionInit(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -7181,7 +7181,7 @@ fn airUnionInit(f: *Function, inst: Air.Inst.Index) !CValue {
71817181
7182 const writer = f.object.writer();7182 const writer = f.object.writer();
7183 const local = try f.allocLocal(inst, union_ty);7183 const local = try f.allocLocal(inst, union_ty);
7184 if (union_obj.getLayout(ip) == .Packed) {7184 if (union_obj.getLayout(ip) == .@"packed") {
7185 try f.writeCValue(writer, local, .Other);7185 try f.writeCValue(writer, local, .Other);
7186 try writer.writeAll(" = ");7186 try writer.writeAll(" = ");
7187 try f.writeCValue(writer, payload, .Initializer);7187 try f.writeCValue(writer, payload, .Initializer);
src/codegen/c/type.zig+1-1
...@@ -1495,7 +1495,7 @@ pub const CType = extern union {...@@ -1495,7 +1495,7 @@ pub const CType = extern union {
1495 }1495 }
1496 },1496 },
14971497
1498 .Struct, .Union => |zig_ty_tag| if (ty.containerLayout(mod) == .Packed) {1498 .Struct, .Union => |zig_ty_tag| if (ty.containerLayout(mod) == .@"packed") {
1499 if (mod.typeToPackedStruct(ty)) |packed_struct| {1499 if (mod.typeToPackedStruct(ty)) |packed_struct| {
1500 try self.initType(Type.fromInterned(packed_struct.backingIntType(ip).*), kind, lookup);1500 try self.initType(Type.fromInterned(packed_struct.backingIntType(ip).*), kind, lookup);
1501 } else {1501 } else {
src/codegen/llvm.zig+17-17
...@@ -3327,7 +3327,7 @@ pub const Object = struct {...@@ -3327,7 +3327,7 @@ pub const Object = struct {
33273327
3328 const struct_type = ip.loadStructType(t.toIntern());3328 const struct_type = ip.loadStructType(t.toIntern());
33293329
3330 if (struct_type.layout == .Packed) {3330 if (struct_type.layout == .@"packed") {
3331 const int_ty = try o.lowerType(Type.fromInterned(struct_type.backingIntType(ip).*));3331 const int_ty = try o.lowerType(Type.fromInterned(struct_type.backingIntType(ip).*));
3332 try o.type_map.put(o.gpa, t.toIntern(), int_ty);3332 try o.type_map.put(o.gpa, t.toIntern(), int_ty);
3333 return int_ty;3333 return int_ty;
...@@ -3477,7 +3477,7 @@ pub const Object = struct {...@@ -3477,7 +3477,7 @@ pub const Object = struct {
3477 const union_obj = ip.loadUnionType(t.toIntern());3477 const union_obj = ip.loadUnionType(t.toIntern());
3478 const layout = mod.getUnionLayout(union_obj);3478 const layout = mod.getUnionLayout(union_obj);
34793479
3480 if (union_obj.flagsPtr(ip).layout == .Packed) {3480 if (union_obj.flagsPtr(ip).layout == .@"packed") {
3481 const int_ty = try o.builder.intType(@intCast(t.bitSize(mod)));3481 const int_ty = try o.builder.intType(@intCast(t.bitSize(mod)));
3482 try o.type_map.put(o.gpa, t.toIntern(), int_ty);3482 try o.type_map.put(o.gpa, t.toIntern(), int_ty);
3483 return int_ty;3483 return int_ty;
...@@ -4038,7 +4038,7 @@ pub const Object = struct {...@@ -4038,7 +4038,7 @@ pub const Object = struct {
4038 const struct_type = ip.loadStructType(ty.toIntern());4038 const struct_type = ip.loadStructType(ty.toIntern());
4039 assert(struct_type.haveLayout(ip));4039 assert(struct_type.haveLayout(ip));
4040 const struct_ty = try o.lowerType(ty);4040 const struct_ty = try o.lowerType(ty);
4041 if (struct_type.layout == .Packed) {4041 if (struct_type.layout == .@"packed") {
4042 comptime assert(Type.packed_struct_layout_version == 2);4042 comptime assert(Type.packed_struct_layout_version == 2);
4043 var running_int = try o.builder.intConst(struct_ty, 0);4043 var running_int = try o.builder.intConst(struct_ty, 0);
4044 var running_bits: u16 = 0;4044 var running_bits: u16 = 0;
...@@ -4154,7 +4154,7 @@ pub const Object = struct {...@@ -4154,7 +4154,7 @@ pub const Object = struct {
4154 const payload = if (un.tag != .none) p: {4154 const payload = if (un.tag != .none) p: {
4155 const field_index = mod.unionTagFieldIndex(union_obj, Value.fromInterned(un.tag)).?;4155 const field_index = mod.unionTagFieldIndex(union_obj, Value.fromInterned(un.tag)).?;
4156 const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]);4156 const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]);
4157 if (container_layout == .Packed) {4157 if (container_layout == .@"packed") {
4158 if (!field_ty.hasRuntimeBits(mod)) return o.builder.intConst(union_ty, 0);4158 if (!field_ty.hasRuntimeBits(mod)) return o.builder.intConst(union_ty, 0);
4159 const small_int_val = try o.builder.castConst(4159 const small_int_val = try o.builder.castConst(
4160 if (field_ty.isPtrAtRuntime(mod)) .ptrtoint else .bitcast,4160 if (field_ty.isPtrAtRuntime(mod)) .ptrtoint else .bitcast,
...@@ -4190,7 +4190,7 @@ pub const Object = struct {...@@ -4190,7 +4190,7 @@ pub const Object = struct {
4190 } else p: {4190 } else p: {
4191 assert(layout.tag_size == 0);4191 assert(layout.tag_size == 0);
4192 const union_val = try o.lowerValue(un.val);4192 const union_val = try o.lowerValue(un.val);
4193 if (container_layout == .Packed) {4193 if (container_layout == .@"packed") {
4194 const bitcast_val = try o.builder.castConst(4194 const bitcast_val = try o.builder.castConst(
4195 .bitcast,4195 .bitcast,
4196 union_val,4196 union_val,
...@@ -4324,7 +4324,7 @@ pub const Object = struct {...@@ -4324,7 +4324,7 @@ pub const Object = struct {
4324 const field_index: u32 = @intCast(field_ptr.index);4324 const field_index: u32 = @intCast(field_ptr.index);
4325 switch (parent_ty.zigTypeTag(mod)) {4325 switch (parent_ty.zigTypeTag(mod)) {
4326 .Union => {4326 .Union => {
4327 if (parent_ty.containerLayout(mod) == .Packed) {4327 if (parent_ty.containerLayout(mod) == .@"packed") {
4328 return parent_ptr;4328 return parent_ptr;
4329 }4329 }
43304330
...@@ -6531,7 +6531,7 @@ pub const FuncGen = struct {...@@ -6531,7 +6531,7 @@ pub const FuncGen = struct {
6531 assert(!isByRef(field_ty, mod));6531 assert(!isByRef(field_ty, mod));
6532 switch (struct_ty.zigTypeTag(mod)) {6532 switch (struct_ty.zigTypeTag(mod)) {
6533 .Struct => switch (struct_ty.containerLayout(mod)) {6533 .Struct => switch (struct_ty.containerLayout(mod)) {
6534 .Packed => {6534 .@"packed" => {
6535 const struct_type = mod.typeToStruct(struct_ty).?;6535 const struct_type = mod.typeToStruct(struct_ty).?;
6536 const bit_offset = mod.structPackedFieldBitOffset(struct_type, field_index);6536 const bit_offset = mod.structPackedFieldBitOffset(struct_type, field_index);
6537 const containing_int = struct_llvm_val;6537 const containing_int = struct_llvm_val;
...@@ -6558,7 +6558,7 @@ pub const FuncGen = struct {...@@ -6558,7 +6558,7 @@ pub const FuncGen = struct {
6558 },6558 },
6559 },6559 },
6560 .Union => {6560 .Union => {
6561 assert(struct_ty.containerLayout(mod) == .Packed);6561 assert(struct_ty.containerLayout(mod) == .@"packed");
6562 const containing_int = struct_llvm_val;6562 const containing_int = struct_llvm_val;
6563 const elem_llvm_ty = try o.lowerType(field_ty);6563 const elem_llvm_ty = try o.lowerType(field_ty);
6564 if (field_ty.zigTypeTag(mod) == .Float or field_ty.zigTypeTag(mod) == .Vector) {6564 if (field_ty.zigTypeTag(mod) == .Float or field_ty.zigTypeTag(mod) == .Vector) {
...@@ -6581,7 +6581,7 @@ pub const FuncGen = struct {...@@ -6581,7 +6581,7 @@ pub const FuncGen = struct {
6581 switch (struct_ty.zigTypeTag(mod)) {6581 switch (struct_ty.zigTypeTag(mod)) {
6582 .Struct => {6582 .Struct => {
6583 const layout = struct_ty.containerLayout(mod);6583 const layout = struct_ty.containerLayout(mod);
6584 assert(layout != .Packed);6584 assert(layout != .@"packed");
6585 const struct_llvm_ty = try o.lowerType(struct_ty);6585 const struct_llvm_ty = try o.lowerType(struct_ty);
6586 const llvm_field_index = o.llvmFieldIndex(struct_ty, field_index).?;6586 const llvm_field_index = o.llvmFieldIndex(struct_ty, field_index).?;
6587 const field_ptr =6587 const field_ptr =
...@@ -9995,7 +9995,7 @@ pub const FuncGen = struct {...@@ -9995,7 +9995,7 @@ pub const FuncGen = struct {
9995 return running_int;9995 return running_int;
9996 }9996 }
99979997
9998 assert(result_ty.containerLayout(mod) != .Packed);9998 assert(result_ty.containerLayout(mod) != .@"packed");
99999999
10000 if (isByRef(result_ty, mod)) {10000 if (isByRef(result_ty, mod)) {
10001 // TODO in debug builds init to undef so that the padding will be 0xaa10001 // TODO in debug builds init to undef so that the padding will be 0xaa
...@@ -10080,7 +10080,7 @@ pub const FuncGen = struct {...@@ -10080,7 +10080,7 @@ pub const FuncGen = struct {
10080 const layout = union_ty.unionGetLayout(mod);10080 const layout = union_ty.unionGetLayout(mod);
10081 const union_obj = mod.typeToUnion(union_ty).?;10081 const union_obj = mod.typeToUnion(union_ty).?;
1008210082
10083 if (union_obj.getLayout(ip) == .Packed) {10083 if (union_obj.getLayout(ip) == .@"packed") {
10084 const big_bits = union_ty.bitSize(mod);10084 const big_bits = union_ty.bitSize(mod);
10085 const int_llvm_ty = try o.builder.intType(@intCast(big_bits));10085 const int_llvm_ty = try o.builder.intType(@intCast(big_bits));
10086 const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[extra.field_index]);10086 const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[extra.field_index]);
...@@ -10420,7 +10420,7 @@ pub const FuncGen = struct {...@@ -10420,7 +10420,7 @@ pub const FuncGen = struct {
10420 const struct_ty = struct_ptr_ty.childType(mod);10420 const struct_ty = struct_ptr_ty.childType(mod);
10421 switch (struct_ty.zigTypeTag(mod)) {10421 switch (struct_ty.zigTypeTag(mod)) {
10422 .Struct => switch (struct_ty.containerLayout(mod)) {10422 .Struct => switch (struct_ty.containerLayout(mod)) {
10423 .Packed => {10423 .@"packed" => {
10424 const result_ty = self.typeOfIndex(inst);10424 const result_ty = self.typeOfIndex(inst);
10425 const result_ty_info = result_ty.ptrInfo(mod);10425 const result_ty_info = result_ty.ptrInfo(mod);
10426 const struct_ptr_ty_info = struct_ptr_ty.ptrInfo(mod);10426 const struct_ptr_ty_info = struct_ptr_ty.ptrInfo(mod);
...@@ -10462,7 +10462,7 @@ pub const FuncGen = struct {...@@ -10462,7 +10462,7 @@ pub const FuncGen = struct {
10462 },10462 },
10463 .Union => {10463 .Union => {
10464 const layout = struct_ty.unionGetLayout(mod);10464 const layout = struct_ty.unionGetLayout(mod);
10465 if (layout.payload_size == 0 or struct_ty.containerLayout(mod) == .Packed) return struct_ptr;10465 if (layout.payload_size == 0 or struct_ty.containerLayout(mod) == .@"packed") return struct_ptr;
10466 const payload_index = @intFromBool(layout.tag_align.compare(.gte, layout.payload_align));10466 const payload_index = @intFromBool(layout.tag_align.compare(.gte, layout.payload_align));
10467 const union_llvm_ty = try o.lowerType(struct_ty);10467 const union_llvm_ty = try o.lowerType(struct_ty);
10468 return self.wip.gepStruct(union_llvm_ty, struct_ptr, payload_index, "");10468 return self.wip.gepStruct(union_llvm_ty, struct_ptr, payload_index, "");
...@@ -11572,7 +11572,7 @@ fn isByRef(ty: Type, mod: *Module) bool {...@@ -11572,7 +11572,7 @@ fn isByRef(ty: Type, mod: *Module) bool {
11572 };11572 };
1157311573
11574 // Packed structs are represented to LLVM as integers.11574 // Packed structs are represented to LLVM as integers.
11575 if (struct_type.layout == .Packed) return false;11575 if (struct_type.layout == .@"packed") return false;
1157611576
11577 const field_types = struct_type.field_types.get(ip);11577 const field_types = struct_type.field_types.get(ip);
11578 var it = struct_type.iterateRuntimeOrder(ip);11578 var it = struct_type.iterateRuntimeOrder(ip);
...@@ -11586,7 +11586,7 @@ fn isByRef(ty: Type, mod: *Module) bool {...@@ -11586,7 +11586,7 @@ fn isByRef(ty: Type, mod: *Module) bool {
11586 return false;11586 return false;
11587 },11587 },
11588 .Union => switch (ty.containerLayout(mod)) {11588 .Union => switch (ty.containerLayout(mod)) {
11589 .Packed => return false,11589 .@"packed" => return false,
11590 else => return ty.hasRuntimeBits(mod),11590 else => return ty.hasRuntimeBits(mod),
11591 },11591 },
11592 .ErrorUnion => {11592 .ErrorUnion => {
...@@ -11624,8 +11624,8 @@ fn isScalar(mod: *Module, ty: Type) bool {...@@ -11624,8 +11624,8 @@ fn isScalar(mod: *Module, ty: Type) bool {
11624 .Vector,11624 .Vector,
11625 => true,11625 => true,
1162611626
11627 .Struct => ty.containerLayout(mod) == .Packed,11627 .Struct => ty.containerLayout(mod) == .@"packed",
11628 .Union => ty.containerLayout(mod) == .Packed,11628 .Union => ty.containerLayout(mod) == .@"packed",
11629 else => false,11629 else => false,
11630 };11630 };
11631}11631}
src/codegen/spirv.zig+8-8
...@@ -979,7 +979,7 @@ const DeclGen = struct {...@@ -979,7 +979,7 @@ const DeclGen = struct {
979 },979 },
980 .struct_type => {980 .struct_type => {
981 const struct_type = mod.typeToStruct(ty).?;981 const struct_type = mod.typeToStruct(ty).?;
982 if (struct_type.layout == .Packed) {982 if (struct_type.layout == .@"packed") {
983 return self.todo("packed struct constants", .{});983 return self.todo("packed struct constants", .{});
984 }984 }
985985
...@@ -1275,7 +1275,7 @@ const DeclGen = struct {...@@ -1275,7 +1275,7 @@ const DeclGen = struct {
1275 const ip = &mod.intern_pool;1275 const ip = &mod.intern_pool;
1276 const union_obj = mod.typeToUnion(ty).?;1276 const union_obj = mod.typeToUnion(ty).?;
12771277
1278 if (union_obj.getLayout(ip) == .Packed) {1278 if (union_obj.getLayout(ip) == .@"packed") {
1279 return self.todo("packed union types", .{});1279 return self.todo("packed union types", .{});
1280 }1280 }
12811281
...@@ -1532,7 +1532,7 @@ const DeclGen = struct {...@@ -1532,7 +1532,7 @@ const DeclGen = struct {
1532 else => unreachable,1532 else => unreachable,
1533 };1533 };
15341534
1535 if (struct_type.layout == .Packed) {1535 if (struct_type.layout == .@"packed") {
1536 return try self.resolveType(Type.fromInterned(struct_type.backingIntType(ip).*), .direct);1536 return try self.resolveType(Type.fromInterned(struct_type.backingIntType(ip).*), .direct);
1537 }1537 }
15381538
...@@ -3904,7 +3904,7 @@ const DeclGen = struct {...@@ -3904,7 +3904,7 @@ const DeclGen = struct {
3904 const union_ty = mod.typeToUnion(ty).?;3904 const union_ty = mod.typeToUnion(ty).?;
3905 const tag_ty = Type.fromInterned(union_ty.enum_tag_ty);3905 const tag_ty = Type.fromInterned(union_ty.enum_tag_ty);
39063906
3907 if (union_ty.getLayout(ip) == .Packed) {3907 if (union_ty.getLayout(ip) == .@"packed") {
3908 unreachable; // TODO3908 unreachable; // TODO
3909 }3909 }
39103910
...@@ -3984,11 +3984,11 @@ const DeclGen = struct {...@@ -3984,11 +3984,11 @@ const DeclGen = struct {
39843984
3985 switch (object_ty.zigTypeTag(mod)) {3985 switch (object_ty.zigTypeTag(mod)) {
3986 .Struct => switch (object_ty.containerLayout(mod)) {3986 .Struct => switch (object_ty.containerLayout(mod)) {
3987 .Packed => unreachable, // TODO3987 .@"packed" => unreachable, // TODO
3988 else => return try self.extractField(field_ty, object_id, field_index),3988 else => return try self.extractField(field_ty, object_id, field_index),
3989 },3989 },
3990 .Union => switch (object_ty.containerLayout(mod)) {3990 .Union => switch (object_ty.containerLayout(mod)) {
3991 .Packed => unreachable, // TODO3991 .@"packed" => unreachable, // TODO
3992 else => {3992 else => {
3993 // Store, ptr-elem-ptr, pointer-cast, load3993 // Store, ptr-elem-ptr, pointer-cast, load
3994 const layout = self.unionLayout(object_ty);3994 const layout = self.unionLayout(object_ty);
...@@ -4058,13 +4058,13 @@ const DeclGen = struct {...@@ -4058,13 +4058,13 @@ const DeclGen = struct {
4058 const object_ty = object_ptr_ty.childType(mod);4058 const object_ty = object_ptr_ty.childType(mod);
4059 switch (object_ty.zigTypeTag(mod)) {4059 switch (object_ty.zigTypeTag(mod)) {
4060 .Struct => switch (object_ty.containerLayout(mod)) {4060 .Struct => switch (object_ty.containerLayout(mod)) {
4061 .Packed => unreachable, // TODO4061 .@"packed" => unreachable, // TODO
4062 else => {4062 else => {
4063 return try self.accessChain(result_ty_ref, object_ptr, &.{field_index});4063 return try self.accessChain(result_ty_ref, object_ptr, &.{field_index});
4064 },4064 },
4065 },4065 },
4066 .Union => switch (object_ty.containerLayout(mod)) {4066 .Union => switch (object_ty.containerLayout(mod)) {
4067 .Packed => unreachable, // TODO4067 .@"packed" => unreachable, // TODO
4068 else => {4068 else => {
4069 const layout = self.unionLayout(object_ty);4069 const layout = self.unionLayout(object_ty);
4070 if (!layout.has_payload) {4070 if (!layout.has_payload) {
src/codegen/spirv/Section.zig+2-2
...@@ -154,7 +154,7 @@ pub fn writeOperand(section: *Section, comptime Operand: type, operand: Operand)...@@ -154,7 +154,7 @@ pub fn writeOperand(section: *Section, comptime Operand: type, operand: Operand)
154 }154 }
155 },155 },
156 .Struct => |info| {156 .Struct => |info| {
157 if (info.layout == .Packed) {157 if (info.layout == .@"packed") {
158 section.writeWord(@as(Word, @bitCast(operand)));158 section.writeWord(@as(Word, @bitCast(operand)));
159 } else {159 } else {
160 section.writeExtendedMask(Operand, operand);160 section.writeExtendedMask(Operand, operand);
...@@ -288,7 +288,7 @@ fn operandSize(comptime Operand: type, operand: Operand) usize {...@@ -288,7 +288,7 @@ fn operandSize(comptime Operand: type, operand: Operand) usize {
288 }288 }
289 break :blk total;289 break :blk total;
290 },290 },
291 .Struct => |info| if (info.layout == .Packed) 1 else extendedMaskSize(Operand, operand),291 .Struct => |info| if (info.layout == .@"packed") 1 else extendedMaskSize(Operand, operand),
292 .Union => extendedUnionSize(Operand, operand),292 .Union => extendedUnionSize(Operand, operand),
293 else => unreachable,293 else => unreachable,
294 },294 },
src/link/Dwarf.zig+1-1
...@@ -317,7 +317,7 @@ pub const DeclState = struct {...@@ -317,7 +317,7 @@ pub const DeclState = struct {
317 try ty.print(dbg_info_buffer.writer(), mod);317 try ty.print(dbg_info_buffer.writer(), mod);
318 try dbg_info_buffer.append(0);318 try dbg_info_buffer.append(0);
319319
320 if (struct_type.layout == .Packed) {320 if (struct_type.layout == .@"packed") {
321 log.debug("TODO implement .debug_info for packed structs", .{});321 log.debug("TODO implement .debug_info for packed structs", .{});
322 break :blk;322 break :blk;
323 }323 }
src/print_zir.zig+1-1
...@@ -1440,7 +1440,7 @@ const Writer = struct {...@@ -1440,7 +1440,7 @@ const Writer = struct {
1440 if (small.has_backing_int) {1440 if (small.has_backing_int) {
1441 const backing_int_body_len = self.code.extra[extra_index];1441 const backing_int_body_len = self.code.extra[extra_index];
1442 extra_index += 1;1442 extra_index += 1;
1443 try stream.writeAll("Packed(");1443 try stream.writeAll("packed(");
1444 if (backing_int_body_len == 0) {1444 if (backing_int_body_len == 0) {
1445 const backing_int_ref: Zir.Inst.Ref = @enumFromInt(self.code.extra[extra_index]);1445 const backing_int_ref: Zir.Inst.Ref = @enumFromInt(self.code.extra[extra_index]);
1446 extra_index += 1;1446 extra_index += 1;
src/type.zig+19-19
...@@ -741,12 +741,12 @@ pub const Type = struct {...@@ -741,12 +741,12 @@ pub const Type = struct {
741 .struct_type => {741 .struct_type => {
742 const struct_type = ip.loadStructType(ty.toIntern());742 const struct_type = ip.loadStructType(ty.toIntern());
743 // Struct with no fields have a well-defined layout of no bits.743 // Struct with no fields have a well-defined layout of no bits.
744 return struct_type.layout != .Auto or struct_type.field_types.len == 0;744 return struct_type.layout != .auto or struct_type.field_types.len == 0;
745 },745 },
746 .union_type => {746 .union_type => {
747 const union_type = ip.loadUnionType(ty.toIntern());747 const union_type = ip.loadUnionType(ty.toIntern());
748 return switch (union_type.flagsPtr(ip).runtime_tag) {748 return switch (union_type.flagsPtr(ip).runtime_tag) {
749 .none, .safety => union_type.flagsPtr(ip).layout != .Auto,749 .none, .safety => union_type.flagsPtr(ip).layout != .auto,
750 .tagged => false,750 .tagged => false,
751 };751 };
752 },752 },
...@@ -1027,7 +1027,7 @@ pub const Type = struct {...@@ -1027,7 +1027,7 @@ pub const Type = struct {
1027 },1027 },
1028 .struct_type => {1028 .struct_type => {
1029 const struct_type = ip.loadStructType(ty.toIntern());1029 const struct_type = ip.loadStructType(ty.toIntern());
1030 if (struct_type.layout == .Packed) {1030 if (struct_type.layout == .@"packed") {
1031 switch (strat) {1031 switch (strat) {
1032 .sema => |sema| try sema.resolveTypeLayout(ty),1032 .sema => |sema| try sema.resolveTypeLayout(ty),
1033 .lazy => if (struct_type.backingIntType(ip).* == .none) return .{1033 .lazy => if (struct_type.backingIntType(ip).* == .none) return .{
...@@ -1407,7 +1407,7 @@ pub const Type = struct {...@@ -1407,7 +1407,7 @@ pub const Type = struct {
1407 switch (strat) {1407 switch (strat) {
1408 .sema => |sema| try sema.resolveTypeLayout(ty),1408 .sema => |sema| try sema.resolveTypeLayout(ty),
1409 .lazy => switch (struct_type.layout) {1409 .lazy => switch (struct_type.layout) {
1410 .Packed => {1410 .@"packed" => {
1411 if (struct_type.backingIntType(ip).* == .none) return .{1411 if (struct_type.backingIntType(ip).* == .none) return .{
1412 .val = Value.fromInterned((try mod.intern(.{ .int = .{1412 .val = Value.fromInterned((try mod.intern(.{ .int = .{
1413 .ty = .comptime_int_type,1413 .ty = .comptime_int_type,
...@@ -1415,7 +1415,7 @@ pub const Type = struct {...@@ -1415,7 +1415,7 @@ pub const Type = struct {
1415 } }))),1415 } }))),
1416 };1416 };
1417 },1417 },
1418 .Auto, .Extern => {1418 .auto, .@"extern" => {
1419 if (!struct_type.haveLayout(ip)) return .{1419 if (!struct_type.haveLayout(ip)) return .{
1420 .val = Value.fromInterned((try mod.intern(.{ .int = .{1420 .val = Value.fromInterned((try mod.intern(.{ .int = .{
1421 .ty = .comptime_int_type,1421 .ty = .comptime_int_type,
...@@ -1427,10 +1427,10 @@ pub const Type = struct {...@@ -1427,10 +1427,10 @@ pub const Type = struct {
1427 .eager => {},1427 .eager => {},
1428 }1428 }
1429 switch (struct_type.layout) {1429 switch (struct_type.layout) {
1430 .Packed => return .{1430 .@"packed" => return .{
1431 .scalar = Type.fromInterned(struct_type.backingIntType(ip).*).abiSize(mod),1431 .scalar = Type.fromInterned(struct_type.backingIntType(ip).*).abiSize(mod),
1432 },1432 },
1433 .Auto, .Extern => {1433 .auto, .@"extern" => {
1434 assert(struct_type.haveLayout(ip));1434 assert(struct_type.haveLayout(ip));
1435 return .{ .scalar = struct_type.size(ip).* };1435 return .{ .scalar = struct_type.size(ip).* };
1436 },1436 },
...@@ -1656,7 +1656,7 @@ pub const Type = struct {...@@ -1656,7 +1656,7 @@ pub const Type = struct {
1656 },1656 },
1657 .struct_type => {1657 .struct_type => {
1658 const struct_type = ip.loadStructType(ty.toIntern());1658 const struct_type = ip.loadStructType(ty.toIntern());
1659 const is_packed = struct_type.layout == .Packed;1659 const is_packed = struct_type.layout == .@"packed";
1660 if (opt_sema) |sema| {1660 if (opt_sema) |sema| {
1661 try sema.resolveTypeFields(ty);1661 try sema.resolveTypeFields(ty);
1662 if (is_packed) try sema.resolveTypeLayout(ty);1662 if (is_packed) try sema.resolveTypeLayout(ty);
...@@ -1674,7 +1674,7 @@ pub const Type = struct {...@@ -1674,7 +1674,7 @@ pub const Type = struct {
16741674
1675 .union_type => {1675 .union_type => {
1676 const union_type = ip.loadUnionType(ty.toIntern());1676 const union_type = ip.loadUnionType(ty.toIntern());
1677 const is_packed = ty.containerLayout(mod) == .Packed;1677 const is_packed = ty.containerLayout(mod) == .@"packed";
1678 if (opt_sema) |sema| {1678 if (opt_sema) |sema| {
1679 try sema.resolveTypeFields(ty);1679 try sema.resolveTypeFields(ty);
1680 if (is_packed) try sema.resolveTypeLayout(ty);1680 if (is_packed) try sema.resolveTypeLayout(ty);
...@@ -1987,9 +1987,9 @@ pub const Type = struct {...@@ -1987,9 +1987,9 @@ pub const Type = struct {
1987 /// Asserts the type is either an extern or packed union.1987 /// Asserts the type is either an extern or packed union.
1988 pub fn unionBackingType(ty: Type, mod: *Module) !Type {1988 pub fn unionBackingType(ty: Type, mod: *Module) !Type {
1989 return switch (ty.containerLayout(mod)) {1989 return switch (ty.containerLayout(mod)) {
1990 .Extern => try mod.arrayType(.{ .len = ty.abiSize(mod), .child = .u8_type }),1990 .@"extern" => try mod.arrayType(.{ .len = ty.abiSize(mod), .child = .u8_type }),
1991 .Packed => try mod.intType(.unsigned, @intCast(ty.bitSize(mod))),1991 .@"packed" => try mod.intType(.unsigned, @intCast(ty.bitSize(mod))),
1992 .Auto => unreachable,1992 .auto => unreachable,
1993 };1993 };
1994 }1994 }
19951995
...@@ -2003,7 +2003,7 @@ pub const Type = struct {...@@ -2003,7 +2003,7 @@ pub const Type = struct {
2003 const ip = &mod.intern_pool;2003 const ip = &mod.intern_pool;
2004 return switch (ip.indexToKey(ty.toIntern())) {2004 return switch (ip.indexToKey(ty.toIntern())) {
2005 .struct_type => ip.loadStructType(ty.toIntern()).layout,2005 .struct_type => ip.loadStructType(ty.toIntern()).layout,
2006 .anon_struct_type => .Auto,2006 .anon_struct_type => .auto,
2007 .union_type => ip.loadUnionType(ty.toIntern()).flagsPtr(ip).layout,2007 .union_type => ip.loadUnionType(ty.toIntern()).flagsPtr(ip).layout,
2008 else => unreachable,2008 else => unreachable,
2009 };2009 };
...@@ -2177,7 +2177,7 @@ pub const Type = struct {...@@ -2177,7 +2177,7 @@ pub const Type = struct {
2177 pub fn isAbiInt(ty: Type, mod: *Module) bool {2177 pub fn isAbiInt(ty: Type, mod: *Module) bool {
2178 return switch (ty.zigTypeTag(mod)) {2178 return switch (ty.zigTypeTag(mod)) {
2179 .Int, .Enum, .ErrorSet => true,2179 .Int, .Enum, .ErrorSet => true,
2180 .Struct => ty.containerLayout(mod) == .Packed,2180 .Struct => ty.containerLayout(mod) == .@"packed",
2181 else => false,2181 else => false,
2182 };2182 };
2183 }2183 }
...@@ -2690,7 +2690,7 @@ pub const Type = struct {...@@ -2690,7 +2690,7 @@ pub const Type = struct {
2690 const struct_type = ip.loadStructType(ty.toIntern());2690 const struct_type = ip.loadStructType(ty.toIntern());
2691 // packed structs cannot be comptime-only because they have a well-defined2691 // packed structs cannot be comptime-only because they have a well-defined
2692 // memory layout and every field has a well-defined bit pattern.2692 // memory layout and every field has a well-defined bit pattern.
2693 if (struct_type.layout == .Packed)2693 if (struct_type.layout == .@"packed")
2694 return false;2694 return false;
26952695
2696 // A struct with no fields is not comptime-only.2696 // A struct with no fields is not comptime-only.
...@@ -3051,7 +3051,7 @@ pub const Type = struct {...@@ -3051,7 +3051,7 @@ pub const Type = struct {
3051 switch (ip.indexToKey(ty.toIntern())) {3051 switch (ip.indexToKey(ty.toIntern())) {
3052 .struct_type => {3052 .struct_type => {
3053 const struct_type = ip.loadStructType(ty.toIntern());3053 const struct_type = ip.loadStructType(ty.toIntern());
3054 assert(struct_type.layout != .Packed);3054 assert(struct_type.layout != .@"packed");
3055 const explicit_align = struct_type.fieldAlign(ip, index);3055 const explicit_align = struct_type.fieldAlign(ip, index);
3056 const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[index]);3056 const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[index]);
3057 return mod.structFieldAlignment(explicit_align, field_ty, struct_type.layout);3057 return mod.structFieldAlignment(explicit_align, field_ty, struct_type.layout);
...@@ -3132,7 +3132,7 @@ pub const Type = struct {...@@ -3132,7 +3132,7 @@ pub const Type = struct {
3132 .struct_type => {3132 .struct_type => {
3133 const struct_type = ip.loadStructType(ty.toIntern());3133 const struct_type = ip.loadStructType(ty.toIntern());
3134 assert(struct_type.haveLayout(ip));3134 assert(struct_type.haveLayout(ip));
3135 assert(struct_type.layout != .Packed);3135 assert(struct_type.layout != .@"packed");
3136 return struct_type.offsets.get(ip)[index];3136 return struct_type.offsets.get(ip)[index];
3137 },3137 },
31383138
...@@ -3208,7 +3208,7 @@ pub const Type = struct {...@@ -3208,7 +3208,7 @@ pub const Type = struct {
3208 return switch (ip.indexToKey(ty.toIntern())) {3208 return switch (ip.indexToKey(ty.toIntern())) {
3209 .struct_type => {3209 .struct_type => {
3210 const struct_type = ip.loadStructType(ty.toIntern());3210 const struct_type = ip.loadStructType(ty.toIntern());
3211 if (struct_type.layout == .Packed) return false;3211 if (struct_type.layout == .@"packed") return false;
3212 if (struct_type.decl == .none) return false;3212 if (struct_type.decl == .none) return false;
3213 return struct_type.flagsPtr(ip).is_tuple;3213 return struct_type.flagsPtr(ip).is_tuple;
3214 },3214 },
...@@ -3230,7 +3230,7 @@ pub const Type = struct {...@@ -3230,7 +3230,7 @@ pub const Type = struct {
3230 return switch (ip.indexToKey(ty.toIntern())) {3230 return switch (ip.indexToKey(ty.toIntern())) {
3231 .struct_type => {3231 .struct_type => {
3232 const struct_type = ip.loadStructType(ty.toIntern());3232 const struct_type = ip.loadStructType(ty.toIntern());
3233 if (struct_type.layout == .Packed) return false;3233 if (struct_type.layout == .@"packed") return false;
3234 if (struct_type.decl == .none) return false;3234 if (struct_type.decl == .none) return false;
3235 return struct_type.flagsPtr(ip).is_tuple;3235 return struct_type.flagsPtr(ip).is_tuple;
3236 },3236 },
test/behavior/tuple.zig+3-3
...@@ -135,7 +135,7 @@ test "array-like initializer for tuple types" {...@@ -135,7 +135,7 @@ test "array-like initializer for tuple types" {
135 const T = @Type(.{135 const T = @Type(.{
136 .Struct = .{136 .Struct = .{
137 .is_tuple = true,137 .is_tuple = true,
138 .layout = .Auto,138 .layout = .auto,
139 .decls = &.{},139 .decls = &.{},
140 .fields = &.{140 .fields = &.{
141 .{141 .{
...@@ -323,7 +323,7 @@ test "zero sized struct in tuple handled correctly" {...@@ -323,7 +323,7 @@ test "zero sized struct in tuple handled correctly" {
323 data: @Type(.{323 data: @Type(.{
324 .Struct = .{324 .Struct = .{
325 .is_tuple = true,325 .is_tuple = true,
326 .layout = .Auto,326 .layout = .auto,
327 .decls = &.{},327 .decls = &.{},
328 .fields = &.{.{328 .fields = &.{.{
329 .name = "0",329 .name = "0",
...@@ -471,7 +471,7 @@ test "coerce anon tuple to tuple" {...@@ -471,7 +471,7 @@ test "coerce anon tuple to tuple" {
471471
472test "empty tuple type" {472test "empty tuple type" {
473 const S = @Type(.{ .Struct = .{473 const S = @Type(.{ .Struct = .{
474 .layout = .Auto,474 .layout = .auto,
475 .fields = &.{},475 .fields = &.{},
476 .decls = &.{},476 .decls = &.{},
477 .is_tuple = true,477 .is_tuple = true,
test/behavior/tuple_declarations.zig+1-1
...@@ -12,7 +12,7 @@ test "tuple declaration type info" {...@@ -12,7 +12,7 @@ test "tuple declaration type info" {
12 const T = struct { comptime u32 align(2) = 1, []const u8 };12 const T = struct { comptime u32 align(2) = 1, []const u8 };
13 const info = @typeInfo(T).Struct;13 const info = @typeInfo(T).Struct;
1414
15 try expect(info.layout == .Auto);15 try expect(info.layout == .auto);
16 try expect(info.backing_integer == null);16 try expect(info.backing_integer == null);
17 try expect(info.fields.len == 2);17 try expect(info.fields.len == 2);
18 try expect(info.decls.len == 0);18 try expect(info.decls.len == 0);
test/behavior/type.zig+19-19
...@@ -263,7 +263,7 @@ test "Type.Struct" {...@@ -263,7 +263,7 @@ test "Type.Struct" {
263263
264 const A = @Type(@typeInfo(struct { x: u8, y: u32 }));264 const A = @Type(@typeInfo(struct { x: u8, y: u32 }));
265 const infoA = @typeInfo(A).Struct;265 const infoA = @typeInfo(A).Struct;
266 try testing.expectEqual(Type.ContainerLayout.Auto, infoA.layout);266 try testing.expectEqual(Type.ContainerLayout.auto, infoA.layout);
267 try testing.expectEqualSlices(u8, "x", infoA.fields[0].name);267 try testing.expectEqualSlices(u8, "x", infoA.fields[0].name);
268 try testing.expectEqual(u8, infoA.fields[0].type);268 try testing.expectEqual(u8, infoA.fields[0].type);
269 try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[0].default_value);269 try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[0].default_value);
...@@ -281,7 +281,7 @@ test "Type.Struct" {...@@ -281,7 +281,7 @@ test "Type.Struct" {
281281
282 const B = @Type(@typeInfo(extern struct { x: u8, y: u32 = 5 }));282 const B = @Type(@typeInfo(extern struct { x: u8, y: u32 = 5 }));
283 const infoB = @typeInfo(B).Struct;283 const infoB = @typeInfo(B).Struct;
284 try testing.expectEqual(Type.ContainerLayout.Extern, infoB.layout);284 try testing.expectEqual(Type.ContainerLayout.@"extern", infoB.layout);
285 try testing.expectEqualSlices(u8, "x", infoB.fields[0].name);285 try testing.expectEqualSlices(u8, "x", infoB.fields[0].name);
286 try testing.expectEqual(u8, infoB.fields[0].type);286 try testing.expectEqual(u8, infoB.fields[0].type);
287 try testing.expectEqual(@as(?*const anyopaque, null), infoB.fields[0].default_value);287 try testing.expectEqual(@as(?*const anyopaque, null), infoB.fields[0].default_value);
...@@ -293,7 +293,7 @@ test "Type.Struct" {...@@ -293,7 +293,7 @@ test "Type.Struct" {
293293
294 const C = @Type(@typeInfo(packed struct { x: u8 = 3, y: u32 = 5 }));294 const C = @Type(@typeInfo(packed struct { x: u8 = 3, y: u32 = 5 }));
295 const infoC = @typeInfo(C).Struct;295 const infoC = @typeInfo(C).Struct;
296 try testing.expectEqual(Type.ContainerLayout.Packed, infoC.layout);296 try testing.expectEqual(Type.ContainerLayout.@"packed", infoC.layout);
297 try testing.expectEqualSlices(u8, "x", infoC.fields[0].name);297 try testing.expectEqualSlices(u8, "x", infoC.fields[0].name);
298 try testing.expectEqual(u8, infoC.fields[0].type);298 try testing.expectEqual(u8, infoC.fields[0].type);
299 try testing.expectEqual(@as(u8, 3), @as(*const u8, @ptrCast(infoC.fields[0].default_value.?)).*);299 try testing.expectEqual(@as(u8, 3), @as(*const u8, @ptrCast(infoC.fields[0].default_value.?)).*);
...@@ -306,7 +306,7 @@ test "Type.Struct" {...@@ -306,7 +306,7 @@ test "Type.Struct" {
306 // anon structs306 // anon structs
307 const D = @Type(@typeInfo(@TypeOf(.{ .x = 3, .y = 5 })));307 const D = @Type(@typeInfo(@TypeOf(.{ .x = 3, .y = 5 })));
308 const infoD = @typeInfo(D).Struct;308 const infoD = @typeInfo(D).Struct;
309 try testing.expectEqual(Type.ContainerLayout.Auto, infoD.layout);309 try testing.expectEqual(Type.ContainerLayout.auto, infoD.layout);
310 try testing.expectEqualSlices(u8, "x", infoD.fields[0].name);310 try testing.expectEqualSlices(u8, "x", infoD.fields[0].name);
311 try testing.expectEqual(comptime_int, infoD.fields[0].type);311 try testing.expectEqual(comptime_int, infoD.fields[0].type);
312 try testing.expectEqual(@as(comptime_int, 3), @as(*const comptime_int, @ptrCast(infoD.fields[0].default_value.?)).*);312 try testing.expectEqual(@as(comptime_int, 3), @as(*const comptime_int, @ptrCast(infoD.fields[0].default_value.?)).*);
...@@ -319,7 +319,7 @@ test "Type.Struct" {...@@ -319,7 +319,7 @@ test "Type.Struct" {
319 // tuples319 // tuples
320 const E = @Type(@typeInfo(@TypeOf(.{ 1, 2 })));320 const E = @Type(@typeInfo(@TypeOf(.{ 1, 2 })));
321 const infoE = @typeInfo(E).Struct;321 const infoE = @typeInfo(E).Struct;
322 try testing.expectEqual(Type.ContainerLayout.Auto, infoE.layout);322 try testing.expectEqual(Type.ContainerLayout.auto, infoE.layout);
323 try testing.expectEqualSlices(u8, "0", infoE.fields[0].name);323 try testing.expectEqualSlices(u8, "0", infoE.fields[0].name);
324 try testing.expectEqual(comptime_int, infoE.fields[0].type);324 try testing.expectEqual(comptime_int, infoE.fields[0].type);
325 try testing.expectEqual(@as(comptime_int, 1), @as(*const comptime_int, @ptrCast(infoE.fields[0].default_value.?)).*);325 try testing.expectEqual(@as(comptime_int, 1), @as(*const comptime_int, @ptrCast(infoE.fields[0].default_value.?)).*);
...@@ -332,14 +332,14 @@ test "Type.Struct" {...@@ -332,14 +332,14 @@ test "Type.Struct" {
332 // empty struct332 // empty struct
333 const F = @Type(@typeInfo(struct {}));333 const F = @Type(@typeInfo(struct {}));
334 const infoF = @typeInfo(F).Struct;334 const infoF = @typeInfo(F).Struct;
335 try testing.expectEqual(Type.ContainerLayout.Auto, infoF.layout);335 try testing.expectEqual(Type.ContainerLayout.auto, infoF.layout);
336 try testing.expect(infoF.fields.len == 0);336 try testing.expect(infoF.fields.len == 0);
337 try testing.expectEqual(@as(bool, false), infoF.is_tuple);337 try testing.expectEqual(@as(bool, false), infoF.is_tuple);
338338
339 // empty tuple339 // empty tuple
340 const G = @Type(@typeInfo(@TypeOf(.{})));340 const G = @Type(@typeInfo(@TypeOf(.{})));
341 const infoG = @typeInfo(G).Struct;341 const infoG = @typeInfo(G).Struct;
342 try testing.expectEqual(Type.ContainerLayout.Auto, infoG.layout);342 try testing.expectEqual(Type.ContainerLayout.auto, infoG.layout);
343 try testing.expect(infoG.fields.len == 0);343 try testing.expect(infoG.fields.len == 0);
344 try testing.expectEqual(@as(bool, true), infoG.is_tuple);344 try testing.expectEqual(@as(bool, true), infoG.is_tuple);
345}345}
...@@ -386,7 +386,7 @@ test "Type.Union" {...@@ -386,7 +386,7 @@ test "Type.Union" {
386386
387 const Untagged = @Type(.{387 const Untagged = @Type(.{
388 .Union = .{388 .Union = .{
389 .layout = .Extern,389 .layout = .@"extern",
390 .tag_type = null,390 .tag_type = null,
391 .fields = &.{391 .fields = &.{
392 .{ .name = "int", .type = i32, .alignment = @alignOf(f32) },392 .{ .name = "int", .type = i32, .alignment = @alignOf(f32) },
...@@ -402,7 +402,7 @@ test "Type.Union" {...@@ -402,7 +402,7 @@ test "Type.Union" {
402402
403 const PackedUntagged = @Type(.{403 const PackedUntagged = @Type(.{
404 .Union = .{404 .Union = .{
405 .layout = .Packed,405 .layout = .@"packed",
406 .tag_type = null,406 .tag_type = null,
407 .fields = &.{407 .fields = &.{
408 .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) },408 .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) },
...@@ -429,7 +429,7 @@ test "Type.Union" {...@@ -429,7 +429,7 @@ test "Type.Union" {
429 });429 });
430 const Tagged = @Type(.{430 const Tagged = @Type(.{
431 .Union = .{431 .Union = .{
432 .layout = .Auto,432 .layout = .auto,
433 .tag_type = Tag,433 .tag_type = Tag,
434 .fields = &.{434 .fields = &.{
435 .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) },435 .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) },
...@@ -457,7 +457,7 @@ test "Type.Union from Type.Enum" {...@@ -457,7 +457,7 @@ test "Type.Union from Type.Enum" {
457 });457 });
458 const T = @Type(.{458 const T = @Type(.{
459 .Union = .{459 .Union = .{
460 .layout = .Auto,460 .layout = .auto,
461 .tag_type = Tag,461 .tag_type = Tag,
462 .fields = &.{462 .fields = &.{
463 .{ .name = "working_as_expected", .type = u32, .alignment = @alignOf(u32) },463 .{ .name = "working_as_expected", .type = u32, .alignment = @alignOf(u32) },
...@@ -472,7 +472,7 @@ test "Type.Union from regular enum" {...@@ -472,7 +472,7 @@ test "Type.Union from regular enum" {
472 const E = enum { working_as_expected };472 const E = enum { working_as_expected };
473 const T = @Type(.{473 const T = @Type(.{
474 .Union = .{474 .Union = .{
475 .layout = .Auto,475 .layout = .auto,
476 .tag_type = E,476 .tag_type = E,
477 .fields = &.{477 .fields = &.{
478 .{ .name = "working_as_expected", .type = u32, .alignment = @alignOf(u32) },478 .{ .name = "working_as_expected", .type = u32, .alignment = @alignOf(u32) },
...@@ -487,7 +487,7 @@ test "Type.Union from empty regular enum" {...@@ -487,7 +487,7 @@ test "Type.Union from empty regular enum" {
487 const E = enum {};487 const E = enum {};
488 const U = @Type(.{488 const U = @Type(.{
489 .Union = .{489 .Union = .{
490 .layout = .Auto,490 .layout = .auto,
491 .tag_type = E,491 .tag_type = E,
492 .fields = &.{},492 .fields = &.{},
493 .decls = &.{},493 .decls = &.{},
...@@ -507,7 +507,7 @@ test "Type.Union from empty Type.Enum" {...@@ -507,7 +507,7 @@ test "Type.Union from empty Type.Enum" {
507 });507 });
508 const U = @Type(.{508 const U = @Type(.{
509 .Union = .{509 .Union = .{
510 .layout = .Auto,510 .layout = .auto,
511 .tag_type = E,511 .tag_type = E,
512 .fields = &.{},512 .fields = &.{},
513 .decls = &.{},513 .decls = &.{},
...@@ -553,7 +553,7 @@ test "reified struct field name from optional payload" {...@@ -553,7 +553,7 @@ test "reified struct field name from optional payload" {
553 const m_name: ?[1:0]u8 = "a".*;553 const m_name: ?[1:0]u8 = "a".*;
554 if (m_name) |*name| {554 if (m_name) |*name| {
555 const T = @Type(.{ .Struct = .{555 const T = @Type(.{ .Struct = .{
556 .layout = .Auto,556 .layout = .auto,
557 .fields = &.{.{557 .fields = &.{.{
558 .name = name,558 .name = name,
559 .type = u8,559 .type = u8,
...@@ -575,7 +575,7 @@ test "reified union uses @alignOf" {...@@ -575,7 +575,7 @@ test "reified union uses @alignOf" {
575 fn CreateUnion(comptime T: type) type {575 fn CreateUnion(comptime T: type) type {
576 return @Type(.{576 return @Type(.{
577 .Union = .{577 .Union = .{
578 .layout = .Auto,578 .layout = .auto,
579 .tag_type = null,579 .tag_type = null,
580 .fields = &[_]std.builtin.Type.UnionField{580 .fields = &[_]std.builtin.Type.UnionField{
581 .{581 .{
...@@ -597,7 +597,7 @@ test "reified struct uses @alignOf" {...@@ -597,7 +597,7 @@ test "reified struct uses @alignOf" {
597 fn NamespacedGlobals(comptime modules: anytype) type {597 fn NamespacedGlobals(comptime modules: anytype) type {
598 return @Type(.{598 return @Type(.{
599 .Struct = .{599 .Struct = .{
600 .layout = .Auto,600 .layout = .auto,
601 .is_tuple = false,601 .is_tuple = false,
602 .fields = &.{602 .fields = &.{
603 .{603 .{
...@@ -659,7 +659,7 @@ test "empty struct assigned to reified struct field" {...@@ -659,7 +659,7 @@ test "empty struct assigned to reified struct field" {
659 fn NamespacedComponents(comptime modules: anytype) type {659 fn NamespacedComponents(comptime modules: anytype) type {
660 return @Type(.{660 return @Type(.{
661 .Struct = .{661 .Struct = .{
662 .layout = .Auto,662 .layout = .auto,
663 .is_tuple = false,663 .is_tuple = false,
664 .fields = &.{.{664 .fields = &.{.{
665 .name = "components",665 .name = "components",
...@@ -721,7 +721,7 @@ test "struct field names sliced at comptime from larger string" {...@@ -721,7 +721,7 @@ test "struct field names sliced at comptime from larger string" {
721721
722 const T = @Type(.{722 const T = @Type(.{
723 .Struct = .{723 .Struct = .{
724 .layout = .Auto,724 .layout = .auto,
725 .is_tuple = false,725 .is_tuple = false,
726 .fields = fields,726 .fields = fields,
727 .decls = &.{},727 .decls = &.{},
test/behavior/type_info.zig+4-4
...@@ -250,7 +250,7 @@ test "type info: union info" {...@@ -250,7 +250,7 @@ test "type info: union info" {
250fn testUnion() !void {250fn testUnion() !void {
251 const typeinfo_info = @typeInfo(Type);251 const typeinfo_info = @typeInfo(Type);
252 try expect(typeinfo_info == .Union);252 try expect(typeinfo_info == .Union);
253 try expect(typeinfo_info.Union.layout == .Auto);253 try expect(typeinfo_info.Union.layout == .auto);
254 try expect(typeinfo_info.Union.tag_type.? == TypeId);254 try expect(typeinfo_info.Union.tag_type.? == TypeId);
255 try expect(typeinfo_info.Union.fields.len == 24);255 try expect(typeinfo_info.Union.fields.len == 24);
256 try expect(typeinfo_info.Union.fields[4].type == @TypeOf(@typeInfo(u8).Int));256 try expect(typeinfo_info.Union.fields[4].type == @TypeOf(@typeInfo(u8).Int));
...@@ -264,7 +264,7 @@ fn testUnion() !void {...@@ -264,7 +264,7 @@ fn testUnion() !void {
264 const notag_union_info = @typeInfo(TestNoTagUnion);264 const notag_union_info = @typeInfo(TestNoTagUnion);
265 try expect(notag_union_info == .Union);265 try expect(notag_union_info == .Union);
266 try expect(notag_union_info.Union.tag_type == null);266 try expect(notag_union_info.Union.tag_type == null);
267 try expect(notag_union_info.Union.layout == .Auto);267 try expect(notag_union_info.Union.layout == .auto);
268 try expect(notag_union_info.Union.fields.len == 2);268 try expect(notag_union_info.Union.fields.len == 2);
269 try expect(notag_union_info.Union.fields[0].alignment == @alignOf(void));269 try expect(notag_union_info.Union.fields[0].alignment == @alignOf(void));
270 try expect(notag_union_info.Union.fields[1].type == u32);270 try expect(notag_union_info.Union.fields[1].type == u32);
...@@ -275,7 +275,7 @@ fn testUnion() !void {...@@ -275,7 +275,7 @@ fn testUnion() !void {
275 };275 };
276276
277 const extern_union_info = @typeInfo(TestExternUnion);277 const extern_union_info = @typeInfo(TestExternUnion);
278 try expect(extern_union_info.Union.layout == .Extern);278 try expect(extern_union_info.Union.layout == .@"extern");
279 try expect(extern_union_info.Union.tag_type == null);279 try expect(extern_union_info.Union.tag_type == null);
280 try expect(extern_union_info.Union.fields[0].type == *anyopaque);280 try expect(extern_union_info.Union.fields[0].type == *anyopaque);
281}281}
...@@ -310,7 +310,7 @@ fn testPackedStruct() !void {...@@ -310,7 +310,7 @@ fn testPackedStruct() !void {
310 const struct_info = @typeInfo(TestPackedStruct);310 const struct_info = @typeInfo(TestPackedStruct);
311 try expect(struct_info == .Struct);311 try expect(struct_info == .Struct);
312 try expect(struct_info.Struct.is_tuple == false);312 try expect(struct_info.Struct.is_tuple == false);
313 try expect(struct_info.Struct.layout == .Packed);313 try expect(struct_info.Struct.layout == .@"packed");
314 try expect(struct_info.Struct.backing_integer == u128);314 try expect(struct_info.Struct.backing_integer == u128);
315 try expect(struct_info.Struct.fields.len == 4);315 try expect(struct_info.Struct.fields.len == 4);
316 try expect(struct_info.Struct.fields[0].alignment == 0);316 try expect(struct_info.Struct.fields[0].alignment == 0);
test/cases/compile_errors/packed_struct_field_alignment_unavailable_for_reify_type.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1export fn entry() void {1export fn entry() void {
2 _ = @Type(.{ .Struct = .{ .layout = .Packed, .fields = &.{2 _ = @Type(.{ .Struct = .{ .layout = .@"packed", .fields = &.{
3 .{ .name = "one", .type = u4, .default_value = null, .is_comptime = false, .alignment = 2 },3 .{ .name = "one", .type = u4, .default_value = null, .is_comptime = false, .alignment = 2 },
4 }, .decls = &.{}, .is_tuple = false } });4 }, .decls = &.{}, .is_tuple = false } });
5}5}
test/cases/compile_errors/reify_struct.zig+5-5
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1comptime {1comptime {
2 @Type(.{ .Struct = .{2 @Type(.{ .Struct = .{
3 .layout = .Auto,3 .layout = .auto,
4 .fields = &.{.{4 .fields = &.{.{
5 .name = "foo",5 .name = "foo",
6 .type = u32,6 .type = u32,
...@@ -14,7 +14,7 @@ comptime {...@@ -14,7 +14,7 @@ comptime {
14}14}
15comptime {15comptime {
16 @Type(.{ .Struct = .{16 @Type(.{ .Struct = .{
17 .layout = .Auto,17 .layout = .auto,
18 .fields = &.{.{18 .fields = &.{.{
19 .name = "3",19 .name = "3",
20 .type = u32,20 .type = u32,
...@@ -28,7 +28,7 @@ comptime {...@@ -28,7 +28,7 @@ comptime {
28}28}
29comptime {29comptime {
30 @Type(.{ .Struct = .{30 @Type(.{ .Struct = .{
31 .layout = .Auto,31 .layout = .auto,
32 .fields = &.{.{32 .fields = &.{.{
33 .name = "0",33 .name = "0",
34 .type = u32,34 .type = u32,
...@@ -42,7 +42,7 @@ comptime {...@@ -42,7 +42,7 @@ comptime {
42}42}
43comptime {43comptime {
44 @Type(.{ .Struct = .{44 @Type(.{ .Struct = .{
45 .layout = .Extern,45 .layout = .@"extern",
46 .fields = &.{.{46 .fields = &.{.{
47 .name = "0",47 .name = "0",
48 .type = u32,48 .type = u32,
...@@ -56,7 +56,7 @@ comptime {...@@ -56,7 +56,7 @@ comptime {
56}56}
57comptime {57comptime {
58 @Type(.{ .Struct = .{58 @Type(.{ .Struct = .{
59 .layout = .Packed,59 .layout = .@"packed",
60 .fields = &.{.{60 .fields = &.{.{
61 .name = "0",61 .name = "0",
62 .type = u32,62 .type = u32,
test/cases/compile_errors/reify_type_for_tagged_union_with_extra_enum_field.zig+1-1
...@@ -12,7 +12,7 @@ const Tag = @Type(.{...@@ -12,7 +12,7 @@ const Tag = @Type(.{
12});12});
13const Tagged = @Type(.{13const Tagged = @Type(.{
14 .Union = .{14 .Union = .{
15 .layout = .Auto,15 .layout = .auto,
16 .tag_type = Tag,16 .tag_type = Tag,
17 .fields = &.{17 .fields = &.{
18 .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) },18 .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) },
test/cases/compile_errors/reify_type_for_tagged_union_with_extra_union_field.zig+1-1
...@@ -11,7 +11,7 @@ const Tag = @Type(.{...@@ -11,7 +11,7 @@ const Tag = @Type(.{
11});11});
12const Tagged = @Type(.{12const Tagged = @Type(.{
13 .Union = .{13 .Union = .{
14 .layout = .Auto,14 .layout = .auto,
15 .tag_type = Tag,15 .tag_type = Tag,
16 .fields = &.{16 .fields = &.{
17 .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) },17 .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) },
test/cases/compile_errors/reify_type_for_tagged_union_with_no_enum_fields.zig+1-1
...@@ -8,7 +8,7 @@ const Tag = @Type(.{...@@ -8,7 +8,7 @@ const Tag = @Type(.{
8});8});
9const Tagged = @Type(.{9const Tagged = @Type(.{
10 .Union = .{10 .Union = .{
11 .layout = .Auto,11 .layout = .auto,
12 .tag_type = Tag,12 .tag_type = Tag,
13 .fields = &.{13 .fields = &.{
14 .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) },14 .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) },
test/cases/compile_errors/reify_type_for_tagged_union_with_no_union_fields.zig+1-1
...@@ -11,7 +11,7 @@ const Tag = @Type(.{...@@ -11,7 +11,7 @@ const Tag = @Type(.{
11});11});
12const Tagged = @Type(.{12const Tagged = @Type(.{
13 .Union = .{13 .Union = .{
14 .layout = .Auto,14 .layout = .auto,
15 .tag_type = Tag,15 .tag_type = Tag,
16 .fields = &.{},16 .fields = &.{},
17 .decls = &.{},17 .decls = &.{},
test/cases/compile_errors/reify_type_for_union_with_opaque_field.zig+1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const Untagged = @Type(.{1const Untagged = @Type(.{
2 .Union = .{2 .Union = .{
3 .layout = .Auto,3 .layout = .auto,
4 .tag_type = null,4 .tag_type = null,
5 .fields = &.{5 .fields = &.{
6 .{ .name = "foo", .type = opaque {}, .alignment = 1 },6 .{ .name = "foo", .type = opaque {}, .alignment = 1 },
test/cases/compile_errors/reify_type_with_invalid_field_alignment.zig+2-2
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1comptime {1comptime {
2 _ = @Type(.{2 _ = @Type(.{
3 .Union = .{3 .Union = .{
4 .layout = .Auto,4 .layout = .auto,
5 .tag_type = null,5 .tag_type = null,
6 .fields = &.{6 .fields = &.{
7 .{ .name = "foo", .type = usize, .alignment = 3 },7 .{ .name = "foo", .type = usize, .alignment = 3 },
...@@ -13,7 +13,7 @@ comptime {...@@ -13,7 +13,7 @@ comptime {
13comptime {13comptime {
14 _ = @Type(.{14 _ = @Type(.{
15 .Struct = .{15 .Struct = .{
16 .layout = .Auto,16 .layout = .auto,
17 .fields = &.{.{17 .fields = &.{.{
18 .name = "0",18 .name = "0",
19 .type = u32,19 .type = u32,
test/cases/compile_errors/reify_type_with_undefined.zig+2-2
...@@ -7,7 +7,7 @@ comptime {...@@ -7,7 +7,7 @@ comptime {
7 .fields = undefined,7 .fields = undefined,
8 .decls = undefined,8 .decls = undefined,
9 .is_tuple = false,9 .is_tuple = false,
10 .layout = .Auto,10 .layout = .auto,
11 },11 },
12 });12 });
13}13}
...@@ -16,7 +16,7 @@ comptime {...@@ -16,7 +16,7 @@ comptime {
16 const fields: [1]std.builtin.Type.StructField = undefined;16 const fields: [1]std.builtin.Type.StructField = undefined;
17 _ = @Type(.{17 _ = @Type(.{
18 .Struct = .{18 .Struct = .{
19 .layout = .Auto,19 .layout = .auto,
20 .fields = &fields,20 .fields = &fields,
21 .decls = &.{},21 .decls = &.{},
22 .is_tuple = false,22 .is_tuple = false,