authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-03-19 12:46:38+01:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-03-30 20:50:48-04:00
logeb723a407073592db858cf14bece8643bec2a771
tree504be71818a397d2b8ce07aa26718b5c7a5b7ef5
parent17673dcd6e3ffeb25fc9dc1cfc72334ab4e71b37

Update uses of `@fieldParentPtr` to use RLS


49 files changed, 494 insertions(+), 539 deletions(-)

doc/langref.html.in+2-3
...@@ -3107,7 +3107,7 @@ test "struct namespaced variable" {...@@ -3107,7 +3107,7 @@ test "struct namespaced variable" {
3107// struct field order is determined by the compiler for optimal performance.3107// struct field order is determined by the compiler for optimal performance.
3108// however, you can still calculate a struct base pointer given a field pointer:3108// however, you can still calculate a struct base pointer given a field pointer:
3109fn setYBasedOnX(x: *f32, y: f32) void {3109fn setYBasedOnX(x: *f32, y: f32) void {
3110 const point = @fieldParentPtr(Point, "x", x);3110 const point: *Point = @fieldParentPtr("x", x);
3111 point.y = y;3111 point.y = y;
3112}3112}
3113test "field parent pointer" {3113test "field parent pointer" {
...@@ -8757,8 +8757,7 @@ test "decl access by string" {...@@ -8757,8 +8757,7 @@ test "decl access by string" {
8757 {#header_close#}8757 {#header_close#}
87588758
8759 {#header_open|@fieldParentPtr#}8759 {#header_open|@fieldParentPtr#}
8760 <pre>{#syntax#}@fieldParentPtr(comptime ParentType: type, comptime field_name: []const u8,8760 <pre>{#syntax#}@fieldParentPtr(comptime field_name: []const u8, field_ptr: *T) anytype{#endsyntax#}</pre>
8761 field_ptr: *T) *ParentType{#endsyntax#}</pre>
8762 <p>8761 <p>
8763 Given a pointer to a field, returns the base pointer of a struct.8762 Given a pointer to a field, returns the base pointer of a struct.
8764 </p>8763 </p>
lib/compiler/aro/aro/pragmas/gcc.zig+6-6
...@@ -37,18 +37,18 @@ const Directive = enum {...@@ -37,18 +37,18 @@ const Directive = enum {
37};37};
3838
39fn beforePreprocess(pragma: *Pragma, comp: *Compilation) void {39fn beforePreprocess(pragma: *Pragma, comp: *Compilation) void {
40 var self = @fieldParentPtr(*GCC, "pragma", pragma);40 var self: *GCC = @fieldParentPtr("pragma", pragma);
41 self.original_options = comp.diagnostics.options;41 self.original_options = comp.diagnostics.options;
42}42}
4343
44fn beforeParse(pragma: *Pragma, comp: *Compilation) void {44fn beforeParse(pragma: *Pragma, comp: *Compilation) void {
45 var self = @fieldParentPtr(*GCC, "pragma", pragma);45 var self: *GCC = @fieldParentPtr("pragma", pragma);
46 comp.diagnostics.options = self.original_options;46 comp.diagnostics.options = self.original_options;
47 self.options_stack.items.len = 0;47 self.options_stack.items.len = 0;
48}48}
4949
50fn afterParse(pragma: *Pragma, comp: *Compilation) void {50fn afterParse(pragma: *Pragma, comp: *Compilation) void {
51 var self = @fieldParentPtr(*GCC, "pragma", pragma);51 var self: *GCC = @fieldParentPtr("pragma", pragma);
52 comp.diagnostics.options = self.original_options;52 comp.diagnostics.options = self.original_options;
53 self.options_stack.items.len = 0;53 self.options_stack.items.len = 0;
54}54}
...@@ -60,7 +60,7 @@ pub fn init(allocator: mem.Allocator) !*Pragma {...@@ -60,7 +60,7 @@ pub fn init(allocator: mem.Allocator) !*Pragma {
60}60}
6161
62fn deinit(pragma: *Pragma, comp: *Compilation) void {62fn deinit(pragma: *Pragma, comp: *Compilation) void {
63 var self = @fieldParentPtr(*GCC, "pragma", pragma);63 var self: *GCC = @fieldParentPtr("pragma", pragma);
64 self.options_stack.deinit(comp.gpa);64 self.options_stack.deinit(comp.gpa);
65 comp.gpa.destroy(self);65 comp.gpa.destroy(self);
66}66}
...@@ -108,7 +108,7 @@ fn diagnosticHandler(self: *GCC, pp: *Preprocessor, start_idx: TokenIndex) Pragm...@@ -108,7 +108,7 @@ fn diagnosticHandler(self: *GCC, pp: *Preprocessor, start_idx: TokenIndex) Pragm
108}108}
109109
110fn preprocessorHandler(pragma: *Pragma, pp: *Preprocessor, start_idx: TokenIndex) Pragma.Error!void {110fn preprocessorHandler(pragma: *Pragma, pp: *Preprocessor, start_idx: TokenIndex) Pragma.Error!void {
111 var self = @fieldParentPtr(*GCC, "pragma", pragma);111 var self: *GCC = @fieldParentPtr("pragma", pragma);
112 const directive_tok = pp.tokens.get(start_idx + 1);112 const directive_tok = pp.tokens.get(start_idx + 1);
113 if (directive_tok.id == .nl) return;113 if (directive_tok.id == .nl) return;
114114
...@@ -174,7 +174,7 @@ fn preprocessorHandler(pragma: *Pragma, pp: *Preprocessor, start_idx: TokenIndex...@@ -174,7 +174,7 @@ fn preprocessorHandler(pragma: *Pragma, pp: *Preprocessor, start_idx: TokenIndex
174}174}
175175
176fn parserHandler(pragma: *Pragma, p: *Parser, start_idx: TokenIndex) Compilation.Error!void {176fn parserHandler(pragma: *Pragma, p: *Parser, start_idx: TokenIndex) Compilation.Error!void {
177 var self = @fieldParentPtr(*GCC, "pragma", pragma);177 var self: *GCC = @fieldParentPtr("pragma", pragma);
178 const directive_tok = p.pp.tokens.get(start_idx + 1);178 const directive_tok = p.pp.tokens.get(start_idx + 1);
179 if (directive_tok.id == .nl) return;179 if (directive_tok.id == .nl) return;
180 const name = p.pp.expandedSlice(directive_tok);180 const name = p.pp.expandedSlice(directive_tok);
lib/compiler/aro/aro/pragmas/message.zig+1-1
...@@ -22,7 +22,7 @@ pub fn init(allocator: mem.Allocator) !*Pragma {...@@ -22,7 +22,7 @@ pub fn init(allocator: mem.Allocator) !*Pragma {
22}22}
2323
24fn deinit(pragma: *Pragma, comp: *Compilation) void {24fn deinit(pragma: *Pragma, comp: *Compilation) void {
25 const self = @fieldParentPtr(*Message, "pragma", pragma);25 const self: *Message = @fieldParentPtr("pragma", pragma);
26 comp.gpa.destroy(self);26 comp.gpa.destroy(self);
27}27}
2828
lib/compiler/aro/aro/pragmas/once.zig+3-3
...@@ -27,18 +27,18 @@ pub fn init(allocator: mem.Allocator) !*Pragma {...@@ -27,18 +27,18 @@ pub fn init(allocator: mem.Allocator) !*Pragma {
27}27}
2828
29fn afterParse(pragma: *Pragma, _: *Compilation) void {29fn afterParse(pragma: *Pragma, _: *Compilation) void {
30 var self = @fieldParentPtr(*Once, "pragma", pragma);30 var self: *Once = @fieldParentPtr("pragma", pragma);
31 self.pragma_once.clearRetainingCapacity();31 self.pragma_once.clearRetainingCapacity();
32}32}
3333
34fn deinit(pragma: *Pragma, comp: *Compilation) void {34fn deinit(pragma: *Pragma, comp: *Compilation) void {
35 var self = @fieldParentPtr(*Once, "pragma", pragma);35 var self: *Once = @fieldParentPtr("pragma", pragma);
36 self.pragma_once.deinit();36 self.pragma_once.deinit();
37 comp.gpa.destroy(self);37 comp.gpa.destroy(self);
38}38}
3939
40fn preprocessorHandler(pragma: *Pragma, pp: *Preprocessor, start_idx: TokenIndex) Pragma.Error!void {40fn preprocessorHandler(pragma: *Pragma, pp: *Preprocessor, start_idx: TokenIndex) Pragma.Error!void {
41 var self = @fieldParentPtr(*Once, "pragma", pragma);41 var self: *Once = @fieldParentPtr("pragma", pragma);
42 const name_tok = pp.tokens.get(start_idx);42 const name_tok = pp.tokens.get(start_idx);
43 const next = pp.tokens.get(start_idx + 1);43 const next = pp.tokens.get(start_idx + 1);
44 if (next.id != .nl) {44 if (next.id != .nl) {
lib/compiler/aro/aro/pragmas/pack.zig+2-2
...@@ -24,13 +24,13 @@ pub fn init(allocator: mem.Allocator) !*Pragma {...@@ -24,13 +24,13 @@ pub fn init(allocator: mem.Allocator) !*Pragma {
24}24}
2525
26fn deinit(pragma: *Pragma, comp: *Compilation) void {26fn deinit(pragma: *Pragma, comp: *Compilation) void {
27 var self = @fieldParentPtr(*Pack, "pragma", pragma);27 var self: *Pack = @fieldParentPtr("pragma", pragma);
28 self.stack.deinit(comp.gpa);28 self.stack.deinit(comp.gpa);
29 comp.gpa.destroy(self);29 comp.gpa.destroy(self);
30}30}
3131
32fn parserHandler(pragma: *Pragma, p: *Parser, start_idx: TokenIndex) Compilation.Error!void {32fn parserHandler(pragma: *Pragma, p: *Parser, start_idx: TokenIndex) Compilation.Error!void {
33 var pack = @fieldParentPtr(*Pack, "pragma", pragma);33 var pack: *Pack = @fieldParentPtr("pragma", pragma);
34 var idx = start_idx + 1;34 var idx = start_idx + 1;
35 const l_paren = p.pp.tokens.get(idx);35 const l_paren = p.pp.tokens.get(idx);
36 if (l_paren.id != .l_paren) {36 if (l_paren.id != .l_paren) {
lib/compiler/aro/backend/Object.zig+5-5
...@@ -16,7 +16,7 @@ pub fn create(gpa: Allocator, target: std.Target) !*Object {...@@ -16,7 +16,7 @@ pub fn create(gpa: Allocator, target: std.Target) !*Object {
1616
17pub fn deinit(obj: *Object) void {17pub fn deinit(obj: *Object) void {
18 switch (obj.format) {18 switch (obj.format) {
19 .elf => @fieldParentPtr(Elf, "obj", obj).deinit(),19 .elf => @as(*Elf, @fieldParentPtr("obj", obj)).deinit(),
20 else => unreachable,20 else => unreachable,
21 }21 }
22}22}
...@@ -32,7 +32,7 @@ pub const Section = union(enum) {...@@ -32,7 +32,7 @@ pub const Section = union(enum) {
3232
33pub fn getSection(obj: *Object, section: Section) !*std.ArrayList(u8) {33pub fn getSection(obj: *Object, section: Section) !*std.ArrayList(u8) {
34 switch (obj.format) {34 switch (obj.format) {
35 .elf => return @fieldParentPtr(Elf, "obj", obj).getSection(section),35 .elf => return @as(*Elf, @fieldParentPtr("obj", obj)).getSection(section),
36 else => unreachable,36 else => unreachable,
37 }37 }
38}38}
...@@ -53,21 +53,21 @@ pub fn declareSymbol(...@@ -53,21 +53,21 @@ pub fn declareSymbol(
53 size: u64,53 size: u64,
54) ![]const u8 {54) ![]const u8 {
55 switch (obj.format) {55 switch (obj.format) {
56 .elf => return @fieldParentPtr(Elf, "obj", obj).declareSymbol(section, name, linkage, @"type", offset, size),56 .elf => return @as(*Elf, @fieldParentPtr("obj", obj)).declareSymbol(section, name, linkage, @"type", offset, size),
57 else => unreachable,57 else => unreachable,
58 }58 }
59}59}
6060
61pub fn addRelocation(obj: *Object, name: []const u8, section: Section, address: u64, addend: i64) !void {61pub fn addRelocation(obj: *Object, name: []const u8, section: Section, address: u64, addend: i64) !void {
62 switch (obj.format) {62 switch (obj.format) {
63 .elf => return @fieldParentPtr(Elf, "obj", obj).addRelocation(name, section, address, addend),63 .elf => return @as(*Elf, @fieldParentPtr("obj", obj)).addRelocation(name, section, address, addend),
64 else => unreachable,64 else => unreachable,
65 }65 }
66}66}
6767
68pub fn finish(obj: *Object, file: std.fs.File) !void {68pub fn finish(obj: *Object, file: std.fs.File) !void {
69 switch (obj.format) {69 switch (obj.format) {
70 .elf => return @fieldParentPtr(Elf, "obj", obj).finish(file),70 .elf => return @as(*Elf, @fieldParentPtr("obj", obj)).finish(file),
71 else => unreachable,71 else => unreachable,
72 }72 }
73}73}
lib/compiler/aro_translate_c.zig+10-10
...@@ -1098,13 +1098,13 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ...@@ -1098,13 +1098,13 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ
1098 }1098 }
1099 };1099 };
11001100
1101 pub fn findBlockScope(inner: *ScopeExtraScope, c: *ScopeExtraContext) !*ScopeExtraScope.Block {1101 pub fn findBlockScope(inner: *ScopeExtraScope, c: *ScopeExtraContext) !*Block {
1102 var scope = inner;1102 var scope = inner;
1103 while (true) {1103 while (true) {
1104 switch (scope.id) {1104 switch (scope.id) {
1105 .root => unreachable,1105 .root => unreachable,
1106 .block => return @fieldParentPtr(*Block, "base", scope),1106 .block => return @fieldParentPtr("base", scope),
1107 .condition => return @fieldParentPtr(*Condition, "base", scope).getBlockScope(c),1107 .condition => return @as(*Condition, @fieldParentPtr("base", scope)).getBlockScope(c),
1108 else => scope = scope.parent.?,1108 else => scope = scope.parent.?,
1109 }1109 }
1110 }1110 }
...@@ -1116,7 +1116,7 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ...@@ -1116,7 +1116,7 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ
1116 switch (scope.id) {1116 switch (scope.id) {
1117 .root => unreachable,1117 .root => unreachable,
1118 .block => {1118 .block => {
1119 const block = @fieldParentPtr(*Block, "base", scope);1119 const block: *Block = @fieldParentPtr("base", scope);
1120 if (block.return_type) |ty| return ty;1120 if (block.return_type) |ty| return ty;
1121 scope = scope.parent.?;1121 scope = scope.parent.?;
1122 },1122 },
...@@ -1128,15 +1128,15 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ...@@ -1128,15 +1128,15 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ
1128 pub fn getAlias(scope: *ScopeExtraScope, name: []const u8) []const u8 {1128 pub fn getAlias(scope: *ScopeExtraScope, name: []const u8) []const u8 {
1129 return switch (scope.id) {1129 return switch (scope.id) {
1130 .root => return name,1130 .root => return name,
1131 .block => @fieldParentPtr(*Block, "base", scope).getAlias(name),1131 .block => @as(*Block, @fieldParentPtr("base", scope)).getAlias(name),
1132 .loop, .do_loop, .condition => scope.parent.?.getAlias(name),1132 .loop, .do_loop, .condition => scope.parent.?.getAlias(name),
1133 };1133 };
1134 }1134 }
11351135
1136 pub fn contains(scope: *ScopeExtraScope, name: []const u8) bool {1136 pub fn contains(scope: *ScopeExtraScope, name: []const u8) bool {
1137 return switch (scope.id) {1137 return switch (scope.id) {
1138 .root => @fieldParentPtr(*Root, "base", scope).contains(name),1138 .root => @as(*Root, @fieldParentPtr("base", scope)).contains(name),
1139 .block => @fieldParentPtr(*Block, "base", scope).contains(name),1139 .block => @as(*Block, @fieldParentPtr("base", scope)).contains(name),
1140 .loop, .do_loop, .condition => scope.parent.?.contains(name),1140 .loop, .do_loop, .condition => scope.parent.?.contains(name),
1141 };1141 };
1142 }1142 }
...@@ -1158,11 +1158,11 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ...@@ -1158,11 +1158,11 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ
1158 while (true) {1158 while (true) {
1159 switch (scope.id) {1159 switch (scope.id) {
1160 .root => {1160 .root => {
1161 const root = @fieldParentPtr(*Root, "base", scope);1161 const root: *Root = @fieldParentPtr("base", scope);
1162 return root.nodes.append(node);1162 return root.nodes.append(node);
1163 },1163 },
1164 .block => {1164 .block => {
1165 const block = @fieldParentPtr(*Block, "base", scope);1165 const block: *Block = @fieldParentPtr("base", scope);
1166 return block.statements.append(node);1166 return block.statements.append(node);
1167 },1167 },
1168 else => scope = scope.parent.?,1168 else => scope = scope.parent.?,
...@@ -1184,7 +1184,7 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ...@@ -1184,7 +1184,7 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ
1184 switch (scope.id) {1184 switch (scope.id) {
1185 .root => return,1185 .root => return,
1186 .block => {1186 .block => {
1187 const block = @fieldParentPtr(*Block, "base", scope);1187 const block: *Block = @fieldParentPtr("base", scope);
1188 if (block.variable_discards.get(name)) |discard| {1188 if (block.variable_discards.get(name)) |discard| {
1189 discard.data.should_skip = true;1189 discard.data.should_skip = true;
1190 return;1190 return;
lib/compiler/aro_translate_c/ast.zig+8-8
...@@ -409,7 +409,7 @@ pub const Node = extern union {...@@ -409,7 +409,7 @@ pub const Node = extern union {
409 return null;409 return null;
410410
411 if (self.ptr_otherwise.tag == t)411 if (self.ptr_otherwise.tag == t)
412 return @alignCast(@fieldParentPtr(*align(1) t.Type(), "base", self.ptr_otherwise));412 return @alignCast(@fieldParentPtr("base", self.ptr_otherwise));
413413
414 return null;414 return null;
415 }415 }
...@@ -1220,7 +1220,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {...@@ -1220,7 +1220,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
1220 });1220 });
1221 },1221 },
1222 .pub_var_simple, .var_simple => {1222 .pub_var_simple, .var_simple => {
1223 const payload = @as(*Payload.SimpleVarDecl, @alignCast(@fieldParentPtr(*align(1) Payload.SimpleVarDecl, "base", node.ptr_otherwise))).data;1223 const payload = @as(*Payload.SimpleVarDecl, @alignCast(@fieldParentPtr("base", node.ptr_otherwise))).data;
1224 if (node.tag() == .pub_var_simple) _ = try c.addToken(.keyword_pub, "pub");1224 if (node.tag() == .pub_var_simple) _ = try c.addToken(.keyword_pub, "pub");
1225 const const_tok = try c.addToken(.keyword_const, "const");1225 const const_tok = try c.addToken(.keyword_const, "const");
1226 _ = try c.addIdentifier(payload.name);1226 _ = try c.addIdentifier(payload.name);
...@@ -1293,7 +1293,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {...@@ -1293,7 +1293,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
1293 },1293 },
1294 .var_decl => return renderVar(c, node),1294 .var_decl => return renderVar(c, node),
1295 .arg_redecl, .alias => {1295 .arg_redecl, .alias => {
1296 const payload = @as(*Payload.ArgRedecl, @alignCast(@fieldParentPtr(*align(1) Payload.ArgRedecl, "base", node.ptr_otherwise))).data;1296 const payload = @as(*Payload.ArgRedecl, @alignCast(@fieldParentPtr("base", node.ptr_otherwise))).data;
1297 if (node.tag() == .alias) _ = try c.addToken(.keyword_pub, "pub");1297 if (node.tag() == .alias) _ = try c.addToken(.keyword_pub, "pub");
1298 const mut_tok = if (node.tag() == .alias)1298 const mut_tok = if (node.tag() == .alias)
1299 try c.addToken(.keyword_const, "const")1299 try c.addToken(.keyword_const, "const")
...@@ -1492,7 +1492,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {...@@ -1492,7 +1492,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
1492 });1492 });
1493 },1493 },
1494 .c_pointer, .single_pointer => {1494 .c_pointer, .single_pointer => {
1495 const payload = @as(*Payload.Pointer, @alignCast(@fieldParentPtr(*align(1) Payload.Pointer, "base", node.ptr_otherwise))).data;1495 const payload = @as(*Payload.Pointer, @alignCast(@fieldParentPtr("base", node.ptr_otherwise))).data;
14961496
1497 const asterisk = if (node.tag() == .single_pointer)1497 const asterisk = if (node.tag() == .single_pointer)
1498 try c.addToken(.asterisk, "*")1498 try c.addToken(.asterisk, "*")
...@@ -2085,7 +2085,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {...@@ -2085,7 +2085,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
2085}2085}
20862086
2087fn renderRecord(c: *Context, node: Node) !NodeIndex {2087fn renderRecord(c: *Context, node: Node) !NodeIndex {
2088 const payload = @as(*Payload.Record, @alignCast(@fieldParentPtr(*align(1) Payload.Record, "base", node.ptr_otherwise))).data;2088 const payload = @as(*Payload.Record, @alignCast(@fieldParentPtr("base", node.ptr_otherwise))).data;
2089 if (payload.layout == .@"packed")2089 if (payload.layout == .@"packed")
2090 _ = try c.addToken(.keyword_packed, "packed")2090 _ = try c.addToken(.keyword_packed, "packed")
2091 else if (payload.layout == .@"extern")2091 else if (payload.layout == .@"extern")
...@@ -2487,7 +2487,7 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex {...@@ -2487,7 +2487,7 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex {
2487}2487}
24882488
2489fn renderPrefixOp(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_tag: TokenTag, bytes: []const u8) !NodeIndex {2489fn renderPrefixOp(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_tag: TokenTag, bytes: []const u8) !NodeIndex {
2490 const payload = @as(*Payload.UnOp, @alignCast(@fieldParentPtr(*align(1) Payload.UnOp, "base", node.ptr_otherwise))).data;2490 const payload = @as(*Payload.UnOp, @alignCast(@fieldParentPtr("base", node.ptr_otherwise))).data;
2491 return c.addNode(.{2491 return c.addNode(.{
2492 .tag = tag,2492 .tag = tag,
2493 .main_token = try c.addToken(tok_tag, bytes),2493 .main_token = try c.addToken(tok_tag, bytes),
...@@ -2499,7 +2499,7 @@ fn renderPrefixOp(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_tag: T...@@ -2499,7 +2499,7 @@ fn renderPrefixOp(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_tag: T
2499}2499}
25002500
2501fn renderBinOpGrouped(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_tag: TokenTag, bytes: []const u8) !NodeIndex {2501fn renderBinOpGrouped(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_tag: TokenTag, bytes: []const u8) !NodeIndex {
2502 const payload = @as(*Payload.BinOp, @alignCast(@fieldParentPtr(*align(1) Payload.BinOp, "base", node.ptr_otherwise))).data;2502 const payload = @as(*Payload.BinOp, @alignCast(@fieldParentPtr("base", node.ptr_otherwise))).data;
2503 const lhs = try renderNodeGrouped(c, payload.lhs);2503 const lhs = try renderNodeGrouped(c, payload.lhs);
2504 return c.addNode(.{2504 return c.addNode(.{
2505 .tag = tag,2505 .tag = tag,
...@@ -2512,7 +2512,7 @@ fn renderBinOpGrouped(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_ta...@@ -2512,7 +2512,7 @@ fn renderBinOpGrouped(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_ta
2512}2512}
25132513
2514fn renderBinOp(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_tag: TokenTag, bytes: []const u8) !NodeIndex {2514fn renderBinOp(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_tag: TokenTag, bytes: []const u8) !NodeIndex {
2515 const payload = @as(*Payload.BinOp, @alignCast(@fieldParentPtr(*align(1) Payload.BinOp, "base", node.ptr_otherwise))).data;2515 const payload = @as(*Payload.BinOp, @alignCast(@fieldParentPtr("base", node.ptr_otherwise))).data;
2516 const lhs = try renderNode(c, payload.lhs);2516 const lhs = try renderNode(c, payload.lhs);
2517 return c.addNode(.{2517 return c.addNode(.{
2518 .tag = tag,2518 .tag = tag,
lib/compiler/resinator/ast.zig+85-88
...@@ -19,7 +19,7 @@ pub const Tree = struct {...@@ -19,7 +19,7 @@ pub const Tree = struct {
19 }19 }
2020
21 pub fn root(self: *Tree) *Node.Root {21 pub fn root(self: *Tree) *Node.Root {
22 return @fieldParentPtr(Node.Root, "base", self.node);22 return @alignCast(@fieldParentPtr("base", self.node));
23 }23 }
2424
25 pub fn dump(self: *Tree, writer: anytype) @TypeOf(writer).Error!void {25 pub fn dump(self: *Tree, writer: anytype) @TypeOf(writer).Error!void {
...@@ -174,7 +174,7 @@ pub const Node = struct {...@@ -174,7 +174,7 @@ pub const Node = struct {
174174
175 pub fn cast(base: *Node, comptime id: Id) ?*id.Type() {175 pub fn cast(base: *Node, comptime id: Id) ?*id.Type() {
176 if (base.id == id) {176 if (base.id == id) {
177 return @fieldParentPtr(id.Type(), "base", base);177 return @alignCast(@fieldParentPtr("base", base));
178 }178 }
179 return null;179 return null;
180 }180 }
...@@ -461,7 +461,7 @@ pub const Node = struct {...@@ -461,7 +461,7 @@ pub const Node = struct {
461 pub fn isNumberExpression(node: *const Node) bool {461 pub fn isNumberExpression(node: *const Node) bool {
462 switch (node.id) {462 switch (node.id) {
463 .literal => {463 .literal => {
464 const literal = @fieldParentPtr(Node.Literal, "base", node);464 const literal: *const Node.Literal = @alignCast(@fieldParentPtr("base", node));
465 return switch (literal.token.id) {465 return switch (literal.token.id) {
466 .number => true,466 .number => true,
467 else => false,467 else => false,
...@@ -475,7 +475,7 @@ pub const Node = struct {...@@ -475,7 +475,7 @@ pub const Node = struct {
475 pub fn isStringLiteral(node: *const Node) bool {475 pub fn isStringLiteral(node: *const Node) bool {
476 switch (node.id) {476 switch (node.id) {
477 .literal => {477 .literal => {
478 const literal = @fieldParentPtr(Node.Literal, "base", node);478 const literal: *const Node.Literal = @alignCast(@fieldParentPtr("base", node));
479 return switch (literal.token.id) {479 return switch (literal.token.id) {
480 .quoted_ascii_string, .quoted_wide_string => true,480 .quoted_ascii_string, .quoted_wide_string => true,
481 else => false,481 else => false,
...@@ -489,105 +489,103 @@ pub const Node = struct {...@@ -489,105 +489,103 @@ pub const Node = struct {
489 switch (node.id) {489 switch (node.id) {
490 .root => unreachable,490 .root => unreachable,
491 .resource_external => {491 .resource_external => {
492 const casted = @fieldParentPtr(Node.ResourceExternal, "base", node);492 const casted: *const Node.ResourceExternal = @alignCast(@fieldParentPtr("base", node));
493 return casted.id;493 return casted.id;
494 },494 },
495 .resource_raw_data => {495 .resource_raw_data => {
496 const casted = @fieldParentPtr(Node.ResourceRawData, "base", node);496 const casted: *const Node.ResourceRawData = @alignCast(@fieldParentPtr("base", node));
497 return casted.id;497 return casted.id;
498 },498 },
499 .literal => {499 .literal => {
500 const casted = @fieldParentPtr(Node.Literal, "base", node);500 const casted: *const Node.Literal = @alignCast(@fieldParentPtr("base", node));
501 return casted.token;501 return casted.token;
502 },502 },
503 .binary_expression => {503 .binary_expression => {
504 const casted = @fieldParentPtr(Node.BinaryExpression, "base", node);504 const casted: *const Node.BinaryExpression = @alignCast(@fieldParentPtr("base", node));
505 return casted.left.getFirstToken();505 return casted.left.getFirstToken();
506 },506 },
507 .grouped_expression => {507 .grouped_expression => {
508 const casted = @fieldParentPtr(Node.GroupedExpression, "base", node);508 const casted: *const Node.GroupedExpression = @alignCast(@fieldParentPtr("base", node));
509 return casted.open_token;509 return casted.open_token;
510 },510 },
511 .not_expression => {511 .not_expression => {
512 const casted = @fieldParentPtr(Node.NotExpression, "base", node);512 const casted: *const Node.NotExpression = @alignCast(@fieldParentPtr("base", node));
513 return casted.not_token;513 return casted.not_token;
514 },514 },
515 .accelerators => {515 .accelerators => {
516 const casted = @fieldParentPtr(Node.Accelerators, "base", node);516 const casted: *const Node.Accelerators = @alignCast(@fieldParentPtr("base", node));
517 return casted.id;517 return casted.id;
518 },518 },
519 .accelerator => {519 .accelerator => {
520 const casted = @fieldParentPtr(Node.Accelerator, "base", node);520 const casted: *const Node.Accelerator = @alignCast(@fieldParentPtr("base", node));
521 return casted.event.getFirstToken();521 return casted.event.getFirstToken();
522 },522 },
523 .dialog => {523 .dialog => {
524 const casted = @fieldParentPtr(Node.Dialog, "base", node);524 const casted: *const Node.Dialog = @alignCast(@fieldParentPtr("base", node));
525 return casted.id;525 return casted.id;
526 },526 },
527 .control_statement => {527 .control_statement => {
528 const casted = @fieldParentPtr(Node.ControlStatement, "base", node);528 const casted: *const Node.ControlStatement = @alignCast(@fieldParentPtr("base", node));
529 return casted.type;529 return casted.type;
530 },530 },
531 .toolbar => {531 .toolbar => {
532 const casted = @fieldParentPtr(Node.Toolbar, "base", node);532 const casted: *const Node.Toolbar = @alignCast(@fieldParentPtr("base", node));
533 return casted.id;533 return casted.id;
534 },534 },
535 .menu => {535 .menu => {
536 const casted = @fieldParentPtr(Node.Menu, "base", node);536 const casted: *const Node.Menu = @alignCast(@fieldParentPtr("base", node));
537 return casted.id;537 return casted.id;
538 },538 },
539 inline .menu_item, .menu_item_separator, .menu_item_ex => |menu_item_type| {539 inline .menu_item, .menu_item_separator, .menu_item_ex => |menu_item_type| {
540 const node_type = menu_item_type.Type();540 const casted: *const menu_item_type.Type() = @alignCast(@fieldParentPtr("base", node));
541 const casted = @fieldParentPtr(node_type, "base", node);
542 return casted.menuitem;541 return casted.menuitem;
543 },542 },
544 inline .popup, .popup_ex => |popup_type| {543 inline .popup, .popup_ex => |popup_type| {
545 const node_type = popup_type.Type();544 const casted: *const popup_type.Type() = @alignCast(@fieldParentPtr("base", node));
546 const casted = @fieldParentPtr(node_type, "base", node);
547 return casted.popup;545 return casted.popup;
548 },546 },
549 .version_info => {547 .version_info => {
550 const casted = @fieldParentPtr(Node.VersionInfo, "base", node);548 const casted: *const Node.VersionInfo = @alignCast(@fieldParentPtr("base", node));
551 return casted.id;549 return casted.id;
552 },550 },
553 .version_statement => {551 .version_statement => {
554 const casted = @fieldParentPtr(Node.VersionStatement, "base", node);552 const casted: *const Node.VersionStatement = @alignCast(@fieldParentPtr("base", node));
555 return casted.type;553 return casted.type;
556 },554 },
557 .block => {555 .block => {
558 const casted = @fieldParentPtr(Node.Block, "base", node);556 const casted: *const Node.Block = @alignCast(@fieldParentPtr("base", node));
559 return casted.identifier;557 return casted.identifier;
560 },558 },
561 .block_value => {559 .block_value => {
562 const casted = @fieldParentPtr(Node.BlockValue, "base", node);560 const casted: *const Node.BlockValue = @alignCast(@fieldParentPtr("base", node));
563 return casted.identifier;561 return casted.identifier;
564 },562 },
565 .block_value_value => {563 .block_value_value => {
566 const casted = @fieldParentPtr(Node.BlockValueValue, "base", node);564 const casted: *const Node.BlockValueValue = @alignCast(@fieldParentPtr("base", node));
567 return casted.expression.getFirstToken();565 return casted.expression.getFirstToken();
568 },566 },
569 .string_table => {567 .string_table => {
570 const casted = @fieldParentPtr(Node.StringTable, "base", node);568 const casted: *const Node.StringTable = @alignCast(@fieldParentPtr("base", node));
571 return casted.type;569 return casted.type;
572 },570 },
573 .string_table_string => {571 .string_table_string => {
574 const casted = @fieldParentPtr(Node.StringTableString, "base", node);572 const casted: *const Node.StringTableString = @alignCast(@fieldParentPtr("base", node));
575 return casted.id.getFirstToken();573 return casted.id.getFirstToken();
576 },574 },
577 .language_statement => {575 .language_statement => {
578 const casted = @fieldParentPtr(Node.LanguageStatement, "base", node);576 const casted: *const Node.LanguageStatement = @alignCast(@fieldParentPtr("base", node));
579 return casted.language_token;577 return casted.language_token;
580 },578 },
581 .font_statement => {579 .font_statement => {
582 const casted = @fieldParentPtr(Node.FontStatement, "base", node);580 const casted: *const Node.FontStatement = @alignCast(@fieldParentPtr("base", node));
583 return casted.identifier;581 return casted.identifier;
584 },582 },
585 .simple_statement => {583 .simple_statement => {
586 const casted = @fieldParentPtr(Node.SimpleStatement, "base", node);584 const casted: *const Node.SimpleStatement = @alignCast(@fieldParentPtr("base", node));
587 return casted.identifier;585 return casted.identifier;
588 },586 },
589 .invalid => {587 .invalid => {
590 const casted = @fieldParentPtr(Node.Invalid, "base", node);588 const casted: *const Node.Invalid = @alignCast(@fieldParentPtr("base", node));
591 return casted.context[0];589 return casted.context[0];
592 },590 },
593 }591 }
...@@ -597,44 +595,44 @@ pub const Node = struct {...@@ -597,44 +595,44 @@ pub const Node = struct {
597 switch (node.id) {595 switch (node.id) {
598 .root => unreachable,596 .root => unreachable,
599 .resource_external => {597 .resource_external => {
600 const casted = @fieldParentPtr(Node.ResourceExternal, "base", node);598 const casted: *const Node.ResourceExternal = @alignCast(@fieldParentPtr("base", node));
601 return casted.filename.getLastToken();599 return casted.filename.getLastToken();
602 },600 },
603 .resource_raw_data => {601 .resource_raw_data => {
604 const casted = @fieldParentPtr(Node.ResourceRawData, "base", node);602 const casted: *const Node.ResourceRawData = @alignCast(@fieldParentPtr("base", node));
605 return casted.end_token;603 return casted.end_token;
606 },604 },
607 .literal => {605 .literal => {
608 const casted = @fieldParentPtr(Node.Literal, "base", node);606 const casted: *const Node.Literal = @alignCast(@fieldParentPtr("base", node));
609 return casted.token;607 return casted.token;
610 },608 },
611 .binary_expression => {609 .binary_expression => {
612 const casted = @fieldParentPtr(Node.BinaryExpression, "base", node);610 const casted: *const Node.BinaryExpression = @alignCast(@fieldParentPtr("base", node));
613 return casted.right.getLastToken();611 return casted.right.getLastToken();
614 },612 },
615 .grouped_expression => {613 .grouped_expression => {
616 const casted = @fieldParentPtr(Node.GroupedExpression, "base", node);614 const casted: *const Node.GroupedExpression = @alignCast(@fieldParentPtr("base", node));
617 return casted.close_token;615 return casted.close_token;
618 },616 },
619 .not_expression => {617 .not_expression => {
620 const casted = @fieldParentPtr(Node.NotExpression, "base", node);618 const casted: *const Node.NotExpression = @alignCast(@fieldParentPtr("base", node));
621 return casted.number_token;619 return casted.number_token;
622 },620 },
623 .accelerators => {621 .accelerators => {
624 const casted = @fieldParentPtr(Node.Accelerators, "base", node);622 const casted: *const Node.Accelerators = @alignCast(@fieldParentPtr("base", node));
625 return casted.end_token;623 return casted.end_token;
626 },624 },
627 .accelerator => {625 .accelerator => {
628 const casted = @fieldParentPtr(Node.Accelerator, "base", node);626 const casted: *const Node.Accelerator = @alignCast(@fieldParentPtr("base", node));
629 if (casted.type_and_options.len > 0) return casted.type_and_options[casted.type_and_options.len - 1];627 if (casted.type_and_options.len > 0) return casted.type_and_options[casted.type_and_options.len - 1];
630 return casted.idvalue.getLastToken();628 return casted.idvalue.getLastToken();
631 },629 },
632 .dialog => {630 .dialog => {
633 const casted = @fieldParentPtr(Node.Dialog, "base", node);631 const casted: *const Node.Dialog = @alignCast(@fieldParentPtr("base", node));
634 return casted.end_token;632 return casted.end_token;
635 },633 },
636 .control_statement => {634 .control_statement => {
637 const casted = @fieldParentPtr(Node.ControlStatement, "base", node);635 const casted: *const Node.ControlStatement = @alignCast(@fieldParentPtr("base", node));
638 if (casted.extra_data_end) |token| return token;636 if (casted.extra_data_end) |token| return token;
639 if (casted.help_id) |help_id_node| return help_id_node.getLastToken();637 if (casted.help_id) |help_id_node| return help_id_node.getLastToken();
640 if (casted.exstyle) |exstyle_node| return exstyle_node.getLastToken();638 if (casted.exstyle) |exstyle_node| return exstyle_node.getLastToken();
...@@ -647,80 +645,79 @@ pub const Node = struct {...@@ -647,80 +645,79 @@ pub const Node = struct {
647 return casted.height.getLastToken();645 return casted.height.getLastToken();
648 },646 },
649 .toolbar => {647 .toolbar => {
650 const casted = @fieldParentPtr(Node.Toolbar, "base", node);648 const casted: *const Node.Toolbar = @alignCast(@fieldParentPtr("base", node));
651 return casted.end_token;649 return casted.end_token;
652 },650 },
653 .menu => {651 .menu => {
654 const casted = @fieldParentPtr(Node.Menu, "base", node);652 const casted: *const Node.Menu = @alignCast(@fieldParentPtr("base", node));
655 return casted.end_token;653 return casted.end_token;
656 },654 },
657 .menu_item => {655 .menu_item => {
658 const casted = @fieldParentPtr(Node.MenuItem, "base", node);656 const casted: *const Node.MenuItem = @alignCast(@fieldParentPtr("base", node));
659 if (casted.option_list.len > 0) return casted.option_list[casted.option_list.len - 1];657 if (casted.option_list.len > 0) return casted.option_list[casted.option_list.len - 1];
660 return casted.result.getLastToken();658 return casted.result.getLastToken();
661 },659 },
662 .menu_item_separator => {660 .menu_item_separator => {
663 const casted = @fieldParentPtr(Node.MenuItemSeparator, "base", node);661 const casted: *const Node.MenuItemSeparator = @alignCast(@fieldParentPtr("base", node));
664 return casted.separator;662 return casted.separator;
665 },663 },
666 .menu_item_ex => {664 .menu_item_ex => {
667 const casted = @fieldParentPtr(Node.MenuItemEx, "base", node);665 const casted: *const Node.MenuItemEx = @alignCast(@fieldParentPtr("base", node));
668 if (casted.state) |state_node| return state_node.getLastToken();666 if (casted.state) |state_node| return state_node.getLastToken();
669 if (casted.type) |type_node| return type_node.getLastToken();667 if (casted.type) |type_node| return type_node.getLastToken();
670 if (casted.id) |id_node| return id_node.getLastToken();668 if (casted.id) |id_node| return id_node.getLastToken();
671 return casted.text;669 return casted.text;
672 },670 },
673 inline .popup, .popup_ex => |popup_type| {671 inline .popup, .popup_ex => |popup_type| {
674 const node_type = popup_type.Type();672 const casted: *const popup_type.Type() = @alignCast(@fieldParentPtr("base", node));
675 const casted = @fieldParentPtr(node_type, "base", node);
676 return casted.end_token;673 return casted.end_token;
677 },674 },
678 .version_info => {675 .version_info => {
679 const casted = @fieldParentPtr(Node.VersionInfo, "base", node);676 const casted: *const Node.VersionInfo = @alignCast(@fieldParentPtr("base", node));
680 return casted.end_token;677 return casted.end_token;
681 },678 },
682 .version_statement => {679 .version_statement => {
683 const casted = @fieldParentPtr(Node.VersionStatement, "base", node);680 const casted: *const Node.VersionStatement = @alignCast(@fieldParentPtr("base", node));
684 return casted.parts[casted.parts.len - 1].getLastToken();681 return casted.parts[casted.parts.len - 1].getLastToken();
685 },682 },
686 .block => {683 .block => {
687 const casted = @fieldParentPtr(Node.Block, "base", node);684 const casted: *const Node.Block = @alignCast(@fieldParentPtr("base", node));
688 return casted.end_token;685 return casted.end_token;
689 },686 },
690 .block_value => {687 .block_value => {
691 const casted = @fieldParentPtr(Node.BlockValue, "base", node);688 const casted: *const Node.BlockValue = @alignCast(@fieldParentPtr("base", node));
692 if (casted.values.len > 0) return casted.values[casted.values.len - 1].getLastToken();689 if (casted.values.len > 0) return casted.values[casted.values.len - 1].getLastToken();
693 return casted.key;690 return casted.key;
694 },691 },
695 .block_value_value => {692 .block_value_value => {
696 const casted = @fieldParentPtr(Node.BlockValueValue, "base", node);693 const casted: *const Node.BlockValueValue = @alignCast(@fieldParentPtr("base", node));
697 return casted.expression.getLastToken();694 return casted.expression.getLastToken();
698 },695 },
699 .string_table => {696 .string_table => {
700 const casted = @fieldParentPtr(Node.StringTable, "base", node);697 const casted: *const Node.StringTable = @alignCast(@fieldParentPtr("base", node));
701 return casted.end_token;698 return casted.end_token;
702 },699 },
703 .string_table_string => {700 .string_table_string => {
704 const casted = @fieldParentPtr(Node.StringTableString, "base", node);701 const casted: *const Node.StringTableString = @alignCast(@fieldParentPtr("base", node));
705 return casted.string;702 return casted.string;
706 },703 },
707 .language_statement => {704 .language_statement => {
708 const casted = @fieldParentPtr(Node.LanguageStatement, "base", node);705 const casted: *const Node.LanguageStatement = @alignCast(@fieldParentPtr("base", node));
709 return casted.sublanguage_id.getLastToken();706 return casted.sublanguage_id.getLastToken();
710 },707 },
711 .font_statement => {708 .font_statement => {
712 const casted = @fieldParentPtr(Node.FontStatement, "base", node);709 const casted: *const Node.FontStatement = @alignCast(@fieldParentPtr("base", node));
713 if (casted.char_set) |char_set_node| return char_set_node.getLastToken();710 if (casted.char_set) |char_set_node| return char_set_node.getLastToken();
714 if (casted.italic) |italic_node| return italic_node.getLastToken();711 if (casted.italic) |italic_node| return italic_node.getLastToken();
715 if (casted.weight) |weight_node| return weight_node.getLastToken();712 if (casted.weight) |weight_node| return weight_node.getLastToken();
716 return casted.typeface;713 return casted.typeface;
717 },714 },
718 .simple_statement => {715 .simple_statement => {
719 const casted = @fieldParentPtr(Node.SimpleStatement, "base", node);716 const casted: *const Node.SimpleStatement = @alignCast(@fieldParentPtr("base", node));
720 return casted.value.getLastToken();717 return casted.value.getLastToken();
721 },718 },
722 .invalid => {719 .invalid => {
723 const casted = @fieldParentPtr(Node.Invalid, "base", node);720 const casted: *const Node.Invalid = @alignCast(@fieldParentPtr("base", node));
724 return casted.context[casted.context.len - 1];721 return casted.context[casted.context.len - 1];
725 },722 },
726 }723 }
...@@ -737,31 +734,31 @@ pub const Node = struct {...@@ -737,31 +734,31 @@ pub const Node = struct {
737 switch (node.id) {734 switch (node.id) {
738 .root => {735 .root => {
739 try writer.writeAll("\n");736 try writer.writeAll("\n");
740 const root = @fieldParentPtr(Node.Root, "base", node);737 const root: *Node.Root = @alignCast(@fieldParentPtr("base", node));
741 for (root.body) |body_node| {738 for (root.body) |body_node| {
742 try body_node.dump(tree, writer, indent + 1);739 try body_node.dump(tree, writer, indent + 1);
743 }740 }
744 },741 },
745 .resource_external => {742 .resource_external => {
746 const resource = @fieldParentPtr(Node.ResourceExternal, "base", node);743 const resource: *Node.ResourceExternal = @alignCast(@fieldParentPtr("base", node));
747 try writer.print(" {s} {s} [{d} common_resource_attributes]\n", .{ resource.id.slice(tree.source), resource.type.slice(tree.source), resource.common_resource_attributes.len });744 try writer.print(" {s} {s} [{d} common_resource_attributes]\n", .{ resource.id.slice(tree.source), resource.type.slice(tree.source), resource.common_resource_attributes.len });
748 try resource.filename.dump(tree, writer, indent + 1);745 try resource.filename.dump(tree, writer, indent + 1);
749 },746 },
750 .resource_raw_data => {747 .resource_raw_data => {
751 const resource = @fieldParentPtr(Node.ResourceRawData, "base", node);748 const resource: *Node.ResourceRawData = @alignCast(@fieldParentPtr("base", node));
752 try writer.print(" {s} {s} [{d} common_resource_attributes] raw data: {}\n", .{ resource.id.slice(tree.source), resource.type.slice(tree.source), resource.common_resource_attributes.len, resource.raw_data.len });749 try writer.print(" {s} {s} [{d} common_resource_attributes] raw data: {}\n", .{ resource.id.slice(tree.source), resource.type.slice(tree.source), resource.common_resource_attributes.len, resource.raw_data.len });
753 for (resource.raw_data) |data_expression| {750 for (resource.raw_data) |data_expression| {
754 try data_expression.dump(tree, writer, indent + 1);751 try data_expression.dump(tree, writer, indent + 1);
755 }752 }
756 },753 },
757 .literal => {754 .literal => {
758 const literal = @fieldParentPtr(Node.Literal, "base", node);755 const literal: *Node.Literal = @alignCast(@fieldParentPtr("base", node));
759 try writer.writeAll(" ");756 try writer.writeAll(" ");
760 try writer.writeAll(literal.token.slice(tree.source));757 try writer.writeAll(literal.token.slice(tree.source));
761 try writer.writeAll("\n");758 try writer.writeAll("\n");
762 },759 },
763 .binary_expression => {760 .binary_expression => {
764 const binary = @fieldParentPtr(Node.BinaryExpression, "base", node);761 const binary: *Node.BinaryExpression = @alignCast(@fieldParentPtr("base", node));
765 try writer.writeAll(" ");762 try writer.writeAll(" ");
766 try writer.writeAll(binary.operator.slice(tree.source));763 try writer.writeAll(binary.operator.slice(tree.source));
767 try writer.writeAll("\n");764 try writer.writeAll("\n");
...@@ -769,7 +766,7 @@ pub const Node = struct {...@@ -769,7 +766,7 @@ pub const Node = struct {
769 try binary.right.dump(tree, writer, indent + 1);766 try binary.right.dump(tree, writer, indent + 1);
770 },767 },
771 .grouped_expression => {768 .grouped_expression => {
772 const grouped = @fieldParentPtr(Node.GroupedExpression, "base", node);769 const grouped: *Node.GroupedExpression = @alignCast(@fieldParentPtr("base", node));
773 try writer.writeAll("\n");770 try writer.writeAll("\n");
774 try writer.writeByteNTimes(' ', indent);771 try writer.writeByteNTimes(' ', indent);
775 try writer.writeAll(grouped.open_token.slice(tree.source));772 try writer.writeAll(grouped.open_token.slice(tree.source));
...@@ -780,7 +777,7 @@ pub const Node = struct {...@@ -780,7 +777,7 @@ pub const Node = struct {
780 try writer.writeAll("\n");777 try writer.writeAll("\n");
781 },778 },
782 .not_expression => {779 .not_expression => {
783 const not = @fieldParentPtr(Node.NotExpression, "base", node);780 const not: *Node.NotExpression = @alignCast(@fieldParentPtr("base", node));
784 try writer.writeAll(" ");781 try writer.writeAll(" ");
785 try writer.writeAll(not.not_token.slice(tree.source));782 try writer.writeAll(not.not_token.slice(tree.source));
786 try writer.writeAll(" ");783 try writer.writeAll(" ");
...@@ -788,7 +785,7 @@ pub const Node = struct {...@@ -788,7 +785,7 @@ pub const Node = struct {
788 try writer.writeAll("\n");785 try writer.writeAll("\n");
789 },786 },
790 .accelerators => {787 .accelerators => {
791 const accelerators = @fieldParentPtr(Node.Accelerators, "base", node);788 const accelerators: *Node.Accelerators = @alignCast(@fieldParentPtr("base", node));
792 try writer.print(" {s} {s} [{d} common_resource_attributes]\n", .{ accelerators.id.slice(tree.source), accelerators.type.slice(tree.source), accelerators.common_resource_attributes.len });789 try writer.print(" {s} {s} [{d} common_resource_attributes]\n", .{ accelerators.id.slice(tree.source), accelerators.type.slice(tree.source), accelerators.common_resource_attributes.len });
793 for (accelerators.optional_statements) |statement| {790 for (accelerators.optional_statements) |statement| {
794 try statement.dump(tree, writer, indent + 1);791 try statement.dump(tree, writer, indent + 1);
...@@ -804,7 +801,7 @@ pub const Node = struct {...@@ -804,7 +801,7 @@ pub const Node = struct {
804 try writer.writeAll("\n");801 try writer.writeAll("\n");
805 },802 },
806 .accelerator => {803 .accelerator => {
807 const accelerator = @fieldParentPtr(Node.Accelerator, "base", node);804 const accelerator: *Node.Accelerator = @alignCast(@fieldParentPtr("base", node));
808 for (accelerator.type_and_options, 0..) |option, i| {805 for (accelerator.type_and_options, 0..) |option, i| {
809 if (i != 0) try writer.writeAll(",");806 if (i != 0) try writer.writeAll(",");
810 try writer.writeByte(' ');807 try writer.writeByte(' ');
...@@ -815,7 +812,7 @@ pub const Node = struct {...@@ -815,7 +812,7 @@ pub const Node = struct {
815 try accelerator.idvalue.dump(tree, writer, indent + 1);812 try accelerator.idvalue.dump(tree, writer, indent + 1);
816 },813 },
817 .dialog => {814 .dialog => {
818 const dialog = @fieldParentPtr(Node.Dialog, "base", node);815 const dialog: *Node.Dialog = @alignCast(@fieldParentPtr("base", node));
819 try writer.print(" {s} {s} [{d} common_resource_attributes]\n", .{ dialog.id.slice(tree.source), dialog.type.slice(tree.source), dialog.common_resource_attributes.len });816 try writer.print(" {s} {s} [{d} common_resource_attributes]\n", .{ dialog.id.slice(tree.source), dialog.type.slice(tree.source), dialog.common_resource_attributes.len });
820 inline for (.{ "x", "y", "width", "height" }) |arg| {817 inline for (.{ "x", "y", "width", "height" }) |arg| {
821 try writer.writeByteNTimes(' ', indent + 1);818 try writer.writeByteNTimes(' ', indent + 1);
...@@ -841,7 +838,7 @@ pub const Node = struct {...@@ -841,7 +838,7 @@ pub const Node = struct {
841 try writer.writeAll("\n");838 try writer.writeAll("\n");
842 },839 },
843 .control_statement => {840 .control_statement => {
844 const control = @fieldParentPtr(Node.ControlStatement, "base", node);841 const control: *Node.ControlStatement = @alignCast(@fieldParentPtr("base", node));
845 try writer.print(" {s}", .{control.type.slice(tree.source)});842 try writer.print(" {s}", .{control.type.slice(tree.source)});
846 if (control.text) |text| {843 if (control.text) |text| {
847 try writer.print(" text: {s}", .{text.slice(tree.source)});844 try writer.print(" text: {s}", .{text.slice(tree.source)});
...@@ -877,7 +874,7 @@ pub const Node = struct {...@@ -877,7 +874,7 @@ pub const Node = struct {
877 }874 }
878 },875 },
879 .toolbar => {876 .toolbar => {
880 const toolbar = @fieldParentPtr(Node.Toolbar, "base", node);877 const toolbar: *Node.Toolbar = @alignCast(@fieldParentPtr("base", node));
881 try writer.print(" {s} {s} [{d} common_resource_attributes]\n", .{ toolbar.id.slice(tree.source), toolbar.type.slice(tree.source), toolbar.common_resource_attributes.len });878 try writer.print(" {s} {s} [{d} common_resource_attributes]\n", .{ toolbar.id.slice(tree.source), toolbar.type.slice(tree.source), toolbar.common_resource_attributes.len });
882 inline for (.{ "button_width", "button_height" }) |arg| {879 inline for (.{ "button_width", "button_height" }) |arg| {
883 try writer.writeByteNTimes(' ', indent + 1);880 try writer.writeByteNTimes(' ', indent + 1);
...@@ -895,7 +892,7 @@ pub const Node = struct {...@@ -895,7 +892,7 @@ pub const Node = struct {
895 try writer.writeAll("\n");892 try writer.writeAll("\n");
896 },893 },
897 .menu => {894 .menu => {
898 const menu = @fieldParentPtr(Node.Menu, "base", node);895 const menu: *Node.Menu = @alignCast(@fieldParentPtr("base", node));
899 try writer.print(" {s} {s} [{d} common_resource_attributes]\n", .{ menu.id.slice(tree.source), menu.type.slice(tree.source), menu.common_resource_attributes.len });896 try writer.print(" {s} {s} [{d} common_resource_attributes]\n", .{ menu.id.slice(tree.source), menu.type.slice(tree.source), menu.common_resource_attributes.len });
900 for (menu.optional_statements) |statement| {897 for (menu.optional_statements) |statement| {
901 try statement.dump(tree, writer, indent + 1);898 try statement.dump(tree, writer, indent + 1);
...@@ -916,16 +913,16 @@ pub const Node = struct {...@@ -916,16 +913,16 @@ pub const Node = struct {
916 try writer.writeAll("\n");913 try writer.writeAll("\n");
917 },914 },
918 .menu_item => {915 .menu_item => {
919 const menu_item = @fieldParentPtr(Node.MenuItem, "base", node);916 const menu_item: *Node.MenuItem = @alignCast(@fieldParentPtr("base", node));
920 try writer.print(" {s} {s} [{d} options]\n", .{ menu_item.menuitem.slice(tree.source), menu_item.text.slice(tree.source), menu_item.option_list.len });917 try writer.print(" {s} {s} [{d} options]\n", .{ menu_item.menuitem.slice(tree.source), menu_item.text.slice(tree.source), menu_item.option_list.len });
921 try menu_item.result.dump(tree, writer, indent + 1);918 try menu_item.result.dump(tree, writer, indent + 1);
922 },919 },
923 .menu_item_separator => {920 .menu_item_separator => {
924 const menu_item = @fieldParentPtr(Node.MenuItemSeparator, "base", node);921 const menu_item: *Node.MenuItemSeparator = @alignCast(@fieldParentPtr("base", node));
925 try writer.print(" {s} {s}\n", .{ menu_item.menuitem.slice(tree.source), menu_item.separator.slice(tree.source) });922 try writer.print(" {s} {s}\n", .{ menu_item.menuitem.slice(tree.source), menu_item.separator.slice(tree.source) });
926 },923 },
927 .menu_item_ex => {924 .menu_item_ex => {
928 const menu_item = @fieldParentPtr(Node.MenuItemEx, "base", node);925 const menu_item: *Node.MenuItemEx = @alignCast(@fieldParentPtr("base", node));
929 try writer.print(" {s} {s}\n", .{ menu_item.menuitem.slice(tree.source), menu_item.text.slice(tree.source) });926 try writer.print(" {s} {s}\n", .{ menu_item.menuitem.slice(tree.source), menu_item.text.slice(tree.source) });
930 inline for (.{ "id", "type", "state" }) |arg| {927 inline for (.{ "id", "type", "state" }) |arg| {
931 if (@field(menu_item, arg)) |val_node| {928 if (@field(menu_item, arg)) |val_node| {
...@@ -936,7 +933,7 @@ pub const Node = struct {...@@ -936,7 +933,7 @@ pub const Node = struct {
936 }933 }
937 },934 },
938 .popup => {935 .popup => {
939 const popup = @fieldParentPtr(Node.Popup, "base", node);936 const popup: *Node.Popup = @alignCast(@fieldParentPtr("base", node));
940 try writer.print(" {s} {s} [{d} options]\n", .{ popup.popup.slice(tree.source), popup.text.slice(tree.source), popup.option_list.len });937 try writer.print(" {s} {s} [{d} options]\n", .{ popup.popup.slice(tree.source), popup.text.slice(tree.source), popup.option_list.len });
941 try writer.writeByteNTimes(' ', indent);938 try writer.writeByteNTimes(' ', indent);
942 try writer.writeAll(popup.begin_token.slice(tree.source));939 try writer.writeAll(popup.begin_token.slice(tree.source));
...@@ -949,7 +946,7 @@ pub const Node = struct {...@@ -949,7 +946,7 @@ pub const Node = struct {
949 try writer.writeAll("\n");946 try writer.writeAll("\n");
950 },947 },
951 .popup_ex => {948 .popup_ex => {
952 const popup = @fieldParentPtr(Node.PopupEx, "base", node);949 const popup: *Node.PopupEx = @alignCast(@fieldParentPtr("base", node));
953 try writer.print(" {s} {s}\n", .{ popup.popup.slice(tree.source), popup.text.slice(tree.source) });950 try writer.print(" {s} {s}\n", .{ popup.popup.slice(tree.source), popup.text.slice(tree.source) });
954 inline for (.{ "id", "type", "state", "help_id" }) |arg| {951 inline for (.{ "id", "type", "state", "help_id" }) |arg| {
955 if (@field(popup, arg)) |val_node| {952 if (@field(popup, arg)) |val_node| {
...@@ -969,7 +966,7 @@ pub const Node = struct {...@@ -969,7 +966,7 @@ pub const Node = struct {
969 try writer.writeAll("\n");966 try writer.writeAll("\n");
970 },967 },
971 .version_info => {968 .version_info => {
972 const version_info = @fieldParentPtr(Node.VersionInfo, "base", node);969 const version_info: *Node.VersionInfo = @alignCast(@fieldParentPtr("base", node));
973 try writer.print(" {s} {s} [{d} common_resource_attributes]\n", .{ version_info.id.slice(tree.source), version_info.versioninfo.slice(tree.source), version_info.common_resource_attributes.len });970 try writer.print(" {s} {s} [{d} common_resource_attributes]\n", .{ version_info.id.slice(tree.source), version_info.versioninfo.slice(tree.source), version_info.common_resource_attributes.len });
974 for (version_info.fixed_info) |fixed_info| {971 for (version_info.fixed_info) |fixed_info| {
975 try fixed_info.dump(tree, writer, indent + 1);972 try fixed_info.dump(tree, writer, indent + 1);
...@@ -985,14 +982,14 @@ pub const Node = struct {...@@ -985,14 +982,14 @@ pub const Node = struct {
985 try writer.writeAll("\n");982 try writer.writeAll("\n");
986 },983 },
987 .version_statement => {984 .version_statement => {
988 const version_statement = @fieldParentPtr(Node.VersionStatement, "base", node);985 const version_statement: *Node.VersionStatement = @alignCast(@fieldParentPtr("base", node));
989 try writer.print(" {s}\n", .{version_statement.type.slice(tree.source)});986 try writer.print(" {s}\n", .{version_statement.type.slice(tree.source)});
990 for (version_statement.parts) |part| {987 for (version_statement.parts) |part| {
991 try part.dump(tree, writer, indent + 1);988 try part.dump(tree, writer, indent + 1);
992 }989 }
993 },990 },
994 .block => {991 .block => {
995 const block = @fieldParentPtr(Node.Block, "base", node);992 const block: *Node.Block = @alignCast(@fieldParentPtr("base", node));
996 try writer.print(" {s} {s}\n", .{ block.identifier.slice(tree.source), block.key.slice(tree.source) });993 try writer.print(" {s} {s}\n", .{ block.identifier.slice(tree.source), block.key.slice(tree.source) });
997 for (block.values) |value| {994 for (block.values) |value| {
998 try value.dump(tree, writer, indent + 1);995 try value.dump(tree, writer, indent + 1);
...@@ -1008,14 +1005,14 @@ pub const Node = struct {...@@ -1008,14 +1005,14 @@ pub const Node = struct {
1008 try writer.writeAll("\n");1005 try writer.writeAll("\n");
1009 },1006 },
1010 .block_value => {1007 .block_value => {
1011 const block_value = @fieldParentPtr(Node.BlockValue, "base", node);1008 const block_value: *Node.BlockValue = @alignCast(@fieldParentPtr("base", node));
1012 try writer.print(" {s} {s}\n", .{ block_value.identifier.slice(tree.source), block_value.key.slice(tree.source) });1009 try writer.print(" {s} {s}\n", .{ block_value.identifier.slice(tree.source), block_value.key.slice(tree.source) });
1013 for (block_value.values) |value| {1010 for (block_value.values) |value| {
1014 try value.dump(tree, writer, indent + 1);1011 try value.dump(tree, writer, indent + 1);
1015 }1012 }
1016 },1013 },
1017 .block_value_value => {1014 .block_value_value => {
1018 const block_value = @fieldParentPtr(Node.BlockValueValue, "base", node);1015 const block_value: *Node.BlockValueValue = @alignCast(@fieldParentPtr("base", node));
1019 if (block_value.trailing_comma) {1016 if (block_value.trailing_comma) {
1020 try writer.writeAll(" ,");1017 try writer.writeAll(" ,");
1021 }1018 }
...@@ -1023,7 +1020,7 @@ pub const Node = struct {...@@ -1023,7 +1020,7 @@ pub const Node = struct {
1023 try block_value.expression.dump(tree, writer, indent + 1);1020 try block_value.expression.dump(tree, writer, indent + 1);
1024 },1021 },
1025 .string_table => {1022 .string_table => {
1026 const string_table = @fieldParentPtr(Node.StringTable, "base", node);1023 const string_table: *Node.StringTable = @alignCast(@fieldParentPtr("base", node));
1027 try writer.print(" {s} [{d} common_resource_attributes]\n", .{ string_table.type.slice(tree.source), string_table.common_resource_attributes.len });1024 try writer.print(" {s} [{d} common_resource_attributes]\n", .{ string_table.type.slice(tree.source), string_table.common_resource_attributes.len });
1028 for (string_table.optional_statements) |statement| {1025 for (string_table.optional_statements) |statement| {
1029 try statement.dump(tree, writer, indent + 1);1026 try statement.dump(tree, writer, indent + 1);
...@@ -1040,19 +1037,19 @@ pub const Node = struct {...@@ -1040,19 +1037,19 @@ pub const Node = struct {
1040 },1037 },
1041 .string_table_string => {1038 .string_table_string => {
1042 try writer.writeAll("\n");1039 try writer.writeAll("\n");
1043 const string = @fieldParentPtr(Node.StringTableString, "base", node);1040 const string: *Node.StringTableString = @alignCast(@fieldParentPtr("base", node));
1044 try string.id.dump(tree, writer, indent + 1);1041 try string.id.dump(tree, writer, indent + 1);
1045 try writer.writeByteNTimes(' ', indent + 1);1042 try writer.writeByteNTimes(' ', indent + 1);
1046 try writer.print("{s}\n", .{string.string.slice(tree.source)});1043 try writer.print("{s}\n", .{string.string.slice(tree.source)});
1047 },1044 },
1048 .language_statement => {1045 .language_statement => {
1049 const language = @fieldParentPtr(Node.LanguageStatement, "base", node);1046 const language: *Node.LanguageStatement = @alignCast(@fieldParentPtr("base", node));
1050 try writer.print(" {s}\n", .{language.language_token.slice(tree.source)});1047 try writer.print(" {s}\n", .{language.language_token.slice(tree.source)});
1051 try language.primary_language_id.dump(tree, writer, indent + 1);1048 try language.primary_language_id.dump(tree, writer, indent + 1);
1052 try language.sublanguage_id.dump(tree, writer, indent + 1);1049 try language.sublanguage_id.dump(tree, writer, indent + 1);
1053 },1050 },
1054 .font_statement => {1051 .font_statement => {
1055 const font = @fieldParentPtr(Node.FontStatement, "base", node);1052 const font: *Node.FontStatement = @alignCast(@fieldParentPtr("base", node));
1056 try writer.print(" {s} typeface: {s}\n", .{ font.identifier.slice(tree.source), font.typeface.slice(tree.source) });1053 try writer.print(" {s} typeface: {s}\n", .{ font.identifier.slice(tree.source), font.typeface.slice(tree.source) });
1057 try writer.writeByteNTimes(' ', indent + 1);1054 try writer.writeByteNTimes(' ', indent + 1);
1058 try writer.writeAll("point_size:\n");1055 try writer.writeAll("point_size:\n");
...@@ -1066,12 +1063,12 @@ pub const Node = struct {...@@ -1066,12 +1063,12 @@ pub const Node = struct {
1066 }1063 }
1067 },1064 },
1068 .simple_statement => {1065 .simple_statement => {
1069 const statement = @fieldParentPtr(Node.SimpleStatement, "base", node);1066 const statement: *Node.SimpleStatement = @alignCast(@fieldParentPtr("base", node));
1070 try writer.print(" {s}\n", .{statement.identifier.slice(tree.source)});1067 try writer.print(" {s}\n", .{statement.identifier.slice(tree.source)});
1071 try statement.value.dump(tree, writer, indent + 1);1068 try statement.value.dump(tree, writer, indent + 1);
1072 },1069 },
1073 .invalid => {1070 .invalid => {
1074 const invalid = @fieldParentPtr(Node.Invalid, "base", node);1071 const invalid: *Node.Invalid = @alignCast(@fieldParentPtr("base", node));
1075 try writer.print(" context.len: {}\n", .{invalid.context.len});1072 try writer.print(" context.len: {}\n", .{invalid.context.len});
1076 for (invalid.context) |context_token| {1073 for (invalid.context) |context_token| {
1077 try writer.writeByteNTimes(' ', indent + 1);1074 try writer.writeByteNTimes(' ', indent + 1);
lib/compiler/resinator/compile.zig+33-33
...@@ -229,34 +229,34 @@ pub const Compiler = struct {...@@ -229,34 +229,34 @@ pub const Compiler = struct {
229 pub fn writeNode(self: *Compiler, node: *Node, writer: anytype) !void {229 pub fn writeNode(self: *Compiler, node: *Node, writer: anytype) !void {
230 switch (node.id) {230 switch (node.id) {
231 .root => unreachable, // writeRoot should be called directly instead231 .root => unreachable, // writeRoot should be called directly instead
232 .resource_external => try self.writeResourceExternal(@fieldParentPtr(Node.ResourceExternal, "base", node), writer),232 .resource_external => try self.writeResourceExternal(@alignCast(@fieldParentPtr("base", node)), writer),
233 .resource_raw_data => try self.writeResourceRawData(@fieldParentPtr(Node.ResourceRawData, "base", node), writer),233 .resource_raw_data => try self.writeResourceRawData(@alignCast(@fieldParentPtr("base", node)), writer),
234 .literal => unreachable, // this is context dependent and should be handled by its parent234 .literal => unreachable, // this is context dependent and should be handled by its parent
235 .binary_expression => unreachable,235 .binary_expression => unreachable,
236 .grouped_expression => unreachable,236 .grouped_expression => unreachable,
237 .not_expression => unreachable,237 .not_expression => unreachable,
238 .invalid => {}, // no-op, currently only used for dangling literals at EOF238 .invalid => {}, // no-op, currently only used for dangling literals at EOF
239 .accelerators => try self.writeAccelerators(@fieldParentPtr(Node.Accelerators, "base", node), writer),239 .accelerators => try self.writeAccelerators(@alignCast(@fieldParentPtr("base", node)), writer),
240 .accelerator => unreachable, // handled by writeAccelerators240 .accelerator => unreachable, // handled by writeAccelerators
241 .dialog => try self.writeDialog(@fieldParentPtr(Node.Dialog, "base", node), writer),241 .dialog => try self.writeDialog(@alignCast(@fieldParentPtr("base", node)), writer),
242 .control_statement => unreachable,242 .control_statement => unreachable,
243 .toolbar => try self.writeToolbar(@fieldParentPtr(Node.Toolbar, "base", node), writer),243 .toolbar => try self.writeToolbar(@alignCast(@fieldParentPtr("base", node)), writer),
244 .menu => try self.writeMenu(@fieldParentPtr(Node.Menu, "base", node), writer),244 .menu => try self.writeMenu(@alignCast(@fieldParentPtr("base", node)), writer),
245 .menu_item => unreachable,245 .menu_item => unreachable,
246 .menu_item_separator => unreachable,246 .menu_item_separator => unreachable,
247 .menu_item_ex => unreachable,247 .menu_item_ex => unreachable,
248 .popup => unreachable,248 .popup => unreachable,
249 .popup_ex => unreachable,249 .popup_ex => unreachable,
250 .version_info => try self.writeVersionInfo(@fieldParentPtr(Node.VersionInfo, "base", node), writer),250 .version_info => try self.writeVersionInfo(@alignCast(@fieldParentPtr("base", node)), writer),
251 .version_statement => unreachable,251 .version_statement => unreachable,
252 .block => unreachable,252 .block => unreachable,
253 .block_value => unreachable,253 .block_value => unreachable,
254 .block_value_value => unreachable,254 .block_value_value => unreachable,
255 .string_table => try self.writeStringTable(@fieldParentPtr(Node.StringTable, "base", node)),255 .string_table => try self.writeStringTable(@alignCast(@fieldParentPtr("base", node))),
256 .string_table_string => unreachable, // handled by writeStringTable256 .string_table_string => unreachable, // handled by writeStringTable
257 .language_statement => self.writeLanguageStatement(@fieldParentPtr(Node.LanguageStatement, "base", node)),257 .language_statement => self.writeLanguageStatement(@alignCast(@fieldParentPtr("base", node))),
258 .font_statement => unreachable,258 .font_statement => unreachable,
259 .simple_statement => self.writeTopLevelSimpleStatement(@fieldParentPtr(Node.SimpleStatement, "base", node)),259 .simple_statement => self.writeTopLevelSimpleStatement(@alignCast(@fieldParentPtr("base", node))),
260 }260 }
261 }261 }
262262
...@@ -1289,7 +1289,7 @@ pub const Compiler = struct {...@@ -1289,7 +1289,7 @@ pub const Compiler = struct {
1289 return evaluateNumberExpression(node, self.source, self.input_code_pages).asWord();1289 return evaluateNumberExpression(node, self.source, self.input_code_pages).asWord();
1290 } else {1290 } else {
1291 std.debug.assert(node.isStringLiteral());1291 std.debug.assert(node.isStringLiteral());
1292 const literal = @fieldParentPtr(Node.Literal, "base", node);1292 const literal: *Node.Literal = @alignCast(@fieldParentPtr("base", node));
1293 const bytes = SourceBytes{1293 const bytes = SourceBytes{
1294 .slice = literal.token.slice(self.source),1294 .slice = literal.token.slice(self.source),
1295 .code_page = self.input_code_pages.getForToken(literal.token),1295 .code_page = self.input_code_pages.getForToken(literal.token),
...@@ -1342,7 +1342,7 @@ pub const Compiler = struct {...@@ -1342,7 +1342,7 @@ pub const Compiler = struct {
1342 /// the writer within this function could return error.NoSpaceLeft1342 /// the writer within this function could return error.NoSpaceLeft
1343 pub fn writeAcceleratorsData(self: *Compiler, node: *Node.Accelerators, data_writer: anytype) !void {1343 pub fn writeAcceleratorsData(self: *Compiler, node: *Node.Accelerators, data_writer: anytype) !void {
1344 for (node.accelerators, 0..) |accel_node, i| {1344 for (node.accelerators, 0..) |accel_node, i| {
1345 const accelerator = @fieldParentPtr(Node.Accelerator, "base", accel_node);1345 const accelerator: *Node.Accelerator = @alignCast(@fieldParentPtr("base", accel_node));
1346 var modifiers = res.AcceleratorModifiers{};1346 var modifiers = res.AcceleratorModifiers{};
1347 for (accelerator.type_and_options) |type_or_option| {1347 for (accelerator.type_and_options) |type_or_option| {
1348 const modifier = rc.AcceleratorTypeAndOptions.map.get(type_or_option.slice(self.source)).?;1348 const modifier = rc.AcceleratorTypeAndOptions.map.get(type_or_option.slice(self.source)).?;
...@@ -1426,7 +1426,7 @@ pub const Compiler = struct {...@@ -1426,7 +1426,7 @@ pub const Compiler = struct {
1426 for (node.optional_statements) |optional_statement| {1426 for (node.optional_statements) |optional_statement| {
1427 switch (optional_statement.id) {1427 switch (optional_statement.id) {
1428 .simple_statement => {1428 .simple_statement => {
1429 const simple_statement = @fieldParentPtr(Node.SimpleStatement, "base", optional_statement);1429 const simple_statement: *Node.SimpleStatement = @alignCast(@fieldParentPtr("base", optional_statement));
1430 const statement_identifier = simple_statement.identifier;1430 const statement_identifier = simple_statement.identifier;
1431 const statement_type = rc.OptionalStatements.dialog_map.get(statement_identifier.slice(self.source)) orelse continue;1431 const statement_type = rc.OptionalStatements.dialog_map.get(statement_identifier.slice(self.source)) orelse continue;
1432 switch (statement_type) {1432 switch (statement_type) {
...@@ -1440,7 +1440,7 @@ pub const Compiler = struct {...@@ -1440,7 +1440,7 @@ pub const Compiler = struct {
1440 },1440 },
1441 .caption => {1441 .caption => {
1442 std.debug.assert(simple_statement.value.id == .literal);1442 std.debug.assert(simple_statement.value.id == .literal);
1443 const literal_node = @fieldParentPtr(Node.Literal, "base", simple_statement.value);1443 const literal_node: *Node.Literal = @alignCast(@fieldParentPtr("base", simple_statement.value));
1444 optional_statement_values.caption = literal_node.token;1444 optional_statement_values.caption = literal_node.token;
1445 },1445 },
1446 .class => {1446 .class => {
...@@ -1466,7 +1466,7 @@ pub const Compiler = struct {...@@ -1466,7 +1466,7 @@ pub const Compiler = struct {
1466 optional_statement_values.class = NameOrOrdinal{ .ordinal = class_ordinal.asWord() };1466 optional_statement_values.class = NameOrOrdinal{ .ordinal = class_ordinal.asWord() };
1467 } else {1467 } else {
1468 std.debug.assert(simple_statement.value.isStringLiteral());1468 std.debug.assert(simple_statement.value.isStringLiteral());
1469 const literal_node = @fieldParentPtr(Node.Literal, "base", simple_statement.value);1469 const literal_node: *Node.Literal = @alignCast(@fieldParentPtr("base", simple_statement.value));
1470 const parsed = try self.parseQuotedStringAsWideString(literal_node.token);1470 const parsed = try self.parseQuotedStringAsWideString(literal_node.token);
1471 optional_statement_values.class = NameOrOrdinal{ .name = parsed };1471 optional_statement_values.class = NameOrOrdinal{ .name = parsed };
1472 }1472 }
...@@ -1492,7 +1492,7 @@ pub const Compiler = struct {...@@ -1492,7 +1492,7 @@ pub const Compiler = struct {
1492 }1492 }
14931493
1494 std.debug.assert(simple_statement.value.id == .literal);1494 std.debug.assert(simple_statement.value.id == .literal);
1495 const literal_node = @fieldParentPtr(Node.Literal, "base", simple_statement.value);1495 const literal_node: *Node.Literal = @alignCast(@fieldParentPtr("base", simple_statement.value));
14961496
1497 const token_slice = literal_node.token.slice(self.source);1497 const token_slice = literal_node.token.slice(self.source);
1498 const bytes = SourceBytes{1498 const bytes = SourceBytes{
...@@ -1542,7 +1542,7 @@ pub const Compiler = struct {...@@ -1542,7 +1542,7 @@ pub const Compiler = struct {
1542 }1542 }
1543 },1543 },
1544 .font_statement => {1544 .font_statement => {
1545 const font = @fieldParentPtr(Node.FontStatement, "base", optional_statement);1545 const font: *Node.FontStatement = @alignCast(@fieldParentPtr("base", optional_statement));
1546 if (optional_statement_values.font != null) {1546 if (optional_statement_values.font != null) {
1547 optional_statement_values.font.?.node = font;1547 optional_statement_values.font.?.node = font;
1548 } else {1548 } else {
...@@ -1581,7 +1581,7 @@ pub const Compiler = struct {...@@ -1581,7 +1581,7 @@ pub const Compiler = struct {
1581 // Multiple CLASS parameters are specified and any of them are treated as a number, then1581 // Multiple CLASS parameters are specified and any of them are treated as a number, then
1582 // the last CLASS is always treated as a number no matter what1582 // the last CLASS is always treated as a number no matter what
1583 if (last_class_would_be_forced_ordinal and optional_statement_values.class.? == .name) {1583 if (last_class_would_be_forced_ordinal and optional_statement_values.class.? == .name) {
1584 const literal_node = @fieldParentPtr(Node.Literal, "base", last_class.value);1584 const literal_node: *Node.Literal = @alignCast(@fieldParentPtr("base", last_class.value));
1585 const ordinal_value = res.ForcedOrdinal.fromUtf16Le(optional_statement_values.class.?.name);1585 const ordinal_value = res.ForcedOrdinal.fromUtf16Le(optional_statement_values.class.?.name);
15861586
1587 try self.addErrorDetails(.{1587 try self.addErrorDetails(.{
...@@ -1611,7 +1611,7 @@ pub const Compiler = struct {...@@ -1611,7 +1611,7 @@ pub const Compiler = struct {
1611 // 2. Multiple MENU parameters are specified and any of them are treated as a number, then1611 // 2. Multiple MENU parameters are specified and any of them are treated as a number, then
1612 // the last MENU is always treated as a number no matter what1612 // the last MENU is always treated as a number no matter what
1613 if ((last_menu_would_be_forced_ordinal or last_menu_has_digit_as_first_char) and optional_statement_values.menu.? == .name) {1613 if ((last_menu_would_be_forced_ordinal or last_menu_has_digit_as_first_char) and optional_statement_values.menu.? == .name) {
1614 const literal_node = @fieldParentPtr(Node.Literal, "base", last_menu.value);1614 const literal_node: *Node.Literal = @alignCast(@fieldParentPtr("base", last_menu.value));
1615 const token_slice = literal_node.token.slice(self.source);1615 const token_slice = literal_node.token.slice(self.source);
1616 const bytes = SourceBytes{1616 const bytes = SourceBytes{
1617 .slice = token_slice,1617 .slice = token_slice,
...@@ -1658,7 +1658,7 @@ pub const Compiler = struct {...@@ -1658,7 +1658,7 @@ pub const Compiler = struct {
1658 // between resinator and the Win32 RC compiler, we only emit a hint instead of1658 // between resinator and the Win32 RC compiler, we only emit a hint instead of
1659 // a warning.1659 // a warning.
1660 if (last_menu_did_uppercase) {1660 if (last_menu_did_uppercase) {
1661 const literal_node = @fieldParentPtr(Node.Literal, "base", last_menu.value);1661 const literal_node: *Node.Literal = @alignCast(@fieldParentPtr("base", last_menu.value));
1662 try self.addErrorDetails(.{1662 try self.addErrorDetails(.{
1663 .err = .dialog_menu_id_was_uppercased,1663 .err = .dialog_menu_id_was_uppercased,
1664 .type = .hint,1664 .type = .hint,
...@@ -1704,7 +1704,7 @@ pub const Compiler = struct {...@@ -1704,7 +1704,7 @@ pub const Compiler = struct {
1704 defer controls_by_id.deinit();1704 defer controls_by_id.deinit();
17051705
1706 for (node.controls) |control_node| {1706 for (node.controls) |control_node| {
1707 const control = @fieldParentPtr(Node.ControlStatement, "base", control_node);1707 const control: *Node.ControlStatement = @alignCast(@fieldParentPtr("base", control_node));
17081708
1709 self.writeDialogControl(1709 self.writeDialogControl(
1710 control,1710 control,
...@@ -1940,7 +1940,7 @@ pub const Compiler = struct {...@@ -1940,7 +1940,7 @@ pub const Compiler = struct {
1940 // And then write out the ordinal using a proper a NameOrOrdinal encoding.1940 // And then write out the ordinal using a proper a NameOrOrdinal encoding.
1941 try ordinal.write(data_writer);1941 try ordinal.write(data_writer);
1942 } else if (class_node.isStringLiteral()) {1942 } else if (class_node.isStringLiteral()) {
1943 const literal_node = @fieldParentPtr(Node.Literal, "base", class_node);1943 const literal_node: *Node.Literal = @alignCast(@fieldParentPtr("base", class_node));
1944 const parsed = try self.parseQuotedStringAsWideString(literal_node.token);1944 const parsed = try self.parseQuotedStringAsWideString(literal_node.token);
1945 defer self.allocator.free(parsed);1945 defer self.allocator.free(parsed);
1946 if (rc.ControlClass.fromWideString(parsed)) |control_class| {1946 if (rc.ControlClass.fromWideString(parsed)) |control_class| {
...@@ -1955,7 +1955,7 @@ pub const Compiler = struct {...@@ -1955,7 +1955,7 @@ pub const Compiler = struct {
1955 try name.write(data_writer);1955 try name.write(data_writer);
1956 }1956 }
1957 } else {1957 } else {
1958 const literal_node = @fieldParentPtr(Node.Literal, "base", class_node);1958 const literal_node: *Node.Literal = @alignCast(@fieldParentPtr("base", class_node));
1959 const literal_slice = literal_node.token.slice(self.source);1959 const literal_slice = literal_node.token.slice(self.source);
1960 // This succeeding is guaranteed by the parser1960 // This succeeding is guaranteed by the parser
1961 const control_class = rc.ControlClass.map.get(literal_slice) orelse unreachable;1961 const control_class = rc.ControlClass.map.get(literal_slice) orelse unreachable;
...@@ -2178,7 +2178,7 @@ pub const Compiler = struct {...@@ -2178,7 +2178,7 @@ pub const Compiler = struct {
2178 try writer.writeInt(u16, 0, .little); // null-terminated UTF-16 text2178 try writer.writeInt(u16, 0, .little); // null-terminated UTF-16 text
2179 },2179 },
2180 .menu_item => {2180 .menu_item => {
2181 const menu_item = @fieldParentPtr(Node.MenuItem, "base", node);2181 const menu_item: *Node.MenuItem = @alignCast(@fieldParentPtr("base", node));
2182 var flags = res.MenuItemFlags{};2182 var flags = res.MenuItemFlags{};
2183 for (menu_item.option_list) |option_token| {2183 for (menu_item.option_list) |option_token| {
2184 // This failing would be a bug in the parser2184 // This failing would be a bug in the parser
...@@ -2196,7 +2196,7 @@ pub const Compiler = struct {...@@ -2196,7 +2196,7 @@ pub const Compiler = struct {
2196 try writer.writeAll(std.mem.sliceAsBytes(text[0 .. text.len + 1]));2196 try writer.writeAll(std.mem.sliceAsBytes(text[0 .. text.len + 1]));
2197 },2197 },
2198 .popup => {2198 .popup => {
2199 const popup = @fieldParentPtr(Node.Popup, "base", node);2199 const popup: *Node.Popup = @alignCast(@fieldParentPtr("base", node));
2200 var flags = res.MenuItemFlags{ .value = res.MF.POPUP };2200 var flags = res.MenuItemFlags{ .value = res.MF.POPUP };
2201 for (popup.option_list) |option_token| {2201 for (popup.option_list) |option_token| {
2202 // This failing would be a bug in the parser2202 // This failing would be a bug in the parser
...@@ -2216,7 +2216,7 @@ pub const Compiler = struct {...@@ -2216,7 +2216,7 @@ pub const Compiler = struct {
2216 }2216 }
2217 },2217 },
2218 inline .menu_item_ex, .popup_ex => |node_type| {2218 inline .menu_item_ex, .popup_ex => |node_type| {
2219 const menu_item = @fieldParentPtr(node_type.Type(), "base", node);2219 const menu_item: *node_type.Type() = @alignCast(@fieldParentPtr("base", node));
22202220
2221 if (menu_item.type) |flags| {2221 if (menu_item.type) |flags| {
2222 const value = evaluateNumberExpression(flags, self.source, self.input_code_pages);2222 const value = evaluateNumberExpression(flags, self.source, self.input_code_pages);
...@@ -2295,7 +2295,7 @@ pub const Compiler = struct {...@@ -2295,7 +2295,7 @@ pub const Compiler = struct {
2295 for (node.fixed_info) |fixed_info| {2295 for (node.fixed_info) |fixed_info| {
2296 switch (fixed_info.id) {2296 switch (fixed_info.id) {
2297 .version_statement => {2297 .version_statement => {
2298 const version_statement = @fieldParentPtr(Node.VersionStatement, "base", fixed_info);2298 const version_statement: *Node.VersionStatement = @alignCast(@fieldParentPtr("base", fixed_info));
2299 const version_type = rc.VersionInfo.map.get(version_statement.type.slice(self.source)).?;2299 const version_type = rc.VersionInfo.map.get(version_statement.type.slice(self.source)).?;
23002300
2301 // Ensure that all parts are cleared for each version, to properly account for2301 // Ensure that all parts are cleared for each version, to properly account for
...@@ -2345,7 +2345,7 @@ pub const Compiler = struct {...@@ -2345,7 +2345,7 @@ pub const Compiler = struct {
2345 }2345 }
2346 },2346 },
2347 .simple_statement => {2347 .simple_statement => {
2348 const statement = @fieldParentPtr(Node.SimpleStatement, "base", fixed_info);2348 const statement: *Node.SimpleStatement = @alignCast(@fieldParentPtr("base", fixed_info));
2349 const statement_type = rc.VersionInfo.map.get(statement.identifier.slice(self.source)).?;2349 const statement_type = rc.VersionInfo.map.get(statement.identifier.slice(self.source)).?;
2350 const value = evaluateNumberExpression(statement.value, self.source, self.input_code_pages);2350 const value = evaluateNumberExpression(statement.value, self.source, self.input_code_pages);
2351 switch (statement_type) {2351 switch (statement_type) {
...@@ -2416,7 +2416,7 @@ pub const Compiler = struct {...@@ -2416,7 +2416,7 @@ pub const Compiler = struct {
24162416
2417 switch (node.id) {2417 switch (node.id) {
2418 inline .block, .block_value => |node_type| {2418 inline .block, .block_value => |node_type| {
2419 const block_or_value = @fieldParentPtr(node_type.Type(), "base", node);2419 const block_or_value: *node_type.Type() = @alignCast(@fieldParentPtr("base", node));
2420 const parsed_key = try self.parseQuotedStringAsWideString(block_or_value.key);2420 const parsed_key = try self.parseQuotedStringAsWideString(block_or_value.key);
2421 defer self.allocator.free(parsed_key);2421 defer self.allocator.free(parsed_key);
24222422
...@@ -2506,7 +2506,7 @@ pub const Compiler = struct {...@@ -2506,7 +2506,7 @@ pub const Compiler = struct {
2506 const language = getLanguageFromOptionalStatements(node.optional_statements, self.source, self.input_code_pages) orelse self.state.language;2506 const language = getLanguageFromOptionalStatements(node.optional_statements, self.source, self.input_code_pages) orelse self.state.language;
25072507
2508 for (node.strings) |string_node| {2508 for (node.strings) |string_node| {
2509 const string = @fieldParentPtr(Node.StringTableString, "base", string_node);2509 const string: *Node.StringTableString = @alignCast(@fieldParentPtr("base", string_node));
2510 const string_id_data = try self.evaluateDataExpression(string.id);2510 const string_id_data = try self.evaluateDataExpression(string.id);
2511 const string_id = string_id_data.number.asWord();2511 const string_id = string_id_data.number.asWord();
25122512
...@@ -2795,11 +2795,11 @@ pub const Compiler = struct {...@@ -2795,11 +2795,11 @@ pub const Compiler = struct {
2795 fn applyToOptionalStatements(language: *res.Language, version: *u32, characteristics: *u32, statements: []*Node, source: []const u8, code_page_lookup: *const CodePageLookup) void {2795 fn applyToOptionalStatements(language: *res.Language, version: *u32, characteristics: *u32, statements: []*Node, source: []const u8, code_page_lookup: *const CodePageLookup) void {
2796 for (statements) |node| switch (node.id) {2796 for (statements) |node| switch (node.id) {
2797 .language_statement => {2797 .language_statement => {
2798 const language_statement = @fieldParentPtr(Node.LanguageStatement, "base", node);2798 const language_statement: *Node.LanguageStatement = @alignCast(@fieldParentPtr("base", node));
2799 language.* = languageFromLanguageStatement(language_statement, source, code_page_lookup);2799 language.* = languageFromLanguageStatement(language_statement, source, code_page_lookup);
2800 },2800 },
2801 .simple_statement => {2801 .simple_statement => {
2802 const simple_statement = @fieldParentPtr(Node.SimpleStatement, "base", node);2802 const simple_statement: *Node.SimpleStatement = @alignCast(@fieldParentPtr("base", node));
2803 const statement_type = rc.OptionalStatements.map.get(simple_statement.identifier.slice(source)) orelse continue;2803 const statement_type = rc.OptionalStatements.map.get(simple_statement.identifier.slice(source)) orelse continue;
2804 const result = Compiler.evaluateNumberExpression(simple_statement.value, source, code_page_lookup);2804 const result = Compiler.evaluateNumberExpression(simple_statement.value, source, code_page_lookup);
2805 switch (statement_type) {2805 switch (statement_type) {
...@@ -2824,7 +2824,7 @@ pub const Compiler = struct {...@@ -2824,7 +2824,7 @@ pub const Compiler = struct {
2824 pub fn getLanguageFromOptionalStatements(statements: []*Node, source: []const u8, code_page_lookup: *const CodePageLookup) ?res.Language {2824 pub fn getLanguageFromOptionalStatements(statements: []*Node, source: []const u8, code_page_lookup: *const CodePageLookup) ?res.Language {
2825 for (statements) |node| switch (node.id) {2825 for (statements) |node| switch (node.id) {
2826 .language_statement => {2826 .language_statement => {
2827 const language_statement = @fieldParentPtr(Node.LanguageStatement, "base", node);2827 const language_statement: *Node.LanguageStatement = @alignCast(@fieldParentPtr("base", node));
2828 return languageFromLanguageStatement(language_statement, source, code_page_lookup);2828 return languageFromLanguageStatement(language_statement, source, code_page_lookup);
2829 },2829 },
2830 else => continue,2830 else => continue,
lib/compiler/resinator/parse.zig+1-1
...@@ -889,7 +889,7 @@ pub const Parser = struct {...@@ -889,7 +889,7 @@ pub const Parser = struct {
889 if (control == .control) {889 if (control == .control) {
890 class = try self.parseExpression(.{});890 class = try self.parseExpression(.{});
891 if (class.?.id == .literal) {891 if (class.?.id == .literal) {
892 const class_literal = @fieldParentPtr(Node.Literal, "base", class.?);892 const class_literal: *Node.Literal = @alignCast(@fieldParentPtr("base", class.?));
893 const is_invalid_control_class = class_literal.token.id == .literal and !rc.ControlClass.map.has(class_literal.token.slice(self.lexer.buffer));893 const is_invalid_control_class = class_literal.token.id == .literal and !rc.ControlClass.map.has(class_literal.token.slice(self.lexer.buffer));
894 if (is_invalid_control_class) {894 if (is_invalid_control_class) {
895 return self.addErrorDetailsAndFail(.{895 return self.addErrorDetailsAndFail(.{
lib/docs/wasm/Walk.zig+6-6
...@@ -48,7 +48,7 @@ pub const File = struct {...@@ -48,7 +48,7 @@ pub const File = struct {
48 pub fn field_count(file: *const File, node: Ast.Node.Index) u32 {48 pub fn field_count(file: *const File, node: Ast.Node.Index) u32 {
49 const scope = file.scopes.get(node) orelse return 0;49 const scope = file.scopes.get(node) orelse return 0;
50 if (scope.tag != .namespace) return 0;50 if (scope.tag != .namespace) return 0;
51 const namespace = @fieldParentPtr(Scope.Namespace, "base", scope);51 const namespace: *Scope.Namespace = @alignCast(@fieldParentPtr("base", scope));
52 return namespace.field_count;52 return namespace.field_count;
53 }53 }
5454
...@@ -439,11 +439,11 @@ pub const Scope = struct {...@@ -439,11 +439,11 @@ pub const Scope = struct {
439 while (true) switch (it.tag) {439 while (true) switch (it.tag) {
440 .top => unreachable,440 .top => unreachable,
441 .local => {441 .local => {
442 const local = @fieldParentPtr(Local, "base", it);442 const local: *Local = @alignCast(@fieldParentPtr("base", it));
443 it = local.parent;443 it = local.parent;
444 },444 },
445 .namespace => {445 .namespace => {
446 const namespace = @fieldParentPtr(Namespace, "base", it);446 const namespace: *Namespace = @alignCast(@fieldParentPtr("base", it));
447 return namespace.decl_index;447 return namespace.decl_index;
448 },448 },
449 };449 };
...@@ -453,7 +453,7 @@ pub const Scope = struct {...@@ -453,7 +453,7 @@ pub const Scope = struct {
453 switch (scope.tag) {453 switch (scope.tag) {
454 .top, .local => return null,454 .top, .local => return null,
455 .namespace => {455 .namespace => {
456 const namespace = @fieldParentPtr(Namespace, "base", scope);456 const namespace: *Namespace = @alignCast(@fieldParentPtr("base", scope));
457 return namespace.names.get(name);457 return namespace.names.get(name);
458 },458 },
459 }459 }
...@@ -465,7 +465,7 @@ pub const Scope = struct {...@@ -465,7 +465,7 @@ pub const Scope = struct {
465 while (true) switch (it.tag) {465 while (true) switch (it.tag) {
466 .top => break,466 .top => break,
467 .local => {467 .local => {
468 const local = @fieldParentPtr(Local, "base", it);468 const local: *Local = @alignCast(@fieldParentPtr("base", it));
469 const name_token = main_tokens[local.var_node] + 1;469 const name_token = main_tokens[local.var_node] + 1;
470 const ident_name = ast.tokenSlice(name_token);470 const ident_name = ast.tokenSlice(name_token);
471 if (std.mem.eql(u8, ident_name, name)) {471 if (std.mem.eql(u8, ident_name, name)) {
...@@ -474,7 +474,7 @@ pub const Scope = struct {...@@ -474,7 +474,7 @@ pub const Scope = struct {
474 it = local.parent;474 it = local.parent;
475 },475 },
476 .namespace => {476 .namespace => {
477 const namespace = @fieldParentPtr(Namespace, "base", it);477 const namespace: *Namespace = @alignCast(@fieldParentPtr("base", it));
478 if (namespace.names.get(name)) |node| {478 if (namespace.names.get(name)) |node| {
479 return node;479 return node;
480 }480 }
lib/std/Build.zig+2-2
...@@ -1062,8 +1062,8 @@ pub fn getUninstallStep(self: *Build) *Step {...@@ -1062,8 +1062,8 @@ pub fn getUninstallStep(self: *Build) *Step {
10621062
1063fn makeUninstall(uninstall_step: *Step, prog_node: *std.Progress.Node) anyerror!void {1063fn makeUninstall(uninstall_step: *Step, prog_node: *std.Progress.Node) anyerror!void {
1064 _ = prog_node;1064 _ = prog_node;
1065 const uninstall_tls = @fieldParentPtr(*TopLevelStep, "step", uninstall_step);1065 const uninstall_tls: *TopLevelStep = @fieldParentPtr("step", uninstall_step);
1066 const self = @fieldParentPtr(*Build, "uninstall_tls", uninstall_tls);1066 const self: *Build = @fieldParentPtr("uninstall_tls", uninstall_tls);
10671067
1068 for (self.installed_files.items) |installed_file| {1068 for (self.installed_files.items) |installed_file| {
1069 const full_path = self.getInstallPath(installed_file.dir, installed_file.path);1069 const full_path = self.getInstallPath(installed_file.dir, installed_file.path);
lib/std/Build/Step.zig+1-1
...@@ -231,7 +231,7 @@ fn makeNoOp(step: *Step, prog_node: *std.Progress.Node) anyerror!void {...@@ -231,7 +231,7 @@ fn makeNoOp(step: *Step, prog_node: *std.Progress.Node) anyerror!void {
231231
232pub fn cast(step: *Step, comptime T: type) ?*T {232pub fn cast(step: *Step, comptime T: type) ?*T {
233 if (step.id == T.base_id) {233 if (step.id == T.base_id) {
234 return @fieldParentPtr(*T, "step", step);234 return @fieldParentPtr("step", step);
235 }235 }
236 return null;236 return null;
237}237}
lib/std/Build/Step/CheckFile.zig+1-1
...@@ -49,7 +49,7 @@ pub fn setName(self: *CheckFile, name: []const u8) void {...@@ -49,7 +49,7 @@ pub fn setName(self: *CheckFile, name: []const u8) void {
49fn make(step: *Step, prog_node: *std.Progress.Node) !void {49fn make(step: *Step, prog_node: *std.Progress.Node) !void {
50 _ = prog_node;50 _ = prog_node;
51 const b = step.owner;51 const b = step.owner;
52 const self = @fieldParentPtr(*CheckFile, "step", step);52 const self: *CheckFile = @fieldParentPtr("step", step);
5353
54 const src_path = self.source.getPath(b);54 const src_path = self.source.getPath(b);
55 const contents = fs.cwd().readFileAlloc(b.allocator, src_path, self.max_bytes) catch |err| {55 const contents = fs.cwd().readFileAlloc(b.allocator, src_path, self.max_bytes) catch |err| {
lib/std/Build/Step/CheckObject.zig+1-1
...@@ -530,7 +530,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -530,7 +530,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
530 _ = prog_node;530 _ = prog_node;
531 const b = step.owner;531 const b = step.owner;
532 const gpa = b.allocator;532 const gpa = b.allocator;
533 const self = @fieldParentPtr(*CheckObject, "step", step);533 const self: *CheckObject = @fieldParentPtr("step", step);
534534
535 const src_path = self.source.getPath(b);535 const src_path = self.source.getPath(b);
536 const contents = fs.cwd().readFileAllocOptions(536 const contents = fs.cwd().readFileAllocOptions(
lib/std/Build/Step/Compile.zig+1-1
...@@ -918,7 +918,7 @@ fn getGeneratedFilePath(self: *Compile, comptime tag_name: []const u8, asking_st...@@ -918,7 +918,7 @@ fn getGeneratedFilePath(self: *Compile, comptime tag_name: []const u8, asking_st
918fn make(step: *Step, prog_node: *std.Progress.Node) !void {918fn make(step: *Step, prog_node: *std.Progress.Node) !void {
919 const b = step.owner;919 const b = step.owner;
920 const arena = b.allocator;920 const arena = b.allocator;
921 const self = @fieldParentPtr(*Compile, "step", step);921 const self: *Compile = @fieldParentPtr("step", step);
922922
923 var zig_args = ArrayList([]const u8).init(arena);923 var zig_args = ArrayList([]const u8).init(arena);
924 defer zig_args.deinit();924 defer zig_args.deinit();
lib/std/Build/Step/ConfigHeader.zig+1-1
...@@ -167,7 +167,7 @@ fn putValue(self: *ConfigHeader, field_name: []const u8, comptime T: type, v: T)...@@ -167,7 +167,7 @@ fn putValue(self: *ConfigHeader, field_name: []const u8, comptime T: type, v: T)
167fn make(step: *Step, prog_node: *std.Progress.Node) !void {167fn make(step: *Step, prog_node: *std.Progress.Node) !void {
168 _ = prog_node;168 _ = prog_node;
169 const b = step.owner;169 const b = step.owner;
170 const self = @fieldParentPtr(*ConfigHeader, "step", step);170 const self: *ConfigHeader = @fieldParentPtr("step", step);
171 const gpa = b.allocator;171 const gpa = b.allocator;
172 const arena = b.allocator;172 const arena = b.allocator;
173173
lib/std/Build/Step/Fmt.zig+1-1
...@@ -47,7 +47,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -47,7 +47,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
4747
48 const b = step.owner;48 const b = step.owner;
49 const arena = b.allocator;49 const arena = b.allocator;
50 const self = @fieldParentPtr(*Fmt, "step", step);50 const self: *Fmt = @fieldParentPtr("step", step);
5151
52 var argv: std.ArrayListUnmanaged([]const u8) = .{};52 var argv: std.ArrayListUnmanaged([]const u8) = .{};
53 try argv.ensureUnusedCapacity(arena, 2 + 1 + self.paths.len + 2 * self.exclude_paths.len);53 try argv.ensureUnusedCapacity(arena, 2 + 1 + self.paths.len + 2 * self.exclude_paths.len);
lib/std/Build/Step/InstallArtifact.zig+1-1
...@@ -121,7 +121,7 @@ pub fn create(owner: *std.Build, artifact: *Step.Compile, options: Options) *Ins...@@ -121,7 +121,7 @@ pub fn create(owner: *std.Build, artifact: *Step.Compile, options: Options) *Ins
121121
122fn make(step: *Step, prog_node: *std.Progress.Node) !void {122fn make(step: *Step, prog_node: *std.Progress.Node) !void {
123 _ = prog_node;123 _ = prog_node;
124 const self = @fieldParentPtr(*InstallArtifact, "step", step);124 const self: *InstallArtifact = @fieldParentPtr("step", step);
125 const dest_builder = step.owner;125 const dest_builder = step.owner;
126 const cwd = fs.cwd();126 const cwd = fs.cwd();
127127
lib/std/Build/Step/InstallDir.zig+1-1
...@@ -63,7 +63,7 @@ pub fn create(owner: *std.Build, options: Options) *InstallDirStep {...@@ -63,7 +63,7 @@ pub fn create(owner: *std.Build, options: Options) *InstallDirStep {
6363
64fn make(step: *Step, prog_node: *std.Progress.Node) !void {64fn make(step: *Step, prog_node: *std.Progress.Node) !void {
65 _ = prog_node;65 _ = prog_node;
66 const self = @fieldParentPtr(*InstallDirStep, "step", step);66 const self: *InstallDirStep = @fieldParentPtr("step", step);
67 const dest_builder = self.dest_builder;67 const dest_builder = self.dest_builder;
68 const arena = dest_builder.allocator;68 const arena = dest_builder.allocator;
69 const dest_prefix = dest_builder.getInstallPath(self.options.install_dir, self.options.install_subdir);69 const dest_prefix = dest_builder.getInstallPath(self.options.install_dir, self.options.install_subdir);
lib/std/Build/Step/InstallFile.zig+1-1
...@@ -43,7 +43,7 @@ pub fn create(...@@ -43,7 +43,7 @@ pub fn create(
43fn make(step: *Step, prog_node: *std.Progress.Node) !void {43fn make(step: *Step, prog_node: *std.Progress.Node) !void {
44 _ = prog_node;44 _ = prog_node;
45 const src_builder = step.owner;45 const src_builder = step.owner;
46 const self = @fieldParentPtr(*InstallFile, "step", step);46 const self: *InstallFile = @fieldParentPtr("step", step);
47 const dest_builder = self.dest_builder;47 const dest_builder = self.dest_builder;
48 const full_src_path = self.source.getPath2(src_builder, step);48 const full_src_path = self.source.getPath2(src_builder, step);
49 const full_dest_path = dest_builder.getInstallPath(self.dir, self.dest_rel_path);49 const full_dest_path = dest_builder.getInstallPath(self.dir, self.dest_rel_path);
lib/std/Build/Step/ObjCopy.zig+1-1
...@@ -92,7 +92,7 @@ pub fn getOutputSeparatedDebug(self: *const ObjCopy) ?std.Build.LazyPath {...@@ -92,7 +92,7 @@ pub fn getOutputSeparatedDebug(self: *const ObjCopy) ?std.Build.LazyPath {
9292
93fn make(step: *Step, prog_node: *std.Progress.Node) !void {93fn make(step: *Step, prog_node: *std.Progress.Node) !void {
94 const b = step.owner;94 const b = step.owner;
95 const self = @fieldParentPtr(*ObjCopy, "step", step);95 const self: *ObjCopy = @fieldParentPtr("step", step);
9696
97 var man = b.graph.cache.obtain();97 var man = b.graph.cache.obtain();
98 defer man.deinit();98 defer man.deinit();
lib/std/Build/Step/Options.zig+1-1
...@@ -415,7 +415,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -415,7 +415,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
415 _ = prog_node;415 _ = prog_node;
416416
417 const b = step.owner;417 const b = step.owner;
418 const self = @fieldParentPtr(*Options, "step", step);418 const self: *Options = @fieldParentPtr("step", step);
419419
420 for (self.args.items) |item| {420 for (self.args.items) |item| {
421 self.addOption(421 self.addOption(
lib/std/Build/Step/RemoveDir.zig+1-1
...@@ -28,7 +28,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -28,7 +28,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
28 _ = prog_node;28 _ = prog_node;
2929
30 const b = step.owner;30 const b = step.owner;
31 const self = @fieldParentPtr(*RemoveDir, "step", step);31 const self: *RemoveDir = @fieldParentPtr("step", step);
3232
33 b.build_root.handle.deleteTree(self.dir_path) catch |err| {33 b.build_root.handle.deleteTree(self.dir_path) catch |err| {
34 if (b.build_root.path) |base| {34 if (b.build_root.path) |base| {
lib/std/Build/Step/Run.zig+1-1
...@@ -497,7 +497,7 @@ const IndexedOutput = struct {...@@ -497,7 +497,7 @@ const IndexedOutput = struct {
497fn make(step: *Step, prog_node: *std.Progress.Node) !void {497fn make(step: *Step, prog_node: *std.Progress.Node) !void {
498 const b = step.owner;498 const b = step.owner;
499 const arena = b.allocator;499 const arena = b.allocator;
500 const self = @fieldParentPtr(*Run, "step", step);500 const self: *Run = @fieldParentPtr("step", step);
501 const has_side_effects = self.hasSideEffects();501 const has_side_effects = self.hasSideEffects();
502502
503 var argv_list = ArrayList([]const u8).init(arena);503 var argv_list = ArrayList([]const u8).init(arena);
lib/std/Build/Step/TranslateC.zig+1-1
...@@ -118,7 +118,7 @@ pub fn defineCMacroRaw(self: *TranslateC, name_and_value: []const u8) void {...@@ -118,7 +118,7 @@ pub fn defineCMacroRaw(self: *TranslateC, name_and_value: []const u8) void {
118118
119fn make(step: *Step, prog_node: *std.Progress.Node) !void {119fn make(step: *Step, prog_node: *std.Progress.Node) !void {
120 const b = step.owner;120 const b = step.owner;
121 const self = @fieldParentPtr(*TranslateC, "step", step);121 const self: *TranslateC = @fieldParentPtr("step", step);
122122
123 var argv_list = std.ArrayList([]const u8).init(b.allocator);123 var argv_list = std.ArrayList([]const u8).init(b.allocator);
124 try argv_list.append(b.graph.zig_exe);124 try argv_list.append(b.graph.zig_exe);
lib/std/Build/Step/WriteFile.zig+1-1
...@@ -141,7 +141,7 @@ fn maybeUpdateName(wf: *WriteFile) void {...@@ -141,7 +141,7 @@ fn maybeUpdateName(wf: *WriteFile) void {
141fn make(step: *Step, prog_node: *std.Progress.Node) !void {141fn make(step: *Step, prog_node: *std.Progress.Node) !void {
142 _ = prog_node;142 _ = prog_node;
143 const b = step.owner;143 const b = step.owner;
144 const wf = @fieldParentPtr(*WriteFile, "step", step);144 const wf: *WriteFile = @fieldParentPtr("step", step);
145145
146 // Writing to source files is kind of an extra capability of this146 // Writing to source files is kind of an extra capability of this
147 // WriteFile - arguably it should be a different step. But anyway here147 // WriteFile - arguably it should be a different step. But anyway here
lib/std/Thread/Futex.zig+3-3
...@@ -644,7 +644,7 @@ const PosixImpl = struct {...@@ -644,7 +644,7 @@ const PosixImpl = struct {
644 };644 };
645645
646 // There's a wait queue on the address; get the queue head and tail.646 // There's a wait queue on the address; get the queue head and tail.
647 const head = @fieldParentPtr(Waiter, "node", entry_node);647 const head: *Waiter = @fieldParentPtr("node", entry_node);
648 const tail = head.tail orelse unreachable;648 const tail = head.tail orelse unreachable;
649649
650 // Push the waiter to the tail by replacing it and linking to the previous tail.650 // Push the waiter to the tail by replacing it and linking to the previous tail.
...@@ -656,7 +656,7 @@ const PosixImpl = struct {...@@ -656,7 +656,7 @@ const PosixImpl = struct {
656 fn remove(treap: *Treap, address: usize, max_waiters: usize) WaitList {656 fn remove(treap: *Treap, address: usize, max_waiters: usize) WaitList {
657 // Find the wait queue associated with this address and get the head/tail if any.657 // Find the wait queue associated with this address and get the head/tail if any.
658 var entry = treap.getEntryFor(address);658 var entry = treap.getEntryFor(address);
659 var queue_head = if (entry.node) |node| @fieldParentPtr(Waiter, "node", node) else null;659 var queue_head: ?*Waiter = if (entry.node) |node| @fieldParentPtr("node", node) else null;
660 const queue_tail = if (queue_head) |head| head.tail else null;660 const queue_tail = if (queue_head) |head| head.tail else null;
661661
662 // Once we're done updating the head, fix it's tail pointer and update the treap's queue head as well.662 // Once we're done updating the head, fix it's tail pointer and update the treap's queue head as well.
...@@ -699,7 +699,7 @@ const PosixImpl = struct {...@@ -699,7 +699,7 @@ const PosixImpl = struct {
699 };699 };
700700
701 // The queue head and tail must exist if we're removing a queued waiter.701 // The queue head and tail must exist if we're removing a queued waiter.
702 const head = @fieldParentPtr(Waiter, "node", entry.node orelse unreachable);702 const head: *Waiter = @fieldParentPtr("node", entry.node orelse unreachable);
703 const tail = head.tail orelse unreachable;703 const tail = head.tail orelse unreachable;
704704
705 // A waiter with a previous link is never the head of the queue.705 // A waiter with a previous link is never the head of the queue.
lib/std/Thread/Pool.zig+2-2
...@@ -88,8 +88,8 @@ pub fn spawn(pool: *Pool, comptime func: anytype, args: anytype) !void {...@@ -88,8 +88,8 @@ pub fn spawn(pool: *Pool, comptime func: anytype, args: anytype) !void {
88 run_node: RunQueue.Node = .{ .data = .{ .runFn = runFn } },88 run_node: RunQueue.Node = .{ .data = .{ .runFn = runFn } },
8989
90 fn runFn(runnable: *Runnable) void {90 fn runFn(runnable: *Runnable) void {
91 const run_node = @fieldParentPtr(*RunQueue.Node, "data", runnable);91 const run_node: *RunQueue.Node = @fieldParentPtr("data", runnable);
92 const closure = @fieldParentPtr(*@This(), "run_node", run_node);92 const closure: *@This() = @fieldParentPtr("run_node", run_node);
93 @call(.auto, func, closure.arguments);93 @call(.auto, func, closure.arguments);
9494
95 // The thread pool's allocator is protected by the mutex.95 // The thread pool's allocator is protected by the mutex.
lib/std/http/Client.zig+1-1
...@@ -108,7 +108,7 @@ pub const ConnectionPool = struct {...@@ -108,7 +108,7 @@ pub const ConnectionPool = struct {
108 pool.mutex.lock();108 pool.mutex.lock();
109 defer pool.mutex.unlock();109 defer pool.mutex.unlock();
110110
111 const node = @fieldParentPtr(*Node, "data", connection);111 const node: *Node = @fieldParentPtr("data", connection);
112112
113 pool.used.remove(node);113 pool.used.remove(node);
114114
lib/std/zig.zig+1
...@@ -1021,4 +1021,5 @@ test {...@@ -1021,4 +1021,5 @@ test {
1021 _ = string_literal;1021 _ = string_literal;
1022 _ = system;1022 _ = system;
1023 _ = target;1023 _ = target;
1024 _ = c_translation;
1024}1025}
lib/std/zig/AstGen.zig+3-3
...@@ -11715,20 +11715,20 @@ const Scope = struct {...@@ -11715,20 +11715,20 @@ const Scope = struct {
11715 fn cast(base: *Scope, comptime T: type) ?*T {11715 fn cast(base: *Scope, comptime T: type) ?*T {
11716 if (T == Defer) {11716 if (T == Defer) {
11717 switch (base.tag) {11717 switch (base.tag) {
11718 .defer_normal, .defer_error => return @alignCast(@fieldParentPtr(*align(1) T, "base", base)),11718 .defer_normal, .defer_error => return @alignCast(@fieldParentPtr("base", base)),
11719 else => return null,11719 else => return null,
11720 }11720 }
11721 }11721 }
11722 if (T == Namespace) {11722 if (T == Namespace) {
11723 switch (base.tag) {11723 switch (base.tag) {
11724 .namespace => return @alignCast(@fieldParentPtr(*align(1) T, "base", base)),11724 .namespace => return @alignCast(@fieldParentPtr("base", base)),
11725 else => return null,11725 else => return null,
11726 }11726 }
11727 }11727 }
11728 if (base.tag != T.base_tag)11728 if (base.tag != T.base_tag)
11729 return null;11729 return null;
1173011730
11731 return @alignCast(@fieldParentPtr(*align(1) T, "base", base));11731 return @alignCast(@fieldParentPtr("base", base));
11732 }11732 }
1173311733
11734 fn parent(base: *Scope) ?*Scope {11734 fn parent(base: *Scope) ?*Scope {
lib/std/zig/c_translation.zig+1-1
...@@ -414,7 +414,7 @@ pub const Macros = struct {...@@ -414,7 +414,7 @@ pub const Macros = struct {
414 }414 }
415415
416 pub fn WL_CONTAINER_OF(ptr: anytype, sample: anytype, comptime member: []const u8) @TypeOf(sample) {416 pub fn WL_CONTAINER_OF(ptr: anytype, sample: anytype, comptime member: []const u8) @TypeOf(sample) {
417 return @fieldParentPtr(@TypeOf(sample), member, ptr);417 return @fieldParentPtr(member, ptr);
418 }418 }
419419
420 /// A 2-argument function-like macro defined as #define FOO(A, B) (A)(B)420 /// A 2-argument function-like macro defined as #define FOO(A, B) (A)(B)
src/Module.zig+2-2
...@@ -299,7 +299,7 @@ const ValueArena = struct {...@@ -299,7 +299,7 @@ const ValueArena = struct {
299 /// and must live until the matching call to release().299 /// and must live until the matching call to release().
300 pub fn acquire(self: *ValueArena, child_allocator: Allocator, out_arena_allocator: *std.heap.ArenaAllocator) Allocator {300 pub fn acquire(self: *ValueArena, child_allocator: Allocator, out_arena_allocator: *std.heap.ArenaAllocator) Allocator {
301 if (self.state_acquired) |state_acquired| {301 if (self.state_acquired) |state_acquired| {
302 return @fieldParentPtr(std.heap.ArenaAllocator, "state", state_acquired).allocator();302 return @as(*std.heap.ArenaAllocator, @fieldParentPtr("state", state_acquired)).allocator();
303 }303 }
304304
305 out_arena_allocator.* = self.state.promote(child_allocator);305 out_arena_allocator.* = self.state.promote(child_allocator);
...@@ -309,7 +309,7 @@ const ValueArena = struct {...@@ -309,7 +309,7 @@ const ValueArena = struct {
309309
310 /// Releases the allocator acquired by `acquire. `arena_allocator` must match the one passed to `acquire`.310 /// Releases the allocator acquired by `acquire. `arena_allocator` must match the one passed to `acquire`.
311 pub fn release(self: *ValueArena, arena_allocator: *std.heap.ArenaAllocator) void {311 pub fn release(self: *ValueArena, arena_allocator: *std.heap.ArenaAllocator) void {
312 if (@fieldParentPtr(std.heap.ArenaAllocator, "state", self.state_acquired.?) == arena_allocator) {312 if (@as(*std.heap.ArenaAllocator, @fieldParentPtr("state", self.state_acquired.?)) == arena_allocator) {
313 self.state = self.state_acquired.?.*;313 self.state = self.state_acquired.?.*;
314 self.state_acquired = null;314 self.state_acquired = null;
315 }315 }
src/link.zig+31-64
...@@ -188,15 +188,10 @@ pub const File = struct {...@@ -188,15 +188,10 @@ pub const File = struct {
188 emit: Compilation.Emit,188 emit: Compilation.Emit,
189 options: OpenOptions,189 options: OpenOptions,
190 ) !*File {190 ) !*File {
191 const tag = Tag.fromObjectFormat(comp.root_mod.resolved_target.result.ofmt);191 switch (Tag.fromObjectFormat(comp.root_mod.resolved_target.result.ofmt)) {
192 switch (tag) {192 inline else => |tag| {
193 .c => {193 if (tag != .c and build_options.only_c) unreachable;
194 const ptr = try C.open(arena, comp, emit, options);194 const ptr = try tag.Type().open(arena, comp, emit, options);
195 return &ptr.base;
196 },
197 inline else => |t| {
198 if (build_options.only_c) unreachable;
199 const ptr = try t.Type().open(arena, comp, emit, options);
200 return &ptr.base;195 return &ptr.base;
201 },196 },
202 }197 }
...@@ -208,25 +203,17 @@ pub const File = struct {...@@ -208,25 +203,17 @@ pub const File = struct {
208 emit: Compilation.Emit,203 emit: Compilation.Emit,
209 options: OpenOptions,204 options: OpenOptions,
210 ) !*File {205 ) !*File {
211 const tag = Tag.fromObjectFormat(comp.root_mod.resolved_target.result.ofmt);206 switch (Tag.fromObjectFormat(comp.root_mod.resolved_target.result.ofmt)) {
212 switch (tag) {207 inline else => |tag| {
213 .c => {208 if (tag != .c and build_options.only_c) unreachable;
214 const ptr = try C.createEmpty(arena, comp, emit, options);209 const ptr = try tag.Type().createEmpty(arena, comp, emit, options);
215 return &ptr.base;
216 },
217 inline else => |t| {
218 if (build_options.only_c) unreachable;
219 const ptr = try t.Type().createEmpty(arena, comp, emit, options);
220 return &ptr.base;210 return &ptr.base;
221 },211 },
222 }212 }
223 }213 }
224214
225 pub fn cast(base: *File, comptime T: type) ?*T {215 pub fn cast(base: *File, comptime T: type) ?*T {
226 if (base.tag != T.base_tag)216 return if (base.tag == T.base_tag) @fieldParentPtr("base", base) else null;
227 return null;
228
229 return @fieldParentPtr(*T, "base", base);
230 }217 }
231218
232 pub fn makeWritable(base: *File) !void {219 pub fn makeWritable(base: *File) !void {
...@@ -383,7 +370,7 @@ pub const File = struct {...@@ -383,7 +370,7 @@ pub const File = struct {
383 .c => unreachable,370 .c => unreachable,
384 .nvptx => unreachable,371 .nvptx => unreachable,
385 inline else => |t| {372 inline else => |t| {
386 return @fieldParentPtr(*t.Type(), "base", base).lowerUnnamedConst(val, decl_index);373 return @as(*t.Type(), @fieldParentPtr("base", base)).lowerUnnamedConst(val, decl_index);
387 },374 },
388 }375 }
389 }376 }
...@@ -402,7 +389,7 @@ pub const File = struct {...@@ -402,7 +389,7 @@ pub const File = struct {
402 .c => unreachable,389 .c => unreachable,
403 .nvptx => unreachable,390 .nvptx => unreachable,
404 inline else => |t| {391 inline else => |t| {
405 return @fieldParentPtr(*t.Type(), "base", base).getGlobalSymbol(name, lib_name);392 return @as(*t.Type(), @fieldParentPtr("base", base)).getGlobalSymbol(name, lib_name);
406 },393 },
407 }394 }
408 }395 }
...@@ -412,12 +399,9 @@ pub const File = struct {...@@ -412,12 +399,9 @@ pub const File = struct {
412 const decl = module.declPtr(decl_index);399 const decl = module.declPtr(decl_index);
413 assert(decl.has_tv);400 assert(decl.has_tv);
414 switch (base.tag) {401 switch (base.tag) {
415 .c => {
416 return @fieldParentPtr(*C, "base", base).updateDecl(module, decl_index);
417 },
418 inline else => |tag| {402 inline else => |tag| {
419 if (build_options.only_c) unreachable;403 if (tag != .c and build_options.only_c) unreachable;
420 return @fieldParentPtr(*tag.Type(), "base", base).updateDecl(module, decl_index);404 return @as(*tag.Type(), @fieldParentPtr("base", base)).updateDecl(module, decl_index);
421 },405 },
422 }406 }
423 }407 }
...@@ -431,12 +415,9 @@ pub const File = struct {...@@ -431,12 +415,9 @@ pub const File = struct {
431 liveness: Liveness,415 liveness: Liveness,
432 ) UpdateDeclError!void {416 ) UpdateDeclError!void {
433 switch (base.tag) {417 switch (base.tag) {
434 .c => {
435 return @fieldParentPtr(*C, "base", base).updateFunc(module, func_index, air, liveness);
436 },
437 inline else => |tag| {418 inline else => |tag| {
438 if (build_options.only_c) unreachable;419 if (tag != .c and build_options.only_c) unreachable;
439 return @fieldParentPtr(*tag.Type(), "base", base).updateFunc(module, func_index, air, liveness);420 return @as(*tag.Type(), @fieldParentPtr("base", base)).updateFunc(module, func_index, air, liveness);
440 },421 },
441 }422 }
442 }423 }
...@@ -446,12 +427,9 @@ pub const File = struct {...@@ -446,12 +427,9 @@ pub const File = struct {
446 assert(decl.has_tv);427 assert(decl.has_tv);
447 switch (base.tag) {428 switch (base.tag) {
448 .spirv, .nvptx => {},429 .spirv, .nvptx => {},
449 .c => {
450 return @fieldParentPtr(*C, "base", base).updateDeclLineNumber(module, decl_index);
451 },
452 inline else => |tag| {430 inline else => |tag| {
453 if (build_options.only_c) unreachable;431 if (tag != .c and build_options.only_c) unreachable;
454 return @fieldParentPtr(*tag.Type(), "base", base).updateDeclLineNumber(module, decl_index);432 return @as(*tag.Type(), @fieldParentPtr("base", base)).updateDeclLineNumber(module, decl_index);
455 },433 },
456 }434 }
457 }435 }
...@@ -473,11 +451,9 @@ pub const File = struct {...@@ -473,11 +451,9 @@ pub const File = struct {
473 base.releaseLock();451 base.releaseLock();
474 if (base.file) |f| f.close();452 if (base.file) |f| f.close();
475 switch (base.tag) {453 switch (base.tag) {
476 .c => @fieldParentPtr(*C, "base", base).deinit(),
477
478 inline else => |tag| {454 inline else => |tag| {
479 if (build_options.only_c) unreachable;455 if (tag != .c and build_options.only_c) unreachable;
480 @fieldParentPtr(*tag.Type(), "base", base).deinit();456 @as(*tag.Type(), @fieldParentPtr("base", base)).deinit();
481 },457 },
482 }458 }
483 }459 }
...@@ -560,7 +536,7 @@ pub const File = struct {...@@ -560,7 +536,7 @@ pub const File = struct {
560 pub fn flush(base: *File, arena: Allocator, prog_node: *std.Progress.Node) FlushError!void {536 pub fn flush(base: *File, arena: Allocator, prog_node: *std.Progress.Node) FlushError!void {
561 if (build_options.only_c) {537 if (build_options.only_c) {
562 assert(base.tag == .c);538 assert(base.tag == .c);
563 return @fieldParentPtr(*C, "base", base).flush(arena, prog_node);539 return @as(*C, @fieldParentPtr("base", base)).flush(arena, prog_node);
564 }540 }
565 const comp = base.comp;541 const comp = base.comp;
566 if (comp.clang_preprocessor_mode == .yes or comp.clang_preprocessor_mode == .pch) {542 if (comp.clang_preprocessor_mode == .yes or comp.clang_preprocessor_mode == .pch) {
...@@ -587,7 +563,7 @@ pub const File = struct {...@@ -587,7 +563,7 @@ pub const File = struct {
587 }563 }
588 switch (base.tag) {564 switch (base.tag) {
589 inline else => |tag| {565 inline else => |tag| {
590 return @fieldParentPtr(*tag.Type(), "base", base).flush(arena, prog_node);566 return @as(*tag.Type(), @fieldParentPtr("base", base)).flush(arena, prog_node);
591 },567 },
592 }568 }
593 }569 }
...@@ -596,12 +572,9 @@ pub const File = struct {...@@ -596,12 +572,9 @@ pub const File = struct {
596 /// rather than final output mode.572 /// rather than final output mode.
597 pub fn flushModule(base: *File, arena: Allocator, prog_node: *std.Progress.Node) FlushError!void {573 pub fn flushModule(base: *File, arena: Allocator, prog_node: *std.Progress.Node) FlushError!void {
598 switch (base.tag) {574 switch (base.tag) {
599 .c => {
600 return @fieldParentPtr(*C, "base", base).flushModule(arena, prog_node);
601 },
602 inline else => |tag| {575 inline else => |tag| {
603 if (build_options.only_c) unreachable;576 if (tag != .c and build_options.only_c) unreachable;
604 return @fieldParentPtr(*tag.Type(), "base", base).flushModule(arena, prog_node);577 return @as(*tag.Type(), @fieldParentPtr("base", base)).flushModule(arena, prog_node);
605 },578 },
606 }579 }
607 }580 }
...@@ -609,12 +582,9 @@ pub const File = struct {...@@ -609,12 +582,9 @@ pub const File = struct {
609 /// Called when a Decl is deleted from the Module.582 /// Called when a Decl is deleted from the Module.
610 pub fn freeDecl(base: *File, decl_index: InternPool.DeclIndex) void {583 pub fn freeDecl(base: *File, decl_index: InternPool.DeclIndex) void {
611 switch (base.tag) {584 switch (base.tag) {
612 .c => {
613 @fieldParentPtr(*C, "base", base).freeDecl(decl_index);
614 },
615 inline else => |tag| {585 inline else => |tag| {
616 if (build_options.only_c) unreachable;586 if (tag != .c and build_options.only_c) unreachable;
617 @fieldParentPtr(*tag.Type(), "base", base).freeDecl(decl_index);587 @as(*tag.Type(), @fieldParentPtr("base", base)).freeDecl(decl_index);
618 },588 },
619 }589 }
620 }590 }
...@@ -635,12 +605,9 @@ pub const File = struct {...@@ -635,12 +605,9 @@ pub const File = struct {
635 exports: []const *Module.Export,605 exports: []const *Module.Export,
636 ) UpdateExportsError!void {606 ) UpdateExportsError!void {
637 switch (base.tag) {607 switch (base.tag) {
638 .c => {
639 return @fieldParentPtr(*C, "base", base).updateExports(module, exported, exports);
640 },
641 inline else => |tag| {608 inline else => |tag| {
642 if (build_options.only_c) unreachable;609 if (tag != .c and build_options.only_c) unreachable;
643 return @fieldParentPtr(*tag.Type(), "base", base).updateExports(module, exported, exports);610 return @as(*tag.Type(), @fieldParentPtr("base", base)).updateExports(module, exported, exports);
644 },611 },
645 }612 }
646 }613 }
...@@ -664,7 +631,7 @@ pub const File = struct {...@@ -664,7 +631,7 @@ pub const File = struct {
664 .spirv => unreachable,631 .spirv => unreachable,
665 .nvptx => unreachable,632 .nvptx => unreachable,
666 inline else => |tag| {633 inline else => |tag| {
667 return @fieldParentPtr(*tag.Type(), "base", base).getDeclVAddr(decl_index, reloc_info);634 return @as(*tag.Type(), @fieldParentPtr("base", base)).getDeclVAddr(decl_index, reloc_info);
668 },635 },
669 }636 }
670 }637 }
...@@ -683,7 +650,7 @@ pub const File = struct {...@@ -683,7 +650,7 @@ pub const File = struct {
683 .spirv => unreachable,650 .spirv => unreachable,
684 .nvptx => unreachable,651 .nvptx => unreachable,
685 inline else => |tag| {652 inline else => |tag| {
686 return @fieldParentPtr(*tag.Type(), "base", base).lowerAnonDecl(decl_val, decl_align, src_loc);653 return @as(*tag.Type(), @fieldParentPtr("base", base)).lowerAnonDecl(decl_val, decl_align, src_loc);
687 },654 },
688 }655 }
689 }656 }
...@@ -695,7 +662,7 @@ pub const File = struct {...@@ -695,7 +662,7 @@ pub const File = struct {
695 .spirv => unreachable,662 .spirv => unreachable,
696 .nvptx => unreachable,663 .nvptx => unreachable,
697 inline else => |tag| {664 inline else => |tag| {
698 return @fieldParentPtr(*tag.Type(), "base", base).getAnonDeclVAddr(decl_val, reloc_info);665 return @as(*tag.Type(), @fieldParentPtr("base", base)).getAnonDeclVAddr(decl_val, reloc_info);
699 },666 },
700 }667 }
701 }668 }
...@@ -714,7 +681,7 @@ pub const File = struct {...@@ -714,7 +681,7 @@ pub const File = struct {
714 => {},681 => {},
715682
716 inline else => |tag| {683 inline else => |tag| {
717 return @fieldParentPtr(*tag.Type(), "base", base).deleteDeclExport(decl_index, name);684 return @as(*tag.Type(), @fieldParentPtr("base", base)).deleteDeclExport(decl_index, name);
718 },685 },
719 }686 }
720 }687 }
src/link/tapi/parse.zig+15-24
...@@ -29,34 +29,28 @@ pub const Node = struct {...@@ -29,34 +29,28 @@ pub const Node = struct {
29 map,29 map,
30 list,30 list,
31 value,31 value,
32
33 pub fn Type(comptime tag: Tag) type {
34 return switch (tag) {
35 .doc => Doc,
36 .map => Map,
37 .list => List,
38 .value => Value,
39 };
40 }
32 };41 };
3342
34 pub fn cast(self: *const Node, comptime T: type) ?*const T {43 pub fn cast(self: *const Node, comptime T: type) ?*const T {
35 if (self.tag != T.base_tag) {44 if (self.tag != T.base_tag) {
36 return null;45 return null;
37 }46 }
38 return @fieldParentPtr(*const T, "base", self);47 return @fieldParentPtr("base", self);
39 }48 }
4049
41 pub fn deinit(self: *Node, allocator: Allocator) void {50 pub fn deinit(self: *Node, allocator: Allocator) void {
42 switch (self.tag) {51 switch (self.tag) {
43 .doc => {52 inline else => |tag| {
44 const parent = @fieldParentPtr(*Node.Doc, "base", self);53 const parent: *tag.Type() = @fieldParentPtr("base", self);
45 parent.deinit(allocator);
46 allocator.destroy(parent);
47 },
48 .map => {
49 const parent = @fieldParentPtr(*Node.Map, "base", self);
50 parent.deinit(allocator);
51 allocator.destroy(parent);
52 },
53 .list => {
54 const parent = @fieldParentPtr(*Node.List, "base", self);
55 parent.deinit(allocator);
56 allocator.destroy(parent);
57 },
58 .value => {
59 const parent = @fieldParentPtr(*Node.Value, "base", self);
60 parent.deinit(allocator);54 parent.deinit(allocator);
61 allocator.destroy(parent);55 allocator.destroy(parent);
62 },56 },
...@@ -69,12 +63,9 @@ pub const Node = struct {...@@ -69,12 +63,9 @@ pub const Node = struct {
69 options: std.fmt.FormatOptions,63 options: std.fmt.FormatOptions,
70 writer: anytype,64 writer: anytype,
71 ) !void {65 ) !void {
72 return switch (self.tag) {66 switch (self.tag) {
73 .doc => @fieldParentPtr(*Node.Doc, "base", self).format(fmt, options, writer),67 inline else => |tag| return @as(*tag.Type(), @fieldParentPtr("base", self)).format(fmt, options, writer),
74 .map => @fieldParentPtr(*Node.Map, "base", self).format(fmt, options, writer),68 }
75 .list => @fieldParentPtr(*Node.List, "base", self).format(fmt, options, writer),
76 .value => @fieldParentPtr(*Node.Value, "base", self).format(fmt, options, writer),
77 };
78 }69 }
7970
80 pub const Doc = struct {71 pub const Doc = struct {
src/register_manager.zig+1-1
...@@ -59,7 +59,7 @@ pub fn RegisterManager(...@@ -59,7 +59,7 @@ pub fn RegisterManager(
59 pub const RegisterBitSet = StaticBitSet(tracked_registers.len);59 pub const RegisterBitSet = StaticBitSet(tracked_registers.len);
6060
61 fn getFunction(self: *Self) *Function {61 fn getFunction(self: *Self) *Function {
62 return @alignCast(@fieldParentPtr(*align(1) Function, "register_manager", self));62 return @alignCast(@fieldParentPtr("register_manager", self));
63 }63 }
6464
65 fn excludeRegister(reg: Register, register_class: RegisterBitSet) bool {65 fn excludeRegister(reg: Register, register_class: RegisterBitSet) bool {
test/behavior/align.zig+1-1
...@@ -693,5 +693,5 @@ test "zero-bit fields in extern struct pad fields appropriately" {...@@ -693,5 +693,5 @@ test "zero-bit fields in extern struct pad fields appropriately" {
693 try expect(@intFromPtr(&s) % 2 == 0);693 try expect(@intFromPtr(&s) % 2 == 0);
694 try expect(@intFromPtr(&s.y) - @intFromPtr(&s.x) == 2);694 try expect(@intFromPtr(&s.y) - @intFromPtr(&s.x) == 2);
695 try expect(@intFromPtr(&s.y) == @intFromPtr(&s.a));695 try expect(@intFromPtr(&s.y) == @intFromPtr(&s.a));
696 try expect(@fieldParentPtr(*S, "a", &s.a) == &s);696 try expect(@as(*S, @fieldParentPtr("a", &s.a)) == &s);
697}697}
test/behavior/field_parent_ptr.zig+232-232
...@@ -12,14 +12,14 @@ test "@fieldParentPtr struct" {...@@ -12,14 +12,14 @@ test "@fieldParentPtr struct" {
12 {12 {
13 const c: C = .{ .a = false };13 const c: C = .{ .a = false };
14 const pcf = &c.a;14 const pcf = &c.a;
15 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));15 const pc: *const C = @alignCast(@fieldParentPtr("a", pcf));
16 try expect(pc == &c);16 try expect(pc == &c);
17 }17 }
18 {18 {
19 const c: C = .{ .a = false };19 const c: C = .{ .a = false };
20 const pcf = &c.a;20 const pcf = &c.a;
21 var pc: *const C = undefined;21 var pc: *const C = undefined;
22 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));22 pc = @alignCast(@fieldParentPtr("a", pcf));
23 try expect(pc == &c);23 try expect(pc == &c);
24 }24 }
25 {25 {
...@@ -27,7 +27,7 @@ test "@fieldParentPtr struct" {...@@ -27,7 +27,7 @@ test "@fieldParentPtr struct" {
27 var pcf: @TypeOf(&c.a) = undefined;27 var pcf: @TypeOf(&c.a) = undefined;
28 pcf = &c.a;28 pcf = &c.a;
29 var pc: *const C = undefined;29 var pc: *const C = undefined;
30 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));30 pc = @alignCast(@fieldParentPtr("a", pcf));
31 try expect(pc == &c);31 try expect(pc == &c);
32 }32 }
33 {33 {
...@@ -36,21 +36,21 @@ test "@fieldParentPtr struct" {...@@ -36,21 +36,21 @@ test "@fieldParentPtr struct" {
36 var pcf: @TypeOf(&c.a) = undefined;36 var pcf: @TypeOf(&c.a) = undefined;
37 pcf = &c.a;37 pcf = &c.a;
38 var pc: *C = undefined;38 var pc: *C = undefined;
39 pc = @alignCast(@fieldParentPtr(*align(1) C, "a", pcf));39 pc = @alignCast(@fieldParentPtr("a", pcf));
40 try expect(pc == &c);40 try expect(pc == &c);
41 }41 }
4242
43 {43 {
44 const c: C = .{ .b = 666.667 };44 const c: C = .{ .b = 666.667 };
45 const pcf = &c.b;45 const pcf = &c.b;
46 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));46 const pc: *const C = @alignCast(@fieldParentPtr("b", pcf));
47 try expect(pc == &c);47 try expect(pc == &c);
48 }48 }
49 {49 {
50 const c: C = .{ .b = 666.667 };50 const c: C = .{ .b = 666.667 };
51 const pcf = &c.b;51 const pcf = &c.b;
52 var pc: *const C = undefined;52 var pc: *const C = undefined;
53 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));53 pc = @alignCast(@fieldParentPtr("b", pcf));
54 try expect(pc == &c);54 try expect(pc == &c);
55 }55 }
56 {56 {
...@@ -58,7 +58,7 @@ test "@fieldParentPtr struct" {...@@ -58,7 +58,7 @@ test "@fieldParentPtr struct" {
58 var pcf: @TypeOf(&c.b) = undefined;58 var pcf: @TypeOf(&c.b) = undefined;
59 pcf = &c.b;59 pcf = &c.b;
60 var pc: *const C = undefined;60 var pc: *const C = undefined;
61 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));61 pc = @alignCast(@fieldParentPtr("b", pcf));
62 try expect(pc == &c);62 try expect(pc == &c);
63 }63 }
64 {64 {
...@@ -67,21 +67,21 @@ test "@fieldParentPtr struct" {...@@ -67,21 +67,21 @@ test "@fieldParentPtr struct" {
67 var pcf: @TypeOf(&c.b) = undefined;67 var pcf: @TypeOf(&c.b) = undefined;
68 pcf = &c.b;68 pcf = &c.b;
69 var pc: *C = undefined;69 var pc: *C = undefined;
70 pc = @alignCast(@fieldParentPtr(*align(1) C, "b", pcf));70 pc = @alignCast(@fieldParentPtr("b", pcf));
71 try expect(pc == &c);71 try expect(pc == &c);
72 }72 }
7373
74 {74 {
75 const c: C = .{ .c = .{255} };75 const c: C = .{ .c = .{255} };
76 const pcf = &c.c;76 const pcf = &c.c;
77 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));77 const pc: *const C = @alignCast(@fieldParentPtr("c", pcf));
78 try expect(pc == &c);78 try expect(pc == &c);
79 }79 }
80 {80 {
81 const c: C = .{ .c = .{255} };81 const c: C = .{ .c = .{255} };
82 const pcf = &c.c;82 const pcf = &c.c;
83 var pc: *const C = undefined;83 var pc: *const C = undefined;
84 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));84 pc = @alignCast(@fieldParentPtr("c", pcf));
85 try expect(pc == &c);85 try expect(pc == &c);
86 }86 }
87 {87 {
...@@ -89,7 +89,7 @@ test "@fieldParentPtr struct" {...@@ -89,7 +89,7 @@ test "@fieldParentPtr struct" {
89 var pcf: @TypeOf(&c.c) = undefined;89 var pcf: @TypeOf(&c.c) = undefined;
90 pcf = &c.c;90 pcf = &c.c;
91 var pc: *const C = undefined;91 var pc: *const C = undefined;
92 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));92 pc = @alignCast(@fieldParentPtr("c", pcf));
93 try expect(pc == &c);93 try expect(pc == &c);
94 }94 }
95 {95 {
...@@ -98,21 +98,21 @@ test "@fieldParentPtr struct" {...@@ -98,21 +98,21 @@ test "@fieldParentPtr struct" {
98 var pcf: @TypeOf(&c.c) = undefined;98 var pcf: @TypeOf(&c.c) = undefined;
99 pcf = &c.c;99 pcf = &c.c;
100 var pc: *C = undefined;100 var pc: *C = undefined;
101 pc = @alignCast(@fieldParentPtr(*align(1) C, "c", pcf));101 pc = @alignCast(@fieldParentPtr("c", pcf));
102 try expect(pc == &c);102 try expect(pc == &c);
103 }103 }
104104
105 {105 {
106 const c: C = .{ .d = -1111111111 };106 const c: C = .{ .d = -1111111111 };
107 const pcf = &c.d;107 const pcf = &c.d;
108 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));108 const pc: *const C = @alignCast(@fieldParentPtr("d", pcf));
109 try expect(pc == &c);109 try expect(pc == &c);
110 }110 }
111 {111 {
112 const c: C = .{ .d = -1111111111 };112 const c: C = .{ .d = -1111111111 };
113 const pcf = &c.d;113 const pcf = &c.d;
114 var pc: *const C = undefined;114 var pc: *const C = undefined;
115 pc = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));115 pc = @alignCast(@fieldParentPtr("d", pcf));
116 try expect(pc == &c);116 try expect(pc == &c);
117 }117 }
118 {118 {
...@@ -120,7 +120,7 @@ test "@fieldParentPtr struct" {...@@ -120,7 +120,7 @@ test "@fieldParentPtr struct" {
120 var pcf: @TypeOf(&c.d) = undefined;120 var pcf: @TypeOf(&c.d) = undefined;
121 pcf = &c.d;121 pcf = &c.d;
122 var pc: *const C = undefined;122 var pc: *const C = undefined;
123 pc = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));123 pc = @alignCast(@fieldParentPtr("d", pcf));
124 try expect(pc == &c);124 try expect(pc == &c);
125 }125 }
126 {126 {
...@@ -129,7 +129,7 @@ test "@fieldParentPtr struct" {...@@ -129,7 +129,7 @@ test "@fieldParentPtr struct" {
129 var pcf: @TypeOf(&c.d) = undefined;129 var pcf: @TypeOf(&c.d) = undefined;
130 pcf = &c.d;130 pcf = &c.d;
131 var pc: *C = undefined;131 var pc: *C = undefined;
132 pc = @alignCast(@fieldParentPtr(*align(1) C, "d", pcf));132 pc = @alignCast(@fieldParentPtr("d", pcf));
133 try expect(pc == &c);133 try expect(pc == &c);
134 }134 }
135}135}
...@@ -145,14 +145,14 @@ test "@fieldParentPtr extern struct" {...@@ -145,14 +145,14 @@ test "@fieldParentPtr extern struct" {
145 {145 {
146 const c: C = .{ .a = false };146 const c: C = .{ .a = false };
147 const pcf = &c.a;147 const pcf = &c.a;
148 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));148 const pc: *const C = @alignCast(@fieldParentPtr("a", pcf));
149 try expect(pc == &c);149 try expect(pc == &c);
150 }150 }
151 {151 {
152 const c: C = .{ .a = false };152 const c: C = .{ .a = false };
153 const pcf = &c.a;153 const pcf = &c.a;
154 var pc: *const C = undefined;154 var pc: *const C = undefined;
155 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));155 pc = @alignCast(@fieldParentPtr("a", pcf));
156 try expect(pc == &c);156 try expect(pc == &c);
157 }157 }
158 {158 {
...@@ -160,7 +160,7 @@ test "@fieldParentPtr extern struct" {...@@ -160,7 +160,7 @@ test "@fieldParentPtr extern struct" {
160 var pcf: @TypeOf(&c.a) = undefined;160 var pcf: @TypeOf(&c.a) = undefined;
161 pcf = &c.a;161 pcf = &c.a;
162 var pc: *const C = undefined;162 var pc: *const C = undefined;
163 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));163 pc = @alignCast(@fieldParentPtr("a", pcf));
164 try expect(pc == &c);164 try expect(pc == &c);
165 }165 }
166 {166 {
...@@ -169,21 +169,21 @@ test "@fieldParentPtr extern struct" {...@@ -169,21 +169,21 @@ test "@fieldParentPtr extern struct" {
169 var pcf: @TypeOf(&c.a) = undefined;169 var pcf: @TypeOf(&c.a) = undefined;
170 pcf = &c.a;170 pcf = &c.a;
171 var pc: *C = undefined;171 var pc: *C = undefined;
172 pc = @alignCast(@fieldParentPtr(*align(1) C, "a", pcf));172 pc = @alignCast(@fieldParentPtr("a", pcf));
173 try expect(pc == &c);173 try expect(pc == &c);
174 }174 }
175175
176 {176 {
177 const c: C = .{ .b = 666.667 };177 const c: C = .{ .b = 666.667 };
178 const pcf = &c.b;178 const pcf = &c.b;
179 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));179 const pc: *const C = @alignCast(@fieldParentPtr("b", pcf));
180 try expect(pc == &c);180 try expect(pc == &c);
181 }181 }
182 {182 {
183 const c: C = .{ .b = 666.667 };183 const c: C = .{ .b = 666.667 };
184 const pcf = &c.b;184 const pcf = &c.b;
185 var pc: *const C = undefined;185 var pc: *const C = undefined;
186 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));186 pc = @alignCast(@fieldParentPtr("b", pcf));
187 try expect(pc == &c);187 try expect(pc == &c);
188 }188 }
189 {189 {
...@@ -191,7 +191,7 @@ test "@fieldParentPtr extern struct" {...@@ -191,7 +191,7 @@ test "@fieldParentPtr extern struct" {
191 var pcf: @TypeOf(&c.b) = undefined;191 var pcf: @TypeOf(&c.b) = undefined;
192 pcf = &c.b;192 pcf = &c.b;
193 var pc: *const C = undefined;193 var pc: *const C = undefined;
194 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));194 pc = @alignCast(@fieldParentPtr("b", pcf));
195 try expect(pc == &c);195 try expect(pc == &c);
196 }196 }
197 {197 {
...@@ -200,21 +200,21 @@ test "@fieldParentPtr extern struct" {...@@ -200,21 +200,21 @@ test "@fieldParentPtr extern struct" {
200 var pcf: @TypeOf(&c.b) = undefined;200 var pcf: @TypeOf(&c.b) = undefined;
201 pcf = &c.b;201 pcf = &c.b;
202 var pc: *C = undefined;202 var pc: *C = undefined;
203 pc = @alignCast(@fieldParentPtr(*align(1) C, "b", pcf));203 pc = @alignCast(@fieldParentPtr("b", pcf));
204 try expect(pc == &c);204 try expect(pc == &c);
205 }205 }
206206
207 {207 {
208 const c: C = .{ .c = .{ .x = 255 } };208 const c: C = .{ .c = .{ .x = 255 } };
209 const pcf = &c.c;209 const pcf = &c.c;
210 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));210 const pc: *const C = @alignCast(@fieldParentPtr("c", pcf));
211 try expect(pc == &c);211 try expect(pc == &c);
212 }212 }
213 {213 {
214 const c: C = .{ .c = .{ .x = 255 } };214 const c: C = .{ .c = .{ .x = 255 } };
215 const pcf = &c.c;215 const pcf = &c.c;
216 var pc: *const C = undefined;216 var pc: *const C = undefined;
217 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));217 pc = @alignCast(@fieldParentPtr("c", pcf));
218 try expect(pc == &c);218 try expect(pc == &c);
219 }219 }
220 {220 {
...@@ -222,7 +222,7 @@ test "@fieldParentPtr extern struct" {...@@ -222,7 +222,7 @@ test "@fieldParentPtr extern struct" {
222 var pcf: @TypeOf(&c.c) = undefined;222 var pcf: @TypeOf(&c.c) = undefined;
223 pcf = &c.c;223 pcf = &c.c;
224 var pc: *const C = undefined;224 var pc: *const C = undefined;
225 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));225 pc = @alignCast(@fieldParentPtr("c", pcf));
226 try expect(pc == &c);226 try expect(pc == &c);
227 }227 }
228 {228 {
...@@ -231,21 +231,21 @@ test "@fieldParentPtr extern struct" {...@@ -231,21 +231,21 @@ test "@fieldParentPtr extern struct" {
231 var pcf: @TypeOf(&c.c) = undefined;231 var pcf: @TypeOf(&c.c) = undefined;
232 pcf = &c.c;232 pcf = &c.c;
233 var pc: *C = undefined;233 var pc: *C = undefined;
234 pc = @alignCast(@fieldParentPtr(*align(1) C, "c", pcf));234 pc = @alignCast(@fieldParentPtr("c", pcf));
235 try expect(pc == &c);235 try expect(pc == &c);
236 }236 }
237237
238 {238 {
239 const c: C = .{ .d = -1111111111 };239 const c: C = .{ .d = -1111111111 };
240 const pcf = &c.d;240 const pcf = &c.d;
241 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));241 const pc: *const C = @alignCast(@fieldParentPtr("d", pcf));
242 try expect(pc == &c);242 try expect(pc == &c);
243 }243 }
244 {244 {
245 const c: C = .{ .d = -1111111111 };245 const c: C = .{ .d = -1111111111 };
246 const pcf = &c.d;246 const pcf = &c.d;
247 var pc: *const C = undefined;247 var pc: *const C = undefined;
248 pc = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));248 pc = @alignCast(@fieldParentPtr("d", pcf));
249 try expect(pc == &c);249 try expect(pc == &c);
250 }250 }
251 {251 {
...@@ -253,7 +253,7 @@ test "@fieldParentPtr extern struct" {...@@ -253,7 +253,7 @@ test "@fieldParentPtr extern struct" {
253 var pcf: @TypeOf(&c.d) = undefined;253 var pcf: @TypeOf(&c.d) = undefined;
254 pcf = &c.d;254 pcf = &c.d;
255 var pc: *const C = undefined;255 var pc: *const C = undefined;
256 pc = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));256 pc = @alignCast(@fieldParentPtr("d", pcf));
257 try expect(pc == &c);257 try expect(pc == &c);
258 }258 }
259 {259 {
...@@ -262,7 +262,7 @@ test "@fieldParentPtr extern struct" {...@@ -262,7 +262,7 @@ test "@fieldParentPtr extern struct" {
262 var pcf: @TypeOf(&c.d) = undefined;262 var pcf: @TypeOf(&c.d) = undefined;
263 pcf = &c.d;263 pcf = &c.d;
264 var pc: *C = undefined;264 var pc: *C = undefined;
265 pc = @alignCast(@fieldParentPtr(*align(1) C, "d", pcf));265 pc = @alignCast(@fieldParentPtr("d", pcf));
266 try expect(pc == &c);266 try expect(pc == &c);
267 }267 }
268}268}
...@@ -277,14 +277,14 @@ test "@fieldParentPtr extern struct first zero-bit field" {...@@ -277,14 +277,14 @@ test "@fieldParentPtr extern struct first zero-bit field" {
277 {277 {
278 const c: C = .{ .a = 0 };278 const c: C = .{ .a = 0 };
279 const pcf = &c.a;279 const pcf = &c.a;
280 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));280 const pc: *const C = @alignCast(@fieldParentPtr("a", pcf));
281 try expect(pc == &c);281 try expect(pc == &c);
282 }282 }
283 {283 {
284 const c: C = .{ .a = 0 };284 const c: C = .{ .a = 0 };
285 const pcf = &c.a;285 const pcf = &c.a;
286 var pc: *const C = undefined;286 var pc: *const C = undefined;
287 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));287 pc = @alignCast(@fieldParentPtr("a", pcf));
288 try expect(pc == &c);288 try expect(pc == &c);
289 }289 }
290 {290 {
...@@ -292,7 +292,7 @@ test "@fieldParentPtr extern struct first zero-bit field" {...@@ -292,7 +292,7 @@ test "@fieldParentPtr extern struct first zero-bit field" {
292 var pcf: @TypeOf(&c.a) = undefined;292 var pcf: @TypeOf(&c.a) = undefined;
293 pcf = &c.a;293 pcf = &c.a;
294 var pc: *const C = undefined;294 var pc: *const C = undefined;
295 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));295 pc = @alignCast(@fieldParentPtr("a", pcf));
296 try expect(pc == &c);296 try expect(pc == &c);
297 }297 }
298 {298 {
...@@ -301,21 +301,21 @@ test "@fieldParentPtr extern struct first zero-bit field" {...@@ -301,21 +301,21 @@ test "@fieldParentPtr extern struct first zero-bit field" {
301 var pcf: @TypeOf(&c.a) = undefined;301 var pcf: @TypeOf(&c.a) = undefined;
302 pcf = &c.a;302 pcf = &c.a;
303 var pc: *C = undefined;303 var pc: *C = undefined;
304 pc = @alignCast(@fieldParentPtr(*align(1) C, "a", pcf));304 pc = @alignCast(@fieldParentPtr("a", pcf));
305 try expect(pc == &c);305 try expect(pc == &c);
306 }306 }
307307
308 {308 {
309 const c: C = .{ .b = 666.667 };309 const c: C = .{ .b = 666.667 };
310 const pcf = &c.b;310 const pcf = &c.b;
311 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));311 const pc: *const C = @alignCast(@fieldParentPtr("b", pcf));
312 try expect(pc == &c);312 try expect(pc == &c);
313 }313 }
314 {314 {
315 const c: C = .{ .b = 666.667 };315 const c: C = .{ .b = 666.667 };
316 const pcf = &c.b;316 const pcf = &c.b;
317 var pc: *const C = undefined;317 var pc: *const C = undefined;
318 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));318 pc = @alignCast(@fieldParentPtr("b", pcf));
319 try expect(pc == &c);319 try expect(pc == &c);
320 }320 }
321 {321 {
...@@ -323,7 +323,7 @@ test "@fieldParentPtr extern struct first zero-bit field" {...@@ -323,7 +323,7 @@ test "@fieldParentPtr extern struct first zero-bit field" {
323 var pcf: @TypeOf(&c.b) = undefined;323 var pcf: @TypeOf(&c.b) = undefined;
324 pcf = &c.b;324 pcf = &c.b;
325 var pc: *const C = undefined;325 var pc: *const C = undefined;
326 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));326 pc = @alignCast(@fieldParentPtr("b", pcf));
327 try expect(pc == &c);327 try expect(pc == &c);
328 }328 }
329 {329 {
...@@ -332,21 +332,21 @@ test "@fieldParentPtr extern struct first zero-bit field" {...@@ -332,21 +332,21 @@ test "@fieldParentPtr extern struct first zero-bit field" {
332 var pcf: @TypeOf(&c.b) = undefined;332 var pcf: @TypeOf(&c.b) = undefined;
333 pcf = &c.b;333 pcf = &c.b;
334 var pc: *C = undefined;334 var pc: *C = undefined;
335 pc = @alignCast(@fieldParentPtr(*align(1) C, "b", pcf));335 pc = @alignCast(@fieldParentPtr("b", pcf));
336 try expect(pc == &c);336 try expect(pc == &c);
337 }337 }
338338
339 {339 {
340 const c: C = .{ .c = -1111111111 };340 const c: C = .{ .c = -1111111111 };
341 const pcf = &c.c;341 const pcf = &c.c;
342 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));342 const pc: *const C = @alignCast(@fieldParentPtr("c", pcf));
343 try expect(pc == &c);343 try expect(pc == &c);
344 }344 }
345 {345 {
346 const c: C = .{ .c = -1111111111 };346 const c: C = .{ .c = -1111111111 };
347 const pcf = &c.c;347 const pcf = &c.c;
348 var pc: *const C = undefined;348 var pc: *const C = undefined;
349 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));349 pc = @alignCast(@fieldParentPtr("c", pcf));
350 try expect(pc == &c);350 try expect(pc == &c);
351 }351 }
352 {352 {
...@@ -354,7 +354,7 @@ test "@fieldParentPtr extern struct first zero-bit field" {...@@ -354,7 +354,7 @@ test "@fieldParentPtr extern struct first zero-bit field" {
354 var pcf: @TypeOf(&c.c) = undefined;354 var pcf: @TypeOf(&c.c) = undefined;
355 pcf = &c.c;355 pcf = &c.c;
356 var pc: *const C = undefined;356 var pc: *const C = undefined;
357 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));357 pc = @alignCast(@fieldParentPtr("c", pcf));
358 try expect(pc == &c);358 try expect(pc == &c);
359 }359 }
360 {360 {
...@@ -363,7 +363,7 @@ test "@fieldParentPtr extern struct first zero-bit field" {...@@ -363,7 +363,7 @@ test "@fieldParentPtr extern struct first zero-bit field" {
363 var pcf: @TypeOf(&c.c) = undefined;363 var pcf: @TypeOf(&c.c) = undefined;
364 pcf = &c.c;364 pcf = &c.c;
365 var pc: *C = undefined;365 var pc: *C = undefined;
366 pc = @alignCast(@fieldParentPtr(*align(1) C, "c", pcf));366 pc = @alignCast(@fieldParentPtr("c", pcf));
367 try expect(pc == &c);367 try expect(pc == &c);
368 }368 }
369}369}
...@@ -378,14 +378,14 @@ test "@fieldParentPtr extern struct middle zero-bit field" {...@@ -378,14 +378,14 @@ test "@fieldParentPtr extern struct middle zero-bit field" {
378 {378 {
379 const c: C = .{ .a = 666.667 };379 const c: C = .{ .a = 666.667 };
380 const pcf = &c.a;380 const pcf = &c.a;
381 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));381 const pc: *const C = @alignCast(@fieldParentPtr("a", pcf));
382 try expect(pc == &c);382 try expect(pc == &c);
383 }383 }
384 {384 {
385 const c: C = .{ .a = 666.667 };385 const c: C = .{ .a = 666.667 };
386 const pcf = &c.a;386 const pcf = &c.a;
387 var pc: *const C = undefined;387 var pc: *const C = undefined;
388 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));388 pc = @alignCast(@fieldParentPtr("a", pcf));
389 try expect(pc == &c);389 try expect(pc == &c);
390 }390 }
391 {391 {
...@@ -393,7 +393,7 @@ test "@fieldParentPtr extern struct middle zero-bit field" {...@@ -393,7 +393,7 @@ test "@fieldParentPtr extern struct middle zero-bit field" {
393 var pcf: @TypeOf(&c.a) = undefined;393 var pcf: @TypeOf(&c.a) = undefined;
394 pcf = &c.a;394 pcf = &c.a;
395 var pc: *const C = undefined;395 var pc: *const C = undefined;
396 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));396 pc = @alignCast(@fieldParentPtr("a", pcf));
397 try expect(pc == &c);397 try expect(pc == &c);
398 }398 }
399 {399 {
...@@ -402,21 +402,21 @@ test "@fieldParentPtr extern struct middle zero-bit field" {...@@ -402,21 +402,21 @@ test "@fieldParentPtr extern struct middle zero-bit field" {
402 var pcf: @TypeOf(&c.a) = undefined;402 var pcf: @TypeOf(&c.a) = undefined;
403 pcf = &c.a;403 pcf = &c.a;
404 var pc: *C = undefined;404 var pc: *C = undefined;
405 pc = @alignCast(@fieldParentPtr(*align(1) C, "a", pcf));405 pc = @alignCast(@fieldParentPtr("a", pcf));
406 try expect(pc == &c);406 try expect(pc == &c);
407 }407 }
408408
409 {409 {
410 const c: C = .{ .b = 0 };410 const c: C = .{ .b = 0 };
411 const pcf = &c.b;411 const pcf = &c.b;
412 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));412 const pc: *const C = @alignCast(@fieldParentPtr("b", pcf));
413 try expect(pc == &c);413 try expect(pc == &c);
414 }414 }
415 {415 {
416 const c: C = .{ .b = 0 };416 const c: C = .{ .b = 0 };
417 const pcf = &c.b;417 const pcf = &c.b;
418 var pc: *const C = undefined;418 var pc: *const C = undefined;
419 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));419 pc = @alignCast(@fieldParentPtr("b", pcf));
420 try expect(pc == &c);420 try expect(pc == &c);
421 }421 }
422 {422 {
...@@ -424,7 +424,7 @@ test "@fieldParentPtr extern struct middle zero-bit field" {...@@ -424,7 +424,7 @@ test "@fieldParentPtr extern struct middle zero-bit field" {
424 var pcf: @TypeOf(&c.b) = undefined;424 var pcf: @TypeOf(&c.b) = undefined;
425 pcf = &c.b;425 pcf = &c.b;
426 var pc: *const C = undefined;426 var pc: *const C = undefined;
427 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));427 pc = @alignCast(@fieldParentPtr("b", pcf));
428 try expect(pc == &c);428 try expect(pc == &c);
429 }429 }
430 {430 {
...@@ -433,21 +433,21 @@ test "@fieldParentPtr extern struct middle zero-bit field" {...@@ -433,21 +433,21 @@ test "@fieldParentPtr extern struct middle zero-bit field" {
433 var pcf: @TypeOf(&c.b) = undefined;433 var pcf: @TypeOf(&c.b) = undefined;
434 pcf = &c.b;434 pcf = &c.b;
435 var pc: *C = undefined;435 var pc: *C = undefined;
436 pc = @alignCast(@fieldParentPtr(*align(1) C, "b", pcf));436 pc = @alignCast(@fieldParentPtr("b", pcf));
437 try expect(pc == &c);437 try expect(pc == &c);
438 }438 }
439439
440 {440 {
441 const c: C = .{ .c = -1111111111 };441 const c: C = .{ .c = -1111111111 };
442 const pcf = &c.c;442 const pcf = &c.c;
443 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));443 const pc: *const C = @alignCast(@fieldParentPtr("c", pcf));
444 try expect(pc == &c);444 try expect(pc == &c);
445 }445 }
446 {446 {
447 const c: C = .{ .c = -1111111111 };447 const c: C = .{ .c = -1111111111 };
448 const pcf = &c.c;448 const pcf = &c.c;
449 var pc: *const C = undefined;449 var pc: *const C = undefined;
450 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));450 pc = @alignCast(@fieldParentPtr("c", pcf));
451 try expect(pc == &c);451 try expect(pc == &c);
452 }452 }
453 {453 {
...@@ -455,7 +455,7 @@ test "@fieldParentPtr extern struct middle zero-bit field" {...@@ -455,7 +455,7 @@ test "@fieldParentPtr extern struct middle zero-bit field" {
455 var pcf: @TypeOf(&c.c) = undefined;455 var pcf: @TypeOf(&c.c) = undefined;
456 pcf = &c.c;456 pcf = &c.c;
457 var pc: *const C = undefined;457 var pc: *const C = undefined;
458 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));458 pc = @alignCast(@fieldParentPtr("c", pcf));
459 try expect(pc == &c);459 try expect(pc == &c);
460 }460 }
461 {461 {
...@@ -464,7 +464,7 @@ test "@fieldParentPtr extern struct middle zero-bit field" {...@@ -464,7 +464,7 @@ test "@fieldParentPtr extern struct middle zero-bit field" {
464 var pcf: @TypeOf(&c.c) = undefined;464 var pcf: @TypeOf(&c.c) = undefined;
465 pcf = &c.c;465 pcf = &c.c;
466 var pc: *C = undefined;466 var pc: *C = undefined;
467 pc = @alignCast(@fieldParentPtr(*align(1) C, "c", pcf));467 pc = @alignCast(@fieldParentPtr("c", pcf));
468 try expect(pc == &c);468 try expect(pc == &c);
469 }469 }
470}470}
...@@ -479,14 +479,14 @@ test "@fieldParentPtr extern struct last zero-bit field" {...@@ -479,14 +479,14 @@ test "@fieldParentPtr extern struct last zero-bit field" {
479 {479 {
480 const c: C = .{ .a = 666.667 };480 const c: C = .{ .a = 666.667 };
481 const pcf = &c.a;481 const pcf = &c.a;
482 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));482 const pc: *const C = @alignCast(@fieldParentPtr("a", pcf));
483 try expect(pc == &c);483 try expect(pc == &c);
484 }484 }
485 {485 {
486 const c: C = .{ .a = 666.667 };486 const c: C = .{ .a = 666.667 };
487 const pcf = &c.a;487 const pcf = &c.a;
488 var pc: *const C = undefined;488 var pc: *const C = undefined;
489 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));489 pc = @alignCast(@fieldParentPtr("a", pcf));
490 try expect(pc == &c);490 try expect(pc == &c);
491 }491 }
492 {492 {
...@@ -494,7 +494,7 @@ test "@fieldParentPtr extern struct last zero-bit field" {...@@ -494,7 +494,7 @@ test "@fieldParentPtr extern struct last zero-bit field" {
494 var pcf: @TypeOf(&c.a) = undefined;494 var pcf: @TypeOf(&c.a) = undefined;
495 pcf = &c.a;495 pcf = &c.a;
496 var pc: *const C = undefined;496 var pc: *const C = undefined;
497 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));497 pc = @alignCast(@fieldParentPtr("a", pcf));
498 try expect(pc == &c);498 try expect(pc == &c);
499 }499 }
500 {500 {
...@@ -503,21 +503,21 @@ test "@fieldParentPtr extern struct last zero-bit field" {...@@ -503,21 +503,21 @@ test "@fieldParentPtr extern struct last zero-bit field" {
503 var pcf: @TypeOf(&c.a) = undefined;503 var pcf: @TypeOf(&c.a) = undefined;
504 pcf = &c.a;504 pcf = &c.a;
505 var pc: *C = undefined;505 var pc: *C = undefined;
506 pc = @alignCast(@fieldParentPtr(*align(1) C, "a", pcf));506 pc = @alignCast(@fieldParentPtr("a", pcf));
507 try expect(pc == &c);507 try expect(pc == &c);
508 }508 }
509509
510 {510 {
511 const c: C = .{ .b = -1111111111 };511 const c: C = .{ .b = -1111111111 };
512 const pcf = &c.b;512 const pcf = &c.b;
513 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));513 const pc: *const C = @alignCast(@fieldParentPtr("b", pcf));
514 try expect(pc == &c);514 try expect(pc == &c);
515 }515 }
516 {516 {
517 const c: C = .{ .b = -1111111111 };517 const c: C = .{ .b = -1111111111 };
518 const pcf = &c.b;518 const pcf = &c.b;
519 var pc: *const C = undefined;519 var pc: *const C = undefined;
520 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));520 pc = @alignCast(@fieldParentPtr("b", pcf));
521 try expect(pc == &c);521 try expect(pc == &c);
522 }522 }
523 {523 {
...@@ -525,7 +525,7 @@ test "@fieldParentPtr extern struct last zero-bit field" {...@@ -525,7 +525,7 @@ test "@fieldParentPtr extern struct last zero-bit field" {
525 var pcf: @TypeOf(&c.b) = undefined;525 var pcf: @TypeOf(&c.b) = undefined;
526 pcf = &c.b;526 pcf = &c.b;
527 var pc: *const C = undefined;527 var pc: *const C = undefined;
528 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));528 pc = @alignCast(@fieldParentPtr("b", pcf));
529 try expect(pc == &c);529 try expect(pc == &c);
530 }530 }
531 {531 {
...@@ -534,21 +534,21 @@ test "@fieldParentPtr extern struct last zero-bit field" {...@@ -534,21 +534,21 @@ test "@fieldParentPtr extern struct last zero-bit field" {
534 var pcf: @TypeOf(&c.b) = undefined;534 var pcf: @TypeOf(&c.b) = undefined;
535 pcf = &c.b;535 pcf = &c.b;
536 var pc: *C = undefined;536 var pc: *C = undefined;
537 pc = @alignCast(@fieldParentPtr(*align(1) C, "b", pcf));537 pc = @alignCast(@fieldParentPtr("b", pcf));
538 try expect(pc == &c);538 try expect(pc == &c);
539 }539 }
540540
541 {541 {
542 const c: C = .{ .c = 0 };542 const c: C = .{ .c = 0 };
543 const pcf = &c.c;543 const pcf = &c.c;
544 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));544 const pc: *const C = @alignCast(@fieldParentPtr("c", pcf));
545 try expect(pc == &c);545 try expect(pc == &c);
546 }546 }
547 {547 {
548 const c: C = .{ .c = 0 };548 const c: C = .{ .c = 0 };
549 const pcf = &c.c;549 const pcf = &c.c;
550 var pc: *const C = undefined;550 var pc: *const C = undefined;
551 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));551 pc = @alignCast(@fieldParentPtr("c", pcf));
552 try expect(pc == &c);552 try expect(pc == &c);
553 }553 }
554 {554 {
...@@ -556,7 +556,7 @@ test "@fieldParentPtr extern struct last zero-bit field" {...@@ -556,7 +556,7 @@ test "@fieldParentPtr extern struct last zero-bit field" {
556 var pcf: @TypeOf(&c.c) = undefined;556 var pcf: @TypeOf(&c.c) = undefined;
557 pcf = &c.c;557 pcf = &c.c;
558 var pc: *const C = undefined;558 var pc: *const C = undefined;
559 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));559 pc = @alignCast(@fieldParentPtr("c", pcf));
560 try expect(pc == &c);560 try expect(pc == &c);
561 }561 }
562 {562 {
...@@ -565,7 +565,7 @@ test "@fieldParentPtr extern struct last zero-bit field" {...@@ -565,7 +565,7 @@ test "@fieldParentPtr extern struct last zero-bit field" {
565 var pcf: @TypeOf(&c.c) = undefined;565 var pcf: @TypeOf(&c.c) = undefined;
566 pcf = &c.c;566 pcf = &c.c;
567 var pc: *C = undefined;567 var pc: *C = undefined;
568 pc = @alignCast(@fieldParentPtr(*align(1) C, "c", pcf));568 pc = @alignCast(@fieldParentPtr("c", pcf));
569 try expect(pc == &c);569 try expect(pc == &c);
570 }570 }
571}571}
...@@ -585,14 +585,14 @@ test "@fieldParentPtr unaligned packed struct" {...@@ -585,14 +585,14 @@ test "@fieldParentPtr unaligned packed struct" {
585 {585 {
586 const c: C = .{ .a = false };586 const c: C = .{ .a = false };
587 const pcf = &c.a;587 const pcf = &c.a;
588 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));588 const pc: *const C = @alignCast(@fieldParentPtr("a", pcf));
589 try expect(pc == &c);589 try expect(pc == &c);
590 }590 }
591 {591 {
592 const c: C = .{ .a = false };592 const c: C = .{ .a = false };
593 const pcf = &c.a;593 const pcf = &c.a;
594 var pc: *const C = undefined;594 var pc: *const C = undefined;
595 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));595 pc = @alignCast(@fieldParentPtr("a", pcf));
596 try expect(pc == &c);596 try expect(pc == &c);
597 }597 }
598 {598 {
...@@ -600,7 +600,7 @@ test "@fieldParentPtr unaligned packed struct" {...@@ -600,7 +600,7 @@ test "@fieldParentPtr unaligned packed struct" {
600 var pcf: @TypeOf(&c.a) = undefined;600 var pcf: @TypeOf(&c.a) = undefined;
601 pcf = &c.a;601 pcf = &c.a;
602 var pc: *const C = undefined;602 var pc: *const C = undefined;
603 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));603 pc = @alignCast(@fieldParentPtr("a", pcf));
604 try expect(pc == &c);604 try expect(pc == &c);
605 }605 }
606 {606 {
...@@ -609,21 +609,21 @@ test "@fieldParentPtr unaligned packed struct" {...@@ -609,21 +609,21 @@ test "@fieldParentPtr unaligned packed struct" {
609 var pcf: @TypeOf(&c.a) = undefined;609 var pcf: @TypeOf(&c.a) = undefined;
610 pcf = &c.a;610 pcf = &c.a;
611 var pc: *C = undefined;611 var pc: *C = undefined;
612 pc = @alignCast(@fieldParentPtr(*align(1) C, "a", pcf));612 pc = @alignCast(@fieldParentPtr("a", pcf));
613 try expect(pc == &c);613 try expect(pc == &c);
614 }614 }
615615
616 {616 {
617 const c: C = .{ .b = 666.667 };617 const c: C = .{ .b = 666.667 };
618 const pcf = &c.b;618 const pcf = &c.b;
619 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));619 const pc: *const C = @alignCast(@fieldParentPtr("b", pcf));
620 try expect(pc == &c);620 try expect(pc == &c);
621 }621 }
622 {622 {
623 const c: C = .{ .b = 666.667 };623 const c: C = .{ .b = 666.667 };
624 const pcf = &c.b;624 const pcf = &c.b;
625 var pc: *const C = undefined;625 var pc: *const C = undefined;
626 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));626 pc = @alignCast(@fieldParentPtr("b", pcf));
627 try expect(pc == &c);627 try expect(pc == &c);
628 }628 }
629 {629 {
...@@ -631,7 +631,7 @@ test "@fieldParentPtr unaligned packed struct" {...@@ -631,7 +631,7 @@ test "@fieldParentPtr unaligned packed struct" {
631 var pcf: @TypeOf(&c.b) = undefined;631 var pcf: @TypeOf(&c.b) = undefined;
632 pcf = &c.b;632 pcf = &c.b;
633 var pc: *const C = undefined;633 var pc: *const C = undefined;
634 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));634 pc = @alignCast(@fieldParentPtr("b", pcf));
635 try expect(pc == &c);635 try expect(pc == &c);
636 }636 }
637 {637 {
...@@ -640,21 +640,21 @@ test "@fieldParentPtr unaligned packed struct" {...@@ -640,21 +640,21 @@ test "@fieldParentPtr unaligned packed struct" {
640 var pcf: @TypeOf(&c.b) = undefined;640 var pcf: @TypeOf(&c.b) = undefined;
641 pcf = &c.b;641 pcf = &c.b;
642 var pc: *C = undefined;642 var pc: *C = undefined;
643 pc = @alignCast(@fieldParentPtr(*align(1) C, "b", pcf));643 pc = @alignCast(@fieldParentPtr("b", pcf));
644 try expect(pc == &c);644 try expect(pc == &c);
645 }645 }
646646
647 {647 {
648 const c: C = .{ .c = .{ .x = 255 } };648 const c: C = .{ .c = .{ .x = 255 } };
649 const pcf = &c.c;649 const pcf = &c.c;
650 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));650 const pc: *const C = @alignCast(@fieldParentPtr("c", pcf));
651 try expect(pc == &c);651 try expect(pc == &c);
652 }652 }
653 {653 {
654 const c: C = .{ .c = .{ .x = 255 } };654 const c: C = .{ .c = .{ .x = 255 } };
655 const pcf = &c.c;655 const pcf = &c.c;
656 var pc: *const C = undefined;656 var pc: *const C = undefined;
657 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));657 pc = @alignCast(@fieldParentPtr("c", pcf));
658 try expect(pc == &c);658 try expect(pc == &c);
659 }659 }
660 {660 {
...@@ -662,7 +662,7 @@ test "@fieldParentPtr unaligned packed struct" {...@@ -662,7 +662,7 @@ test "@fieldParentPtr unaligned packed struct" {
662 var pcf: @TypeOf(&c.c) = undefined;662 var pcf: @TypeOf(&c.c) = undefined;
663 pcf = &c.c;663 pcf = &c.c;
664 var pc: *const C = undefined;664 var pc: *const C = undefined;
665 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));665 pc = @alignCast(@fieldParentPtr("c", pcf));
666 try expect(pc == &c);666 try expect(pc == &c);
667 }667 }
668 {668 {
...@@ -671,21 +671,21 @@ test "@fieldParentPtr unaligned packed struct" {...@@ -671,21 +671,21 @@ test "@fieldParentPtr unaligned packed struct" {
671 var pcf: @TypeOf(&c.c) = undefined;671 var pcf: @TypeOf(&c.c) = undefined;
672 pcf = &c.c;672 pcf = &c.c;
673 var pc: *C = undefined;673 var pc: *C = undefined;
674 pc = @alignCast(@fieldParentPtr(*align(1) C, "c", pcf));674 pc = @alignCast(@fieldParentPtr("c", pcf));
675 try expect(pc == &c);675 try expect(pc == &c);
676 }676 }
677677
678 {678 {
679 const c: C = .{ .d = -1111111111 };679 const c: C = .{ .d = -1111111111 };
680 const pcf = &c.d;680 const pcf = &c.d;
681 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));681 const pc: *const C = @alignCast(@fieldParentPtr("d", pcf));
682 try expect(pc == &c);682 try expect(pc == &c);
683 }683 }
684 {684 {
685 const c: C = .{ .d = -1111111111 };685 const c: C = .{ .d = -1111111111 };
686 const pcf = &c.d;686 const pcf = &c.d;
687 var pc: *const C = undefined;687 var pc: *const C = undefined;
688 pc = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));688 pc = @alignCast(@fieldParentPtr("d", pcf));
689 try expect(pc == &c);689 try expect(pc == &c);
690 }690 }
691 {691 {
...@@ -693,7 +693,7 @@ test "@fieldParentPtr unaligned packed struct" {...@@ -693,7 +693,7 @@ test "@fieldParentPtr unaligned packed struct" {
693 var pcf: @TypeOf(&c.d) = undefined;693 var pcf: @TypeOf(&c.d) = undefined;
694 pcf = &c.d;694 pcf = &c.d;
695 var pc: *const C = undefined;695 var pc: *const C = undefined;
696 pc = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));696 pc = @alignCast(@fieldParentPtr("d", pcf));
697 try expect(pc == &c);697 try expect(pc == &c);
698 }698 }
699 {699 {
...@@ -702,7 +702,7 @@ test "@fieldParentPtr unaligned packed struct" {...@@ -702,7 +702,7 @@ test "@fieldParentPtr unaligned packed struct" {
702 var pcf: @TypeOf(&c.d) = undefined;702 var pcf: @TypeOf(&c.d) = undefined;
703 pcf = &c.d;703 pcf = &c.d;
704 var pc: *C = undefined;704 var pc: *C = undefined;
705 pc = @alignCast(@fieldParentPtr(*align(1) C, "d", pcf));705 pc = @alignCast(@fieldParentPtr("d", pcf));
706 try expect(pc == &c);706 try expect(pc == &c);
707 }707 }
708}708}
...@@ -722,14 +722,14 @@ test "@fieldParentPtr aligned packed struct" {...@@ -722,14 +722,14 @@ test "@fieldParentPtr aligned packed struct" {
722 {722 {
723 const c: C = .{ .a = 666.667 };723 const c: C = .{ .a = 666.667 };
724 const pcf = &c.a;724 const pcf = &c.a;
725 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));725 const pc: *const C = @alignCast(@fieldParentPtr("a", pcf));
726 try expect(pc == &c);726 try expect(pc == &c);
727 }727 }
728 {728 {
729 const c: C = .{ .a = 666.667 };729 const c: C = .{ .a = 666.667 };
730 const pcf = &c.a;730 const pcf = &c.a;
731 var pc: *const C = undefined;731 var pc: *const C = undefined;
732 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));732 pc = @alignCast(@fieldParentPtr("a", pcf));
733 try expect(pc == &c);733 try expect(pc == &c);
734 }734 }
735 {735 {
...@@ -737,7 +737,7 @@ test "@fieldParentPtr aligned packed struct" {...@@ -737,7 +737,7 @@ test "@fieldParentPtr aligned packed struct" {
737 var pcf: @TypeOf(&c.a) = undefined;737 var pcf: @TypeOf(&c.a) = undefined;
738 pcf = &c.a;738 pcf = &c.a;
739 var pc: *const C = undefined;739 var pc: *const C = undefined;
740 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));740 pc = @alignCast(@fieldParentPtr("a", pcf));
741 try expect(pc == &c);741 try expect(pc == &c);
742 }742 }
743 {743 {
...@@ -746,21 +746,21 @@ test "@fieldParentPtr aligned packed struct" {...@@ -746,21 +746,21 @@ test "@fieldParentPtr aligned packed struct" {
746 var pcf: @TypeOf(&c.a) = undefined;746 var pcf: @TypeOf(&c.a) = undefined;
747 pcf = &c.a;747 pcf = &c.a;
748 var pc: *C = undefined;748 var pc: *C = undefined;
749 pc = @alignCast(@fieldParentPtr(*align(1) C, "a", pcf));749 pc = @alignCast(@fieldParentPtr("a", pcf));
750 try expect(pc == &c);750 try expect(pc == &c);
751 }751 }
752752
753 {753 {
754 const c: C = .{ .b = -1111111111 };754 const c: C = .{ .b = -1111111111 };
755 const pcf = &c.b;755 const pcf = &c.b;
756 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));756 const pc: *const C = @alignCast(@fieldParentPtr("b", pcf));
757 try expect(pc == &c);757 try expect(pc == &c);
758 }758 }
759 {759 {
760 const c: C = .{ .b = -1111111111 };760 const c: C = .{ .b = -1111111111 };
761 const pcf = &c.b;761 const pcf = &c.b;
762 var pc: *const C = undefined;762 var pc: *const C = undefined;
763 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));763 pc = @alignCast(@fieldParentPtr("b", pcf));
764 try expect(pc == &c);764 try expect(pc == &c);
765 }765 }
766 {766 {
...@@ -768,7 +768,7 @@ test "@fieldParentPtr aligned packed struct" {...@@ -768,7 +768,7 @@ test "@fieldParentPtr aligned packed struct" {
768 var pcf: @TypeOf(&c.b) = undefined;768 var pcf: @TypeOf(&c.b) = undefined;
769 pcf = &c.b;769 pcf = &c.b;
770 var pc: *const C = undefined;770 var pc: *const C = undefined;
771 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));771 pc = @alignCast(@fieldParentPtr("b", pcf));
772 try expect(pc == &c);772 try expect(pc == &c);
773 }773 }
774 {774 {
...@@ -777,21 +777,21 @@ test "@fieldParentPtr aligned packed struct" {...@@ -777,21 +777,21 @@ test "@fieldParentPtr aligned packed struct" {
777 var pcf: @TypeOf(&c.b) = undefined;777 var pcf: @TypeOf(&c.b) = undefined;
778 pcf = &c.b;778 pcf = &c.b;
779 var pc: *C = undefined;779 var pc: *C = undefined;
780 pc = @alignCast(@fieldParentPtr(*align(1) C, "b", pcf));780 pc = @alignCast(@fieldParentPtr("b", pcf));
781 try expect(pc == &c);781 try expect(pc == &c);
782 }782 }
783783
784 {784 {
785 const c: C = .{ .c = .{ .x = 255 } };785 const c: C = .{ .c = .{ .x = 255 } };
786 const pcf = &c.c;786 const pcf = &c.c;
787 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));787 const pc: *const C = @alignCast(@fieldParentPtr("c", pcf));
788 try expect(pc == &c);788 try expect(pc == &c);
789 }789 }
790 {790 {
791 const c: C = .{ .c = .{ .x = 255 } };791 const c: C = .{ .c = .{ .x = 255 } };
792 const pcf = &c.c;792 const pcf = &c.c;
793 var pc: *const C = undefined;793 var pc: *const C = undefined;
794 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));794 pc = @alignCast(@fieldParentPtr("c", pcf));
795 try expect(pc == &c);795 try expect(pc == &c);
796 }796 }
797 {797 {
...@@ -799,7 +799,7 @@ test "@fieldParentPtr aligned packed struct" {...@@ -799,7 +799,7 @@ test "@fieldParentPtr aligned packed struct" {
799 var pcf: @TypeOf(&c.c) = undefined;799 var pcf: @TypeOf(&c.c) = undefined;
800 pcf = &c.c;800 pcf = &c.c;
801 var pc: *const C = undefined;801 var pc: *const C = undefined;
802 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));802 pc = @alignCast(@fieldParentPtr("c", pcf));
803 try expect(pc == &c);803 try expect(pc == &c);
804 }804 }
805 {805 {
...@@ -808,21 +808,21 @@ test "@fieldParentPtr aligned packed struct" {...@@ -808,21 +808,21 @@ test "@fieldParentPtr aligned packed struct" {
808 var pcf: @TypeOf(&c.c) = undefined;808 var pcf: @TypeOf(&c.c) = undefined;
809 pcf = &c.c;809 pcf = &c.c;
810 var pc: *C = undefined;810 var pc: *C = undefined;
811 pc = @alignCast(@fieldParentPtr(*align(1) C, "c", pcf));811 pc = @alignCast(@fieldParentPtr("c", pcf));
812 try expect(pc == &c);812 try expect(pc == &c);
813 }813 }
814814
815 {815 {
816 const c: C = .{ .d = false };816 const c: C = .{ .d = false };
817 const pcf = &c.d;817 const pcf = &c.d;
818 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));818 const pc: *const C = @alignCast(@fieldParentPtr("d", pcf));
819 try expect(pc == &c);819 try expect(pc == &c);
820 }820 }
821 {821 {
822 const c: C = .{ .d = false };822 const c: C = .{ .d = false };
823 const pcf = &c.d;823 const pcf = &c.d;
824 var pc: *const C = undefined;824 var pc: *const C = undefined;
825 pc = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));825 pc = @alignCast(@fieldParentPtr("d", pcf));
826 try expect(pc == &c);826 try expect(pc == &c);
827 }827 }
828 {828 {
...@@ -830,7 +830,7 @@ test "@fieldParentPtr aligned packed struct" {...@@ -830,7 +830,7 @@ test "@fieldParentPtr aligned packed struct" {
830 var pcf: @TypeOf(&c.d) = undefined;830 var pcf: @TypeOf(&c.d) = undefined;
831 pcf = &c.d;831 pcf = &c.d;
832 var pc: *const C = undefined;832 var pc: *const C = undefined;
833 pc = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));833 pc = @alignCast(@fieldParentPtr("d", pcf));
834 try expect(pc == &c);834 try expect(pc == &c);
835 }835 }
836 {836 {
...@@ -839,7 +839,7 @@ test "@fieldParentPtr aligned packed struct" {...@@ -839,7 +839,7 @@ test "@fieldParentPtr aligned packed struct" {
839 var pcf: @TypeOf(&c.d) = undefined;839 var pcf: @TypeOf(&c.d) = undefined;
840 pcf = &c.d;840 pcf = &c.d;
841 var pc: *C = undefined;841 var pc: *C = undefined;
842 pc = @alignCast(@fieldParentPtr(*align(1) C, "d", pcf));842 pc = @alignCast(@fieldParentPtr("d", pcf));
843 try expect(pc == &c);843 try expect(pc == &c);
844 }844 }
845}845}
...@@ -862,11 +862,11 @@ test "@fieldParentPtr nested packed struct" {...@@ -862,11 +862,11 @@ test "@fieldParentPtr nested packed struct" {
862 {862 {
863 const c: C = .{ .a = 0, .b = .{ .a = 0, .b = .{ .a = 0 } } };863 const c: C = .{ .a = 0, .b = .{ .a = 0, .b = .{ .a = 0 } } };
864 const pcbba = &c.b.b.a;864 const pcbba = &c.b.b.a;
865 const pcbb: @TypeOf(&c.b.b) = @alignCast(@fieldParentPtr(*align(1) const @TypeOf(c.b.b), "a", pcbba));865 const pcbb: @TypeOf(&c.b.b) = @alignCast(@fieldParentPtr("a", pcbba));
866 try expect(pcbb == &c.b.b);866 try expect(pcbb == &c.b.b);
867 const pcb: @TypeOf(&c.b) = @alignCast(@fieldParentPtr(*align(1) const @TypeOf(c.b), "b", pcbb));867 const pcb: @TypeOf(&c.b) = @alignCast(@fieldParentPtr("b", pcbb));
868 try expect(pcb == &c.b);868 try expect(pcb == &c.b);
869 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcb));869 const pc: *const C = @alignCast(@fieldParentPtr("b", pcb));
870 try expect(pc == &c);870 try expect(pc == &c);
871 }871 }
872872
...@@ -876,13 +876,13 @@ test "@fieldParentPtr nested packed struct" {...@@ -876,13 +876,13 @@ test "@fieldParentPtr nested packed struct" {
876 var pcbba: @TypeOf(&c.b.b.a) = undefined;876 var pcbba: @TypeOf(&c.b.b.a) = undefined;
877 pcbba = &c.b.b.a;877 pcbba = &c.b.b.a;
878 var pcbb: @TypeOf(&c.b.b) = undefined;878 var pcbb: @TypeOf(&c.b.b) = undefined;
879 pcbb = @alignCast(@fieldParentPtr(*align(1) @TypeOf(c.b.b), "a", pcbba));879 pcbb = @alignCast(@fieldParentPtr("a", pcbba));
880 try expect(pcbb == &c.b.b);880 try expect(pcbb == &c.b.b);
881 var pcb: @TypeOf(&c.b) = undefined;881 var pcb: @TypeOf(&c.b) = undefined;
882 pcb = @alignCast(@fieldParentPtr(*align(1) @TypeOf(c.b), "b", pcbb));882 pcb = @alignCast(@fieldParentPtr("b", pcbb));
883 try expect(pcb == &c.b);883 try expect(pcb == &c.b);
884 var pc: *C = undefined;884 var pc: *C = undefined;
885 pc = @alignCast(@fieldParentPtr(*align(1) C, "b", pcb));885 pc = @alignCast(@fieldParentPtr("b", pcb));
886 try expect(pc == &c);886 try expect(pc == &c);
887 }887 }
888 }888 }
...@@ -901,11 +901,11 @@ test "@fieldParentPtr nested packed struct" {...@@ -901,11 +901,11 @@ test "@fieldParentPtr nested packed struct" {
901 {901 {
902 const c: C = .{ .a = 0, .b = .{ .a = 0, .b = .{ .a = 0 } } };902 const c: C = .{ .a = 0, .b = .{ .a = 0, .b = .{ .a = 0 } } };
903 const pcbba = &c.b.b.a;903 const pcbba = &c.b.b.a;
904 const pcbb: @TypeOf(&c.b.b) = @alignCast(@fieldParentPtr(*align(1:17:4) const @TypeOf(c.b.b), "a", pcbba));904 const pcbb: @TypeOf(&c.b.b) = @alignCast(@fieldParentPtr("a", pcbba));
905 try expect(pcbb == &c.b.b);905 try expect(pcbb == &c.b.b);
906 const pcb: @TypeOf(&c.b) = @alignCast(@fieldParentPtr(*align(1:8:4) const @TypeOf(c.b), "b", pcbb));906 const pcb: @TypeOf(&c.b) = @alignCast(@fieldParentPtr("b", pcbb));
907 try expect(pcb == &c.b);907 try expect(pcb == &c.b);
908 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcb));908 const pc: *const C = @alignCast(@fieldParentPtr("b", pcb));
909 try expect(pc == &c);909 try expect(pc == &c);
910 }910 }
911911
...@@ -915,13 +915,13 @@ test "@fieldParentPtr nested packed struct" {...@@ -915,13 +915,13 @@ test "@fieldParentPtr nested packed struct" {
915 var pcbba: @TypeOf(&c.b.b.a) = undefined;915 var pcbba: @TypeOf(&c.b.b.a) = undefined;
916 pcbba = &c.b.b.a;916 pcbba = &c.b.b.a;
917 var pcbb: @TypeOf(&c.b.b) = undefined;917 var pcbb: @TypeOf(&c.b.b) = undefined;
918 pcbb = @alignCast(@fieldParentPtr(*align(1:17:4) @TypeOf(c.b.b), "a", pcbba));918 pcbb = @alignCast(@fieldParentPtr("a", pcbba));
919 try expect(pcbb == &c.b.b);919 try expect(pcbb == &c.b.b);
920 var pcb: @TypeOf(&c.b) = undefined;920 var pcb: @TypeOf(&c.b) = undefined;
921 pcb = @alignCast(@fieldParentPtr(*align(1:8:4) @TypeOf(c.b), "b", pcbb));921 pcb = @alignCast(@fieldParentPtr("b", pcbb));
922 try expect(pcb == &c.b);922 try expect(pcb == &c.b);
923 var pc: *C = undefined;923 var pc: *C = undefined;
924 pc = @alignCast(@fieldParentPtr(*align(1) C, "b", pcb));924 pc = @alignCast(@fieldParentPtr("b", pcb));
925 try expect(pc == &c);925 try expect(pc == &c);
926 }926 }
927 }927 }
...@@ -940,11 +940,11 @@ test "@fieldParentPtr nested packed struct" {...@@ -940,11 +940,11 @@ test "@fieldParentPtr nested packed struct" {
940 {940 {
941 const c: C = .{ .a = 0, .b = .{ .a = 0, .b = .{ .a = 0 } } };941 const c: C = .{ .a = 0, .b = .{ .a = 0, .b = .{ .a = 0 } } };
942 const pcbba = &c.b.b.a;942 const pcbba = &c.b.b.a;
943 const pcbb: @TypeOf(&c.b.b) = @alignCast(@fieldParentPtr(*align(1) const @TypeOf(c.b.b), "a", pcbba));943 const pcbb: @TypeOf(&c.b.b) = @alignCast(@fieldParentPtr("a", pcbba));
944 try expect(pcbb == &c.b.b);944 try expect(pcbb == &c.b.b);
945 const pcb: @TypeOf(&c.b) = @alignCast(@fieldParentPtr(*align(1:9:3) const @TypeOf(c.b), "b", pcbb));945 const pcb: @TypeOf(&c.b) = @alignCast(@fieldParentPtr("b", pcbb));
946 try expect(pcb == &c.b);946 try expect(pcb == &c.b);
947 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcb));947 const pc: *const C = @alignCast(@fieldParentPtr("b", pcb));
948 try expect(pc == &c);948 try expect(pc == &c);
949 }949 }
950950
...@@ -954,13 +954,13 @@ test "@fieldParentPtr nested packed struct" {...@@ -954,13 +954,13 @@ test "@fieldParentPtr nested packed struct" {
954 var pcbba: @TypeOf(&c.b.b.a) = undefined;954 var pcbba: @TypeOf(&c.b.b.a) = undefined;
955 pcbba = &c.b.b.a;955 pcbba = &c.b.b.a;
956 var pcbb: @TypeOf(&c.b.b) = undefined;956 var pcbb: @TypeOf(&c.b.b) = undefined;
957 pcbb = @alignCast(@fieldParentPtr(*align(1) @TypeOf(c.b.b), "a", pcbba));957 pcbb = @alignCast(@fieldParentPtr("a", pcbba));
958 try expect(pcbb == &c.b.b);958 try expect(pcbb == &c.b.b);
959 var pcb: @TypeOf(&c.b) = undefined;959 var pcb: @TypeOf(&c.b) = undefined;
960 pcb = @alignCast(@fieldParentPtr(*align(1:9:3) @TypeOf(c.b), "b", pcbb));960 pcb = @alignCast(@fieldParentPtr("b", pcbb));
961 try expect(pcb == &c.b);961 try expect(pcb == &c.b);
962 var pc: *C = undefined;962 var pc: *C = undefined;
963 pc = @alignCast(@fieldParentPtr(*align(1) C, "b", pcb));963 pc = @alignCast(@fieldParentPtr("b", pcb));
964 try expect(pc == &c);964 try expect(pc == &c);
965 }965 }
966 }966 }
...@@ -979,11 +979,11 @@ test "@fieldParentPtr nested packed struct" {...@@ -979,11 +979,11 @@ test "@fieldParentPtr nested packed struct" {
979 {979 {
980 const c: C = .{ .a = 0, .b = .{ .a = 0, .b = .{ .a = 0 } } };980 const c: C = .{ .a = 0, .b = .{ .a = 0, .b = .{ .a = 0 } } };
981 const pcbba = &c.b.b.a;981 const pcbba = &c.b.b.a;
982 const pcbb: @TypeOf(&c.b.b) = @alignCast(@fieldParentPtr(*align(1:17:4) const @TypeOf(c.b.b), "a", pcbba));982 const pcbb: @TypeOf(&c.b.b) = @alignCast(@fieldParentPtr("a", pcbba));
983 try expect(pcbb == &c.b.b);983 try expect(pcbb == &c.b.b);
984 const pcb: @TypeOf(&c.b) = @alignCast(@fieldParentPtr(*align(1:9:4) const @TypeOf(c.b), "b", pcbb));984 const pcb: @TypeOf(&c.b) = @alignCast(@fieldParentPtr("b", pcbb));
985 try expect(pcb == &c.b);985 try expect(pcb == &c.b);
986 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcb));986 const pc: *const C = @alignCast(@fieldParentPtr("b", pcb));
987 try expect(pc == &c);987 try expect(pc == &c);
988 }988 }
989989
...@@ -993,13 +993,13 @@ test "@fieldParentPtr nested packed struct" {...@@ -993,13 +993,13 @@ test "@fieldParentPtr nested packed struct" {
993 var pcbba: @TypeOf(&c.b.b.a) = undefined;993 var pcbba: @TypeOf(&c.b.b.a) = undefined;
994 pcbba = &c.b.b.a;994 pcbba = &c.b.b.a;
995 var pcbb: @TypeOf(&c.b.b) = undefined;995 var pcbb: @TypeOf(&c.b.b) = undefined;
996 pcbb = @alignCast(@fieldParentPtr(*align(1:17:4) @TypeOf(c.b.b), "a", pcbba));996 pcbb = @alignCast(@fieldParentPtr("a", pcbba));
997 try expect(pcbb == &c.b.b);997 try expect(pcbb == &c.b.b);
998 var pcb: @TypeOf(&c.b) = undefined;998 var pcb: @TypeOf(&c.b) = undefined;
999 pcb = @alignCast(@fieldParentPtr(*align(1:9:4) @TypeOf(c.b), "b", pcbb));999 pcb = @alignCast(@fieldParentPtr("b", pcbb));
1000 try expect(pcb == &c.b);1000 try expect(pcb == &c.b);
1001 var pc: *C = undefined;1001 var pc: *C = undefined;
1002 pc = @alignCast(@fieldParentPtr(*align(1) C, "b", pcb));1002 pc = @alignCast(@fieldParentPtr("b", pcb));
1003 try expect(pc == &c);1003 try expect(pc == &c);
1004 }1004 }
1005 }1005 }
...@@ -1018,14 +1018,14 @@ test "@fieldParentPtr packed struct first zero-bit field" {...@@ -1018,14 +1018,14 @@ test "@fieldParentPtr packed struct first zero-bit field" {
1018 {1018 {
1019 const c: C = .{ .a = 0 };1019 const c: C = .{ .a = 0 };
1020 const pcf = &c.a;1020 const pcf = &c.a;
1021 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1021 const pc: *const C = @alignCast(@fieldParentPtr("a", pcf));
1022 try expect(pc == &c);1022 try expect(pc == &c);
1023 }1023 }
1024 {1024 {
1025 const c: C = .{ .a = 0 };1025 const c: C = .{ .a = 0 };
1026 const pcf = &c.a;1026 const pcf = &c.a;
1027 var pc: *const C = undefined;1027 var pc: *const C = undefined;
1028 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1028 pc = @alignCast(@fieldParentPtr("a", pcf));
1029 try expect(pc == &c);1029 try expect(pc == &c);
1030 }1030 }
1031 {1031 {
...@@ -1033,7 +1033,7 @@ test "@fieldParentPtr packed struct first zero-bit field" {...@@ -1033,7 +1033,7 @@ test "@fieldParentPtr packed struct first zero-bit field" {
1033 var pcf: @TypeOf(&c.a) = undefined;1033 var pcf: @TypeOf(&c.a) = undefined;
1034 pcf = &c.a;1034 pcf = &c.a;
1035 var pc: *const C = undefined;1035 var pc: *const C = undefined;
1036 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1036 pc = @alignCast(@fieldParentPtr("a", pcf));
1037 try expect(pc == &c);1037 try expect(pc == &c);
1038 }1038 }
1039 {1039 {
...@@ -1042,21 +1042,21 @@ test "@fieldParentPtr packed struct first zero-bit field" {...@@ -1042,21 +1042,21 @@ test "@fieldParentPtr packed struct first zero-bit field" {
1042 var pcf: @TypeOf(&c.a) = undefined;1042 var pcf: @TypeOf(&c.a) = undefined;
1043 pcf = &c.a;1043 pcf = &c.a;
1044 var pc: *C = undefined;1044 var pc: *C = undefined;
1045 pc = @alignCast(@fieldParentPtr(*align(1) C, "a", pcf));1045 pc = @alignCast(@fieldParentPtr("a", pcf));
1046 try expect(pc == &c);1046 try expect(pc == &c);
1047 }1047 }
10481048
1049 {1049 {
1050 const c: C = .{ .b = 666.667 };1050 const c: C = .{ .b = 666.667 };
1051 const pcf = &c.b;1051 const pcf = &c.b;
1052 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1052 const pc: *const C = @alignCast(@fieldParentPtr("b", pcf));
1053 try expect(pc == &c);1053 try expect(pc == &c);
1054 }1054 }
1055 {1055 {
1056 const c: C = .{ .b = 666.667 };1056 const c: C = .{ .b = 666.667 };
1057 const pcf = &c.b;1057 const pcf = &c.b;
1058 var pc: *const C = undefined;1058 var pc: *const C = undefined;
1059 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1059 pc = @alignCast(@fieldParentPtr("b", pcf));
1060 try expect(pc == &c);1060 try expect(pc == &c);
1061 }1061 }
1062 {1062 {
...@@ -1064,7 +1064,7 @@ test "@fieldParentPtr packed struct first zero-bit field" {...@@ -1064,7 +1064,7 @@ test "@fieldParentPtr packed struct first zero-bit field" {
1064 var pcf: @TypeOf(&c.b) = undefined;1064 var pcf: @TypeOf(&c.b) = undefined;
1065 pcf = &c.b;1065 pcf = &c.b;
1066 var pc: *const C = undefined;1066 var pc: *const C = undefined;
1067 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1067 pc = @alignCast(@fieldParentPtr("b", pcf));
1068 try expect(pc == &c);1068 try expect(pc == &c);
1069 }1069 }
1070 {1070 {
...@@ -1073,21 +1073,21 @@ test "@fieldParentPtr packed struct first zero-bit field" {...@@ -1073,21 +1073,21 @@ test "@fieldParentPtr packed struct first zero-bit field" {
1073 var pcf: @TypeOf(&c.b) = undefined;1073 var pcf: @TypeOf(&c.b) = undefined;
1074 pcf = &c.b;1074 pcf = &c.b;
1075 var pc: *C = undefined;1075 var pc: *C = undefined;
1076 pc = @alignCast(@fieldParentPtr(*align(1) C, "b", pcf));1076 pc = @alignCast(@fieldParentPtr("b", pcf));
1077 try expect(pc == &c);1077 try expect(pc == &c);
1078 }1078 }
10791079
1080 {1080 {
1081 const c: C = .{ .c = -1111111111 };1081 const c: C = .{ .c = -1111111111 };
1082 const pcf = &c.c;1082 const pcf = &c.c;
1083 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));1083 const pc: *const C = @alignCast(@fieldParentPtr("c", pcf));
1084 try expect(pc == &c);1084 try expect(pc == &c);
1085 }1085 }
1086 {1086 {
1087 const c: C = .{ .c = -1111111111 };1087 const c: C = .{ .c = -1111111111 };
1088 const pcf = &c.c;1088 const pcf = &c.c;
1089 var pc: *const C = undefined;1089 var pc: *const C = undefined;
1090 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));1090 pc = @alignCast(@fieldParentPtr("c", pcf));
1091 try expect(pc == &c);1091 try expect(pc == &c);
1092 }1092 }
1093 {1093 {
...@@ -1095,7 +1095,7 @@ test "@fieldParentPtr packed struct first zero-bit field" {...@@ -1095,7 +1095,7 @@ test "@fieldParentPtr packed struct first zero-bit field" {
1095 var pcf: @TypeOf(&c.c) = undefined;1095 var pcf: @TypeOf(&c.c) = undefined;
1096 pcf = &c.c;1096 pcf = &c.c;
1097 var pc: *const C = undefined;1097 var pc: *const C = undefined;
1098 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));1098 pc = @alignCast(@fieldParentPtr("c", pcf));
1099 try expect(pc == &c);1099 try expect(pc == &c);
1100 }1100 }
1101 {1101 {
...@@ -1104,7 +1104,7 @@ test "@fieldParentPtr packed struct first zero-bit field" {...@@ -1104,7 +1104,7 @@ test "@fieldParentPtr packed struct first zero-bit field" {
1104 var pcf: @TypeOf(&c.c) = undefined;1104 var pcf: @TypeOf(&c.c) = undefined;
1105 pcf = &c.c;1105 pcf = &c.c;
1106 var pc: *C = undefined;1106 var pc: *C = undefined;
1107 pc = @alignCast(@fieldParentPtr(*align(1) C, "c", pcf));1107 pc = @alignCast(@fieldParentPtr("c", pcf));
1108 try expect(pc == &c);1108 try expect(pc == &c);
1109 }1109 }
1110}1110}
...@@ -1122,14 +1122,14 @@ test "@fieldParentPtr packed struct middle zero-bit field" {...@@ -1122,14 +1122,14 @@ test "@fieldParentPtr packed struct middle zero-bit field" {
1122 {1122 {
1123 const c: C = .{ .a = 666.667 };1123 const c: C = .{ .a = 666.667 };
1124 const pcf = &c.a;1124 const pcf = &c.a;
1125 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1125 const pc: *const C = @alignCast(@fieldParentPtr("a", pcf));
1126 try expect(pc == &c);1126 try expect(pc == &c);
1127 }1127 }
1128 {1128 {
1129 const c: C = .{ .a = 666.667 };1129 const c: C = .{ .a = 666.667 };
1130 const pcf = &c.a;1130 const pcf = &c.a;
1131 var pc: *const C = undefined;1131 var pc: *const C = undefined;
1132 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1132 pc = @alignCast(@fieldParentPtr("a", pcf));
1133 try expect(pc == &c);1133 try expect(pc == &c);
1134 }1134 }
1135 {1135 {
...@@ -1137,7 +1137,7 @@ test "@fieldParentPtr packed struct middle zero-bit field" {...@@ -1137,7 +1137,7 @@ test "@fieldParentPtr packed struct middle zero-bit field" {
1137 var pcf: @TypeOf(&c.a) = undefined;1137 var pcf: @TypeOf(&c.a) = undefined;
1138 pcf = &c.a;1138 pcf = &c.a;
1139 var pc: *const C = undefined;1139 var pc: *const C = undefined;
1140 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1140 pc = @alignCast(@fieldParentPtr("a", pcf));
1141 try expect(pc == &c);1141 try expect(pc == &c);
1142 }1142 }
1143 {1143 {
...@@ -1146,21 +1146,21 @@ test "@fieldParentPtr packed struct middle zero-bit field" {...@@ -1146,21 +1146,21 @@ test "@fieldParentPtr packed struct middle zero-bit field" {
1146 var pcf: @TypeOf(&c.a) = undefined;1146 var pcf: @TypeOf(&c.a) = undefined;
1147 pcf = &c.a;1147 pcf = &c.a;
1148 var pc: *C = undefined;1148 var pc: *C = undefined;
1149 pc = @alignCast(@fieldParentPtr(*align(1) C, "a", pcf));1149 pc = @alignCast(@fieldParentPtr("a", pcf));
1150 try expect(pc == &c);1150 try expect(pc == &c);
1151 }1151 }
11521152
1153 {1153 {
1154 const c: C = .{ .b = 0 };1154 const c: C = .{ .b = 0 };
1155 const pcf = &c.b;1155 const pcf = &c.b;
1156 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1156 const pc: *const C = @alignCast(@fieldParentPtr("b", pcf));
1157 try expect(pc == &c);1157 try expect(pc == &c);
1158 }1158 }
1159 {1159 {
1160 const c: C = .{ .b = 0 };1160 const c: C = .{ .b = 0 };
1161 const pcf = &c.b;1161 const pcf = &c.b;
1162 var pc: *const C = undefined;1162 var pc: *const C = undefined;
1163 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1163 pc = @alignCast(@fieldParentPtr("b", pcf));
1164 try expect(pc == &c);1164 try expect(pc == &c);
1165 }1165 }
1166 {1166 {
...@@ -1168,7 +1168,7 @@ test "@fieldParentPtr packed struct middle zero-bit field" {...@@ -1168,7 +1168,7 @@ test "@fieldParentPtr packed struct middle zero-bit field" {
1168 var pcf: @TypeOf(&c.b) = undefined;1168 var pcf: @TypeOf(&c.b) = undefined;
1169 pcf = &c.b;1169 pcf = &c.b;
1170 var pc: *const C = undefined;1170 var pc: *const C = undefined;
1171 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1171 pc = @alignCast(@fieldParentPtr("b", pcf));
1172 try expect(pc == &c);1172 try expect(pc == &c);
1173 }1173 }
1174 {1174 {
...@@ -1177,21 +1177,21 @@ test "@fieldParentPtr packed struct middle zero-bit field" {...@@ -1177,21 +1177,21 @@ test "@fieldParentPtr packed struct middle zero-bit field" {
1177 var pcf: @TypeOf(&c.b) = undefined;1177 var pcf: @TypeOf(&c.b) = undefined;
1178 pcf = &c.b;1178 pcf = &c.b;
1179 var pc: *C = undefined;1179 var pc: *C = undefined;
1180 pc = @alignCast(@fieldParentPtr(*align(1) C, "b", pcf));1180 pc = @alignCast(@fieldParentPtr("b", pcf));
1181 try expect(pc == &c);1181 try expect(pc == &c);
1182 }1182 }
11831183
1184 {1184 {
1185 const c: C = .{ .c = -1111111111 };1185 const c: C = .{ .c = -1111111111 };
1186 const pcf = &c.c;1186 const pcf = &c.c;
1187 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));1187 const pc: *const C = @alignCast(@fieldParentPtr("c", pcf));
1188 try expect(pc == &c);1188 try expect(pc == &c);
1189 }1189 }
1190 {1190 {
1191 const c: C = .{ .c = -1111111111 };1191 const c: C = .{ .c = -1111111111 };
1192 const pcf = &c.c;1192 const pcf = &c.c;
1193 var pc: *const C = undefined;1193 var pc: *const C = undefined;
1194 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));1194 pc = @alignCast(@fieldParentPtr("c", pcf));
1195 try expect(pc == &c);1195 try expect(pc == &c);
1196 }1196 }
1197 {1197 {
...@@ -1199,7 +1199,7 @@ test "@fieldParentPtr packed struct middle zero-bit field" {...@@ -1199,7 +1199,7 @@ test "@fieldParentPtr packed struct middle zero-bit field" {
1199 var pcf: @TypeOf(&c.c) = undefined;1199 var pcf: @TypeOf(&c.c) = undefined;
1200 pcf = &c.c;1200 pcf = &c.c;
1201 var pc: *const C = undefined;1201 var pc: *const C = undefined;
1202 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));1202 pc = @alignCast(@fieldParentPtr("c", pcf));
1203 try expect(pc == &c);1203 try expect(pc == &c);
1204 }1204 }
1205 {1205 {
...@@ -1208,7 +1208,7 @@ test "@fieldParentPtr packed struct middle zero-bit field" {...@@ -1208,7 +1208,7 @@ test "@fieldParentPtr packed struct middle zero-bit field" {
1208 var pcf: @TypeOf(&c.c) = undefined;1208 var pcf: @TypeOf(&c.c) = undefined;
1209 pcf = &c.c;1209 pcf = &c.c;
1210 var pc: *C = undefined;1210 var pc: *C = undefined;
1211 pc = @alignCast(@fieldParentPtr(*align(1) C, "c", pcf));1211 pc = @alignCast(@fieldParentPtr("c", pcf));
1212 try expect(pc == &c);1212 try expect(pc == &c);
1213 }1213 }
1214}1214}
...@@ -1226,14 +1226,14 @@ test "@fieldParentPtr packed struct last zero-bit field" {...@@ -1226,14 +1226,14 @@ test "@fieldParentPtr packed struct last zero-bit field" {
1226 {1226 {
1227 const c: C = .{ .a = 666.667 };1227 const c: C = .{ .a = 666.667 };
1228 const pcf = &c.a;1228 const pcf = &c.a;
1229 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1229 const pc: *const C = @alignCast(@fieldParentPtr("a", pcf));
1230 try expect(pc == &c);1230 try expect(pc == &c);
1231 }1231 }
1232 {1232 {
1233 const c: C = .{ .a = 666.667 };1233 const c: C = .{ .a = 666.667 };
1234 const pcf = &c.a;1234 const pcf = &c.a;
1235 var pc: *const C = undefined;1235 var pc: *const C = undefined;
1236 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1236 pc = @alignCast(@fieldParentPtr("a", pcf));
1237 try expect(pc == &c);1237 try expect(pc == &c);
1238 }1238 }
1239 {1239 {
...@@ -1241,7 +1241,7 @@ test "@fieldParentPtr packed struct last zero-bit field" {...@@ -1241,7 +1241,7 @@ test "@fieldParentPtr packed struct last zero-bit field" {
1241 var pcf: @TypeOf(&c.a) = undefined;1241 var pcf: @TypeOf(&c.a) = undefined;
1242 pcf = &c.a;1242 pcf = &c.a;
1243 var pc: *const C = undefined;1243 var pc: *const C = undefined;
1244 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1244 pc = @alignCast(@fieldParentPtr("a", pcf));
1245 try expect(pc == &c);1245 try expect(pc == &c);
1246 }1246 }
1247 {1247 {
...@@ -1250,21 +1250,21 @@ test "@fieldParentPtr packed struct last zero-bit field" {...@@ -1250,21 +1250,21 @@ test "@fieldParentPtr packed struct last zero-bit field" {
1250 var pcf: @TypeOf(&c.a) = undefined;1250 var pcf: @TypeOf(&c.a) = undefined;
1251 pcf = &c.a;1251 pcf = &c.a;
1252 var pc: *C = undefined;1252 var pc: *C = undefined;
1253 pc = @alignCast(@fieldParentPtr(*align(1) C, "a", pcf));1253 pc = @alignCast(@fieldParentPtr("a", pcf));
1254 try expect(pc == &c);1254 try expect(pc == &c);
1255 }1255 }
12561256
1257 {1257 {
1258 const c: C = .{ .b = -1111111111 };1258 const c: C = .{ .b = -1111111111 };
1259 const pcf = &c.b;1259 const pcf = &c.b;
1260 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1260 const pc: *const C = @alignCast(@fieldParentPtr("b", pcf));
1261 try expect(pc == &c);1261 try expect(pc == &c);
1262 }1262 }
1263 {1263 {
1264 const c: C = .{ .b = -1111111111 };1264 const c: C = .{ .b = -1111111111 };
1265 const pcf = &c.b;1265 const pcf = &c.b;
1266 var pc: *const C = undefined;1266 var pc: *const C = undefined;
1267 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1267 pc = @alignCast(@fieldParentPtr("b", pcf));
1268 try expect(pc == &c);1268 try expect(pc == &c);
1269 }1269 }
1270 {1270 {
...@@ -1272,7 +1272,7 @@ test "@fieldParentPtr packed struct last zero-bit field" {...@@ -1272,7 +1272,7 @@ test "@fieldParentPtr packed struct last zero-bit field" {
1272 var pcf: @TypeOf(&c.b) = undefined;1272 var pcf: @TypeOf(&c.b) = undefined;
1273 pcf = &c.b;1273 pcf = &c.b;
1274 var pc: *const C = undefined;1274 var pc: *const C = undefined;
1275 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1275 pc = @alignCast(@fieldParentPtr("b", pcf));
1276 try expect(pc == &c);1276 try expect(pc == &c);
1277 }1277 }
1278 {1278 {
...@@ -1281,21 +1281,21 @@ test "@fieldParentPtr packed struct last zero-bit field" {...@@ -1281,21 +1281,21 @@ test "@fieldParentPtr packed struct last zero-bit field" {
1281 var pcf: @TypeOf(&c.b) = undefined;1281 var pcf: @TypeOf(&c.b) = undefined;
1282 pcf = &c.b;1282 pcf = &c.b;
1283 var pc: *C = undefined;1283 var pc: *C = undefined;
1284 pc = @alignCast(@fieldParentPtr(*align(1) C, "b", pcf));1284 pc = @alignCast(@fieldParentPtr("b", pcf));
1285 try expect(pc == &c);1285 try expect(pc == &c);
1286 }1286 }
12871287
1288 {1288 {
1289 const c: C = .{ .c = 0 };1289 const c: C = .{ .c = 0 };
1290 const pcf = &c.c;1290 const pcf = &c.c;
1291 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));1291 const pc: *const C = @alignCast(@fieldParentPtr("c", pcf));
1292 try expect(pc == &c);1292 try expect(pc == &c);
1293 }1293 }
1294 {1294 {
1295 const c: C = .{ .c = 0 };1295 const c: C = .{ .c = 0 };
1296 const pcf = &c.c;1296 const pcf = &c.c;
1297 var pc: *const C = undefined;1297 var pc: *const C = undefined;
1298 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));1298 pc = @alignCast(@fieldParentPtr("c", pcf));
1299 try expect(pc == &c);1299 try expect(pc == &c);
1300 }1300 }
1301 {1301 {
...@@ -1303,7 +1303,7 @@ test "@fieldParentPtr packed struct last zero-bit field" {...@@ -1303,7 +1303,7 @@ test "@fieldParentPtr packed struct last zero-bit field" {
1303 var pcf: @TypeOf(&c.c) = undefined;1303 var pcf: @TypeOf(&c.c) = undefined;
1304 pcf = &c.c;1304 pcf = &c.c;
1305 var pc: *const C = undefined;1305 var pc: *const C = undefined;
1306 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));1306 pc = @alignCast(@fieldParentPtr("c", pcf));
1307 try expect(pc == &c);1307 try expect(pc == &c);
1308 }1308 }
1309 {1309 {
...@@ -1312,7 +1312,7 @@ test "@fieldParentPtr packed struct last zero-bit field" {...@@ -1312,7 +1312,7 @@ test "@fieldParentPtr packed struct last zero-bit field" {
1312 var pcf: @TypeOf(&c.c) = undefined;1312 var pcf: @TypeOf(&c.c) = undefined;
1313 pcf = &c.c;1313 pcf = &c.c;
1314 var pc: *C = undefined;1314 var pc: *C = undefined;
1315 pc = @alignCast(@fieldParentPtr(*align(1) C, "c", pcf));1315 pc = @alignCast(@fieldParentPtr("c", pcf));
1316 try expect(pc == &c);1316 try expect(pc == &c);
1317 }1317 }
1318}1318}
...@@ -1328,14 +1328,14 @@ test "@fieldParentPtr tagged union" {...@@ -1328,14 +1328,14 @@ test "@fieldParentPtr tagged union" {
1328 {1328 {
1329 const c: C = .{ .a = false };1329 const c: C = .{ .a = false };
1330 const pcf = &c.a;1330 const pcf = &c.a;
1331 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1331 const pc: *const C = @alignCast(@fieldParentPtr("a", pcf));
1332 try expect(pc == &c);1332 try expect(pc == &c);
1333 }1333 }
1334 {1334 {
1335 const c: C = .{ .a = false };1335 const c: C = .{ .a = false };
1336 const pcf = &c.a;1336 const pcf = &c.a;
1337 var pc: *const C = undefined;1337 var pc: *const C = undefined;
1338 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1338 pc = @alignCast(@fieldParentPtr("a", pcf));
1339 try expect(pc == &c);1339 try expect(pc == &c);
1340 }1340 }
1341 {1341 {
...@@ -1343,7 +1343,7 @@ test "@fieldParentPtr tagged union" {...@@ -1343,7 +1343,7 @@ test "@fieldParentPtr tagged union" {
1343 var pcf: @TypeOf(&c.a) = undefined;1343 var pcf: @TypeOf(&c.a) = undefined;
1344 pcf = &c.a;1344 pcf = &c.a;
1345 var pc: *const C = undefined;1345 var pc: *const C = undefined;
1346 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1346 pc = @alignCast(@fieldParentPtr("a", pcf));
1347 try expect(pc == &c);1347 try expect(pc == &c);
1348 }1348 }
1349 {1349 {
...@@ -1352,21 +1352,21 @@ test "@fieldParentPtr tagged union" {...@@ -1352,21 +1352,21 @@ test "@fieldParentPtr tagged union" {
1352 var pcf: @TypeOf(&c.a) = undefined;1352 var pcf: @TypeOf(&c.a) = undefined;
1353 pcf = &c.a;1353 pcf = &c.a;
1354 var pc: *C = undefined;1354 var pc: *C = undefined;
1355 pc = @alignCast(@fieldParentPtr(*align(1) C, "a", pcf));1355 pc = @alignCast(@fieldParentPtr("a", pcf));
1356 try expect(pc == &c);1356 try expect(pc == &c);
1357 }1357 }
13581358
1359 {1359 {
1360 const c: C = .{ .b = 0 };1360 const c: C = .{ .b = 0 };
1361 const pcf = &c.b;1361 const pcf = &c.b;
1362 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1362 const pc: *const C = @alignCast(@fieldParentPtr("b", pcf));
1363 try expect(pc == &c);1363 try expect(pc == &c);
1364 }1364 }
1365 {1365 {
1366 const c: C = .{ .b = 0 };1366 const c: C = .{ .b = 0 };
1367 const pcf = &c.b;1367 const pcf = &c.b;
1368 var pc: *const C = undefined;1368 var pc: *const C = undefined;
1369 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1369 pc = @alignCast(@fieldParentPtr("b", pcf));
1370 try expect(pc == &c);1370 try expect(pc == &c);
1371 }1371 }
1372 {1372 {
...@@ -1374,7 +1374,7 @@ test "@fieldParentPtr tagged union" {...@@ -1374,7 +1374,7 @@ test "@fieldParentPtr tagged union" {
1374 var pcf: @TypeOf(&c.b) = undefined;1374 var pcf: @TypeOf(&c.b) = undefined;
1375 pcf = &c.b;1375 pcf = &c.b;
1376 var pc: *const C = undefined;1376 var pc: *const C = undefined;
1377 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1377 pc = @alignCast(@fieldParentPtr("b", pcf));
1378 try expect(pc == &c);1378 try expect(pc == &c);
1379 }1379 }
1380 {1380 {
...@@ -1383,21 +1383,21 @@ test "@fieldParentPtr tagged union" {...@@ -1383,21 +1383,21 @@ test "@fieldParentPtr tagged union" {
1383 var pcf: @TypeOf(&c.b) = undefined;1383 var pcf: @TypeOf(&c.b) = undefined;
1384 pcf = &c.b;1384 pcf = &c.b;
1385 var pc: *C = undefined;1385 var pc: *C = undefined;
1386 pc = @alignCast(@fieldParentPtr(*align(1) C, "b", pcf));1386 pc = @alignCast(@fieldParentPtr("b", pcf));
1387 try expect(pc == &c);1387 try expect(pc == &c);
1388 }1388 }
13891389
1390 {1390 {
1391 const c: C = .{ .c = .{255} };1391 const c: C = .{ .c = .{255} };
1392 const pcf = &c.c;1392 const pcf = &c.c;
1393 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));1393 const pc: *const C = @alignCast(@fieldParentPtr("c", pcf));
1394 try expect(pc == &c);1394 try expect(pc == &c);
1395 }1395 }
1396 {1396 {
1397 const c: C = .{ .c = .{255} };1397 const c: C = .{ .c = .{255} };
1398 const pcf = &c.c;1398 const pcf = &c.c;
1399 var pc: *const C = undefined;1399 var pc: *const C = undefined;
1400 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));1400 pc = @alignCast(@fieldParentPtr("c", pcf));
1401 try expect(pc == &c);1401 try expect(pc == &c);
1402 }1402 }
1403 {1403 {
...@@ -1405,7 +1405,7 @@ test "@fieldParentPtr tagged union" {...@@ -1405,7 +1405,7 @@ test "@fieldParentPtr tagged union" {
1405 var pcf: @TypeOf(&c.c) = undefined;1405 var pcf: @TypeOf(&c.c) = undefined;
1406 pcf = &c.c;1406 pcf = &c.c;
1407 var pc: *const C = undefined;1407 var pc: *const C = undefined;
1408 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));1408 pc = @alignCast(@fieldParentPtr("c", pcf));
1409 try expect(pc == &c);1409 try expect(pc == &c);
1410 }1410 }
1411 {1411 {
...@@ -1414,21 +1414,21 @@ test "@fieldParentPtr tagged union" {...@@ -1414,21 +1414,21 @@ test "@fieldParentPtr tagged union" {
1414 var pcf: @TypeOf(&c.c) = undefined;1414 var pcf: @TypeOf(&c.c) = undefined;
1415 pcf = &c.c;1415 pcf = &c.c;
1416 var pc: *C = undefined;1416 var pc: *C = undefined;
1417 pc = @alignCast(@fieldParentPtr(*align(1) C, "c", pcf));1417 pc = @alignCast(@fieldParentPtr("c", pcf));
1418 try expect(pc == &c);1418 try expect(pc == &c);
1419 }1419 }
14201420
1421 {1421 {
1422 const c: C = .{ .d = -1111111111 };1422 const c: C = .{ .d = -1111111111 };
1423 const pcf = &c.d;1423 const pcf = &c.d;
1424 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));1424 const pc: *const C = @alignCast(@fieldParentPtr("d", pcf));
1425 try expect(pc == &c);1425 try expect(pc == &c);
1426 }1426 }
1427 {1427 {
1428 const c: C = .{ .d = -1111111111 };1428 const c: C = .{ .d = -1111111111 };
1429 const pcf = &c.d;1429 const pcf = &c.d;
1430 var pc: *const C = undefined;1430 var pc: *const C = undefined;
1431 pc = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));1431 pc = @alignCast(@fieldParentPtr("d", pcf));
1432 try expect(pc == &c);1432 try expect(pc == &c);
1433 }1433 }
1434 {1434 {
...@@ -1436,7 +1436,7 @@ test "@fieldParentPtr tagged union" {...@@ -1436,7 +1436,7 @@ test "@fieldParentPtr tagged union" {
1436 var pcf: @TypeOf(&c.d) = undefined;1436 var pcf: @TypeOf(&c.d) = undefined;
1437 pcf = &c.d;1437 pcf = &c.d;
1438 var pc: *const C = undefined;1438 var pc: *const C = undefined;
1439 pc = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));1439 pc = @alignCast(@fieldParentPtr("d", pcf));
1440 try expect(pc == &c);1440 try expect(pc == &c);
1441 }1441 }
1442 {1442 {
...@@ -1445,7 +1445,7 @@ test "@fieldParentPtr tagged union" {...@@ -1445,7 +1445,7 @@ test "@fieldParentPtr tagged union" {
1445 var pcf: @TypeOf(&c.d) = undefined;1445 var pcf: @TypeOf(&c.d) = undefined;
1446 pcf = &c.d;1446 pcf = &c.d;
1447 var pc: *C = undefined;1447 var pc: *C = undefined;
1448 pc = @alignCast(@fieldParentPtr(*align(1) C, "d", pcf));1448 pc = @alignCast(@fieldParentPtr("d", pcf));
1449 try expect(pc == &c);1449 try expect(pc == &c);
1450 }1450 }
1451}1451}
...@@ -1461,14 +1461,14 @@ test "@fieldParentPtr untagged union" {...@@ -1461,14 +1461,14 @@ test "@fieldParentPtr untagged union" {
1461 {1461 {
1462 const c: C = .{ .a = false };1462 const c: C = .{ .a = false };
1463 const pcf = &c.a;1463 const pcf = &c.a;
1464 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1464 const pc: *const C = @alignCast(@fieldParentPtr("a", pcf));
1465 try expect(pc == &c);1465 try expect(pc == &c);
1466 }1466 }
1467 {1467 {
1468 const c: C = .{ .a = false };1468 const c: C = .{ .a = false };
1469 const pcf = &c.a;1469 const pcf = &c.a;
1470 var pc: *const C = undefined;1470 var pc: *const C = undefined;
1471 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1471 pc = @alignCast(@fieldParentPtr("a", pcf));
1472 try expect(pc == &c);1472 try expect(pc == &c);
1473 }1473 }
1474 {1474 {
...@@ -1476,7 +1476,7 @@ test "@fieldParentPtr untagged union" {...@@ -1476,7 +1476,7 @@ test "@fieldParentPtr untagged union" {
1476 var pcf: @TypeOf(&c.a) = undefined;1476 var pcf: @TypeOf(&c.a) = undefined;
1477 pcf = &c.a;1477 pcf = &c.a;
1478 var pc: *const C = undefined;1478 var pc: *const C = undefined;
1479 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1479 pc = @alignCast(@fieldParentPtr("a", pcf));
1480 try expect(pc == &c);1480 try expect(pc == &c);
1481 }1481 }
1482 {1482 {
...@@ -1485,21 +1485,21 @@ test "@fieldParentPtr untagged union" {...@@ -1485,21 +1485,21 @@ test "@fieldParentPtr untagged union" {
1485 var pcf: @TypeOf(&c.a) = undefined;1485 var pcf: @TypeOf(&c.a) = undefined;
1486 pcf = &c.a;1486 pcf = &c.a;
1487 var pc: *C = undefined;1487 var pc: *C = undefined;
1488 pc = @alignCast(@fieldParentPtr(*align(1) C, "a", pcf));1488 pc = @alignCast(@fieldParentPtr("a", pcf));
1489 try expect(pc == &c);1489 try expect(pc == &c);
1490 }1490 }
14911491
1492 {1492 {
1493 const c: C = .{ .b = 0 };1493 const c: C = .{ .b = 0 };
1494 const pcf = &c.b;1494 const pcf = &c.b;
1495 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1495 const pc: *const C = @alignCast(@fieldParentPtr("b", pcf));
1496 try expect(pc == &c);1496 try expect(pc == &c);
1497 }1497 }
1498 {1498 {
1499 const c: C = .{ .b = 0 };1499 const c: C = .{ .b = 0 };
1500 const pcf = &c.b;1500 const pcf = &c.b;
1501 var pc: *const C = undefined;1501 var pc: *const C = undefined;
1502 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1502 pc = @alignCast(@fieldParentPtr("b", pcf));
1503 try expect(pc == &c);1503 try expect(pc == &c);
1504 }1504 }
1505 {1505 {
...@@ -1507,7 +1507,7 @@ test "@fieldParentPtr untagged union" {...@@ -1507,7 +1507,7 @@ test "@fieldParentPtr untagged union" {
1507 var pcf: @TypeOf(&c.b) = undefined;1507 var pcf: @TypeOf(&c.b) = undefined;
1508 pcf = &c.b;1508 pcf = &c.b;
1509 var pc: *const C = undefined;1509 var pc: *const C = undefined;
1510 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1510 pc = @alignCast(@fieldParentPtr("b", pcf));
1511 try expect(pc == &c);1511 try expect(pc == &c);
1512 }1512 }
1513 {1513 {
...@@ -1516,21 +1516,21 @@ test "@fieldParentPtr untagged union" {...@@ -1516,21 +1516,21 @@ test "@fieldParentPtr untagged union" {
1516 var pcf: @TypeOf(&c.b) = undefined;1516 var pcf: @TypeOf(&c.b) = undefined;
1517 pcf = &c.b;1517 pcf = &c.b;
1518 var pc: *C = undefined;1518 var pc: *C = undefined;
1519 pc = @alignCast(@fieldParentPtr(*align(1) C, "b", pcf));1519 pc = @alignCast(@fieldParentPtr("b", pcf));
1520 try expect(pc == &c);1520 try expect(pc == &c);
1521 }1521 }
15221522
1523 {1523 {
1524 const c: C = .{ .c = .{255} };1524 const c: C = .{ .c = .{255} };
1525 const pcf = &c.c;1525 const pcf = &c.c;
1526 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));1526 const pc: *const C = @alignCast(@fieldParentPtr("c", pcf));
1527 try expect(pc == &c);1527 try expect(pc == &c);
1528 }1528 }
1529 {1529 {
1530 const c: C = .{ .c = .{255} };1530 const c: C = .{ .c = .{255} };
1531 const pcf = &c.c;1531 const pcf = &c.c;
1532 var pc: *const C = undefined;1532 var pc: *const C = undefined;
1533 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));1533 pc = @alignCast(@fieldParentPtr("c", pcf));
1534 try expect(pc == &c);1534 try expect(pc == &c);
1535 }1535 }
1536 {1536 {
...@@ -1538,7 +1538,7 @@ test "@fieldParentPtr untagged union" {...@@ -1538,7 +1538,7 @@ test "@fieldParentPtr untagged union" {
1538 var pcf: @TypeOf(&c.c) = undefined;1538 var pcf: @TypeOf(&c.c) = undefined;
1539 pcf = &c.c;1539 pcf = &c.c;
1540 var pc: *const C = undefined;1540 var pc: *const C = undefined;
1541 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));1541 pc = @alignCast(@fieldParentPtr("c", pcf));
1542 try expect(pc == &c);1542 try expect(pc == &c);
1543 }1543 }
1544 {1544 {
...@@ -1547,21 +1547,21 @@ test "@fieldParentPtr untagged union" {...@@ -1547,21 +1547,21 @@ test "@fieldParentPtr untagged union" {
1547 var pcf: @TypeOf(&c.c) = undefined;1547 var pcf: @TypeOf(&c.c) = undefined;
1548 pcf = &c.c;1548 pcf = &c.c;
1549 var pc: *C = undefined;1549 var pc: *C = undefined;
1550 pc = @alignCast(@fieldParentPtr(*align(1) C, "c", pcf));1550 pc = @alignCast(@fieldParentPtr("c", pcf));
1551 try expect(pc == &c);1551 try expect(pc == &c);
1552 }1552 }
15531553
1554 {1554 {
1555 const c: C = .{ .d = -1111111111 };1555 const c: C = .{ .d = -1111111111 };
1556 const pcf = &c.d;1556 const pcf = &c.d;
1557 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));1557 const pc: *const C = @alignCast(@fieldParentPtr("d", pcf));
1558 try expect(pc == &c);1558 try expect(pc == &c);
1559 }1559 }
1560 {1560 {
1561 const c: C = .{ .d = -1111111111 };1561 const c: C = .{ .d = -1111111111 };
1562 const pcf = &c.d;1562 const pcf = &c.d;
1563 var pc: *const C = undefined;1563 var pc: *const C = undefined;
1564 pc = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));1564 pc = @alignCast(@fieldParentPtr("d", pcf));
1565 try expect(pc == &c);1565 try expect(pc == &c);
1566 }1566 }
1567 {1567 {
...@@ -1569,7 +1569,7 @@ test "@fieldParentPtr untagged union" {...@@ -1569,7 +1569,7 @@ test "@fieldParentPtr untagged union" {
1569 var pcf: @TypeOf(&c.d) = undefined;1569 var pcf: @TypeOf(&c.d) = undefined;
1570 pcf = &c.d;1570 pcf = &c.d;
1571 var pc: *const C = undefined;1571 var pc: *const C = undefined;
1572 pc = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));1572 pc = @alignCast(@fieldParentPtr("d", pcf));
1573 try expect(pc == &c);1573 try expect(pc == &c);
1574 }1574 }
1575 {1575 {
...@@ -1578,7 +1578,7 @@ test "@fieldParentPtr untagged union" {...@@ -1578,7 +1578,7 @@ test "@fieldParentPtr untagged union" {
1578 var pcf: @TypeOf(&c.d) = undefined;1578 var pcf: @TypeOf(&c.d) = undefined;
1579 pcf = &c.d;1579 pcf = &c.d;
1580 var pc: *C = undefined;1580 var pc: *C = undefined;
1581 pc = @alignCast(@fieldParentPtr(*align(1) C, "d", pcf));1581 pc = @alignCast(@fieldParentPtr("d", pcf));
1582 try expect(pc == &c);1582 try expect(pc == &c);
1583 }1583 }
1584}1584}
...@@ -1594,14 +1594,14 @@ test "@fieldParentPtr extern union" {...@@ -1594,14 +1594,14 @@ test "@fieldParentPtr extern union" {
1594 {1594 {
1595 const c: C = .{ .a = false };1595 const c: C = .{ .a = false };
1596 const pcf = &c.a;1596 const pcf = &c.a;
1597 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1597 const pc: *const C = @alignCast(@fieldParentPtr("a", pcf));
1598 try expect(pc == &c);1598 try expect(pc == &c);
1599 }1599 }
1600 {1600 {
1601 const c: C = .{ .a = false };1601 const c: C = .{ .a = false };
1602 const pcf = &c.a;1602 const pcf = &c.a;
1603 var pc: *const C = undefined;1603 var pc: *const C = undefined;
1604 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1604 pc = @alignCast(@fieldParentPtr("a", pcf));
1605 try expect(pc == &c);1605 try expect(pc == &c);
1606 }1606 }
1607 {1607 {
...@@ -1609,7 +1609,7 @@ test "@fieldParentPtr extern union" {...@@ -1609,7 +1609,7 @@ test "@fieldParentPtr extern union" {
1609 var pcf: @TypeOf(&c.a) = undefined;1609 var pcf: @TypeOf(&c.a) = undefined;
1610 pcf = &c.a;1610 pcf = &c.a;
1611 var pc: *const C = undefined;1611 var pc: *const C = undefined;
1612 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1612 pc = @alignCast(@fieldParentPtr("a", pcf));
1613 try expect(pc == &c);1613 try expect(pc == &c);
1614 }1614 }
1615 {1615 {
...@@ -1618,21 +1618,21 @@ test "@fieldParentPtr extern union" {...@@ -1618,21 +1618,21 @@ test "@fieldParentPtr extern union" {
1618 var pcf: @TypeOf(&c.a) = undefined;1618 var pcf: @TypeOf(&c.a) = undefined;
1619 pcf = &c.a;1619 pcf = &c.a;
1620 var pc: *C = undefined;1620 var pc: *C = undefined;
1621 pc = @alignCast(@fieldParentPtr(*align(1) C, "a", pcf));1621 pc = @alignCast(@fieldParentPtr("a", pcf));
1622 try expect(pc == &c);1622 try expect(pc == &c);
1623 }1623 }
16241624
1625 {1625 {
1626 const c: C = .{ .b = 0 };1626 const c: C = .{ .b = 0 };
1627 const pcf = &c.b;1627 const pcf = &c.b;
1628 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1628 const pc: *const C = @alignCast(@fieldParentPtr("b", pcf));
1629 try expect(pc == &c);1629 try expect(pc == &c);
1630 }1630 }
1631 {1631 {
1632 const c: C = .{ .b = 0 };1632 const c: C = .{ .b = 0 };
1633 const pcf = &c.b;1633 const pcf = &c.b;
1634 var pc: *const C = undefined;1634 var pc: *const C = undefined;
1635 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1635 pc = @alignCast(@fieldParentPtr("b", pcf));
1636 try expect(pc == &c);1636 try expect(pc == &c);
1637 }1637 }
1638 {1638 {
...@@ -1640,7 +1640,7 @@ test "@fieldParentPtr extern union" {...@@ -1640,7 +1640,7 @@ test "@fieldParentPtr extern union" {
1640 var pcf: @TypeOf(&c.b) = undefined;1640 var pcf: @TypeOf(&c.b) = undefined;
1641 pcf = &c.b;1641 pcf = &c.b;
1642 var pc: *const C = undefined;1642 var pc: *const C = undefined;
1643 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1643 pc = @alignCast(@fieldParentPtr("b", pcf));
1644 try expect(pc == &c);1644 try expect(pc == &c);
1645 }1645 }
1646 {1646 {
...@@ -1649,21 +1649,21 @@ test "@fieldParentPtr extern union" {...@@ -1649,21 +1649,21 @@ test "@fieldParentPtr extern union" {
1649 var pcf: @TypeOf(&c.b) = undefined;1649 var pcf: @TypeOf(&c.b) = undefined;
1650 pcf = &c.b;1650 pcf = &c.b;
1651 var pc: *C = undefined;1651 var pc: *C = undefined;
1652 pc = @alignCast(@fieldParentPtr(*align(1) C, "b", pcf));1652 pc = @alignCast(@fieldParentPtr("b", pcf));
1653 try expect(pc == &c);1653 try expect(pc == &c);
1654 }1654 }
16551655
1656 {1656 {
1657 const c: C = .{ .c = .{ .x = 255 } };1657 const c: C = .{ .c = .{ .x = 255 } };
1658 const pcf = &c.c;1658 const pcf = &c.c;
1659 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));1659 const pc: *const C = @alignCast(@fieldParentPtr("c", pcf));
1660 try expect(pc == &c);1660 try expect(pc == &c);
1661 }1661 }
1662 {1662 {
1663 const c: C = .{ .c = .{ .x = 255 } };1663 const c: C = .{ .c = .{ .x = 255 } };
1664 const pcf = &c.c;1664 const pcf = &c.c;
1665 var pc: *const C = undefined;1665 var pc: *const C = undefined;
1666 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));1666 pc = @alignCast(@fieldParentPtr("c", pcf));
1667 try expect(pc == &c);1667 try expect(pc == &c);
1668 }1668 }
1669 {1669 {
...@@ -1671,7 +1671,7 @@ test "@fieldParentPtr extern union" {...@@ -1671,7 +1671,7 @@ test "@fieldParentPtr extern union" {
1671 var pcf: @TypeOf(&c.c) = undefined;1671 var pcf: @TypeOf(&c.c) = undefined;
1672 pcf = &c.c;1672 pcf = &c.c;
1673 var pc: *const C = undefined;1673 var pc: *const C = undefined;
1674 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));1674 pc = @alignCast(@fieldParentPtr("c", pcf));
1675 try expect(pc == &c);1675 try expect(pc == &c);
1676 }1676 }
1677 {1677 {
...@@ -1680,21 +1680,21 @@ test "@fieldParentPtr extern union" {...@@ -1680,21 +1680,21 @@ test "@fieldParentPtr extern union" {
1680 var pcf: @TypeOf(&c.c) = undefined;1680 var pcf: @TypeOf(&c.c) = undefined;
1681 pcf = &c.c;1681 pcf = &c.c;
1682 var pc: *C = undefined;1682 var pc: *C = undefined;
1683 pc = @alignCast(@fieldParentPtr(*align(1) C, "c", pcf));1683 pc = @alignCast(@fieldParentPtr("c", pcf));
1684 try expect(pc == &c);1684 try expect(pc == &c);
1685 }1685 }
16861686
1687 {1687 {
1688 const c: C = .{ .d = -1111111111 };1688 const c: C = .{ .d = -1111111111 };
1689 const pcf = &c.d;1689 const pcf = &c.d;
1690 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));1690 const pc: *const C = @alignCast(@fieldParentPtr("d", pcf));
1691 try expect(pc == &c);1691 try expect(pc == &c);
1692 }1692 }
1693 {1693 {
1694 const c: C = .{ .d = -1111111111 };1694 const c: C = .{ .d = -1111111111 };
1695 const pcf = &c.d;1695 const pcf = &c.d;
1696 var pc: *const C = undefined;1696 var pc: *const C = undefined;
1697 pc = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));1697 pc = @alignCast(@fieldParentPtr("d", pcf));
1698 try expect(pc == &c);1698 try expect(pc == &c);
1699 }1699 }
1700 {1700 {
...@@ -1702,7 +1702,7 @@ test "@fieldParentPtr extern union" {...@@ -1702,7 +1702,7 @@ test "@fieldParentPtr extern union" {
1702 var pcf: @TypeOf(&c.d) = undefined;1702 var pcf: @TypeOf(&c.d) = undefined;
1703 pcf = &c.d;1703 pcf = &c.d;
1704 var pc: *const C = undefined;1704 var pc: *const C = undefined;
1705 pc = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));1705 pc = @alignCast(@fieldParentPtr("d", pcf));
1706 try expect(pc == &c);1706 try expect(pc == &c);
1707 }1707 }
1708 {1708 {
...@@ -1711,7 +1711,7 @@ test "@fieldParentPtr extern union" {...@@ -1711,7 +1711,7 @@ test "@fieldParentPtr extern union" {
1711 var pcf: @TypeOf(&c.d) = undefined;1711 var pcf: @TypeOf(&c.d) = undefined;
1712 pcf = &c.d;1712 pcf = &c.d;
1713 var pc: *C = undefined;1713 var pc: *C = undefined;
1714 pc = @alignCast(@fieldParentPtr(*align(1) C, "d", pcf));1714 pc = @alignCast(@fieldParentPtr("d", pcf));
1715 try expect(pc == &c);1715 try expect(pc == &c);
1716 }1716 }
1717}1717}
...@@ -1729,14 +1729,14 @@ test "@fieldParentPtr packed union" {...@@ -1729,14 +1729,14 @@ test "@fieldParentPtr packed union" {
1729 {1729 {
1730 const c: C = .{ .a = false };1730 const c: C = .{ .a = false };
1731 const pcf = &c.a;1731 const pcf = &c.a;
1732 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1732 const pc: *const C = @alignCast(@fieldParentPtr("a", pcf));
1733 try expect(pc == &c);1733 try expect(pc == &c);
1734 }1734 }
1735 {1735 {
1736 const c: C = .{ .a = false };1736 const c: C = .{ .a = false };
1737 const pcf = &c.a;1737 const pcf = &c.a;
1738 var pc: *const C = undefined;1738 var pc: *const C = undefined;
1739 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1739 pc = @alignCast(@fieldParentPtr("a", pcf));
1740 try expect(pc == &c);1740 try expect(pc == &c);
1741 }1741 }
1742 {1742 {
...@@ -1744,7 +1744,7 @@ test "@fieldParentPtr packed union" {...@@ -1744,7 +1744,7 @@ test "@fieldParentPtr packed union" {
1744 var pcf: @TypeOf(&c.a) = undefined;1744 var pcf: @TypeOf(&c.a) = undefined;
1745 pcf = &c.a;1745 pcf = &c.a;
1746 var pc: *const C = undefined;1746 var pc: *const C = undefined;
1747 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1747 pc = @alignCast(@fieldParentPtr("a", pcf));
1748 try expect(pc == &c);1748 try expect(pc == &c);
1749 }1749 }
1750 {1750 {
...@@ -1753,21 +1753,21 @@ test "@fieldParentPtr packed union" {...@@ -1753,21 +1753,21 @@ test "@fieldParentPtr packed union" {
1753 var pcf: @TypeOf(&c.a) = undefined;1753 var pcf: @TypeOf(&c.a) = undefined;
1754 pcf = &c.a;1754 pcf = &c.a;
1755 var pc: *C = undefined;1755 var pc: *C = undefined;
1756 pc = @alignCast(@fieldParentPtr(*align(1) C, "a", pcf));1756 pc = @alignCast(@fieldParentPtr("a", pcf));
1757 try expect(pc == &c);1757 try expect(pc == &c);
1758 }1758 }
17591759
1760 {1760 {
1761 const c: C = .{ .b = 0 };1761 const c: C = .{ .b = 0 };
1762 const pcf = &c.b;1762 const pcf = &c.b;
1763 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1763 const pc: *const C = @alignCast(@fieldParentPtr("b", pcf));
1764 try expect(pc == &c);1764 try expect(pc == &c);
1765 }1765 }
1766 {1766 {
1767 const c: C = .{ .b = 0 };1767 const c: C = .{ .b = 0 };
1768 const pcf = &c.b;1768 const pcf = &c.b;
1769 var pc: *const C = undefined;1769 var pc: *const C = undefined;
1770 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1770 pc = @alignCast(@fieldParentPtr("b", pcf));
1771 try expect(pc == &c);1771 try expect(pc == &c);
1772 }1772 }
1773 {1773 {
...@@ -1775,7 +1775,7 @@ test "@fieldParentPtr packed union" {...@@ -1775,7 +1775,7 @@ test "@fieldParentPtr packed union" {
1775 var pcf: @TypeOf(&c.b) = undefined;1775 var pcf: @TypeOf(&c.b) = undefined;
1776 pcf = &c.b;1776 pcf = &c.b;
1777 var pc: *const C = undefined;1777 var pc: *const C = undefined;
1778 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1778 pc = @alignCast(@fieldParentPtr("b", pcf));
1779 try expect(pc == &c);1779 try expect(pc == &c);
1780 }1780 }
1781 {1781 {
...@@ -1784,21 +1784,21 @@ test "@fieldParentPtr packed union" {...@@ -1784,21 +1784,21 @@ test "@fieldParentPtr packed union" {
1784 var pcf: @TypeOf(&c.b) = undefined;1784 var pcf: @TypeOf(&c.b) = undefined;
1785 pcf = &c.b;1785 pcf = &c.b;
1786 var pc: *C = undefined;1786 var pc: *C = undefined;
1787 pc = @alignCast(@fieldParentPtr(*align(1) C, "b", pcf));1787 pc = @alignCast(@fieldParentPtr("b", pcf));
1788 try expect(pc == &c);1788 try expect(pc == &c);
1789 }1789 }
17901790
1791 {1791 {
1792 const c: C = .{ .c = .{ .x = 255 } };1792 const c: C = .{ .c = .{ .x = 255 } };
1793 const pcf = &c.c;1793 const pcf = &c.c;
1794 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));1794 const pc: *const C = @alignCast(@fieldParentPtr("c", pcf));
1795 try expect(pc == &c);1795 try expect(pc == &c);
1796 }1796 }
1797 {1797 {
1798 const c: C = .{ .c = .{ .x = 255 } };1798 const c: C = .{ .c = .{ .x = 255 } };
1799 const pcf = &c.c;1799 const pcf = &c.c;
1800 var pc: *const C = undefined;1800 var pc: *const C = undefined;
1801 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));1801 pc = @alignCast(@fieldParentPtr("c", pcf));
1802 try expect(pc == &c);1802 try expect(pc == &c);
1803 }1803 }
1804 {1804 {
...@@ -1806,7 +1806,7 @@ test "@fieldParentPtr packed union" {...@@ -1806,7 +1806,7 @@ test "@fieldParentPtr packed union" {
1806 var pcf: @TypeOf(&c.c) = undefined;1806 var pcf: @TypeOf(&c.c) = undefined;
1807 pcf = &c.c;1807 pcf = &c.c;
1808 var pc: *const C = undefined;1808 var pc: *const C = undefined;
1809 pc = @alignCast(@fieldParentPtr(*align(1) const C, "c", pcf));1809 pc = @alignCast(@fieldParentPtr("c", pcf));
1810 try expect(pc == &c);1810 try expect(pc == &c);
1811 }1811 }
1812 {1812 {
...@@ -1815,21 +1815,21 @@ test "@fieldParentPtr packed union" {...@@ -1815,21 +1815,21 @@ test "@fieldParentPtr packed union" {
1815 var pcf: @TypeOf(&c.c) = undefined;1815 var pcf: @TypeOf(&c.c) = undefined;
1816 pcf = &c.c;1816 pcf = &c.c;
1817 var pc: *C = undefined;1817 var pc: *C = undefined;
1818 pc = @alignCast(@fieldParentPtr(*align(1) C, "c", pcf));1818 pc = @alignCast(@fieldParentPtr("c", pcf));
1819 try expect(pc == &c);1819 try expect(pc == &c);
1820 }1820 }
18211821
1822 {1822 {
1823 const c: C = .{ .d = -1111111111 };1823 const c: C = .{ .d = -1111111111 };
1824 const pcf = &c.d;1824 const pcf = &c.d;
1825 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));1825 const pc: *const C = @alignCast(@fieldParentPtr("d", pcf));
1826 try expect(pc == &c);1826 try expect(pc == &c);
1827 }1827 }
1828 {1828 {
1829 const c: C = .{ .d = -1111111111 };1829 const c: C = .{ .d = -1111111111 };
1830 const pcf = &c.d;1830 const pcf = &c.d;
1831 var pc: *const C = undefined;1831 var pc: *const C = undefined;
1832 pc = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));1832 pc = @alignCast(@fieldParentPtr("d", pcf));
1833 try expect(pc == &c);1833 try expect(pc == &c);
1834 }1834 }
1835 {1835 {
...@@ -1837,7 +1837,7 @@ test "@fieldParentPtr packed union" {...@@ -1837,7 +1837,7 @@ test "@fieldParentPtr packed union" {
1837 var pcf: @TypeOf(&c.d) = undefined;1837 var pcf: @TypeOf(&c.d) = undefined;
1838 pcf = &c.d;1838 pcf = &c.d;
1839 var pc: *const C = undefined;1839 var pc: *const C = undefined;
1840 pc = @alignCast(@fieldParentPtr(*align(1) const C, "d", pcf));1840 pc = @alignCast(@fieldParentPtr("d", pcf));
1841 try expect(pc == &c);1841 try expect(pc == &c);
1842 }1842 }
1843 {1843 {
...@@ -1846,7 +1846,7 @@ test "@fieldParentPtr packed union" {...@@ -1846,7 +1846,7 @@ test "@fieldParentPtr packed union" {
1846 var pcf: @TypeOf(&c.d) = undefined;1846 var pcf: @TypeOf(&c.d) = undefined;
1847 pcf = &c.d;1847 pcf = &c.d;
1848 var pc: *C = undefined;1848 var pc: *C = undefined;
1849 pc = @alignCast(@fieldParentPtr(*align(1) C, "d", pcf));1849 pc = @alignCast(@fieldParentPtr("d", pcf));
1850 try expect(pc == &c);1850 try expect(pc == &c);
1851 }1851 }
1852}1852}
...@@ -1863,14 +1863,14 @@ test "@fieldParentPtr tagged union all zero-bit fields" {...@@ -1863,14 +1863,14 @@ test "@fieldParentPtr tagged union all zero-bit fields" {
1863 {1863 {
1864 const c: C = .{ .a = 0 };1864 const c: C = .{ .a = 0 };
1865 const pcf = &c.a;1865 const pcf = &c.a;
1866 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1866 const pc: *const C = @alignCast(@fieldParentPtr("a", pcf));
1867 try expect(pc == &c);1867 try expect(pc == &c);
1868 }1868 }
1869 {1869 {
1870 const c: C = .{ .a = 0 };1870 const c: C = .{ .a = 0 };
1871 const pcf = &c.a;1871 const pcf = &c.a;
1872 var pc: *const C = undefined;1872 var pc: *const C = undefined;
1873 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1873 pc = @alignCast(@fieldParentPtr("a", pcf));
1874 try expect(pc == &c);1874 try expect(pc == &c);
1875 }1875 }
1876 {1876 {
...@@ -1878,7 +1878,7 @@ test "@fieldParentPtr tagged union all zero-bit fields" {...@@ -1878,7 +1878,7 @@ test "@fieldParentPtr tagged union all zero-bit fields" {
1878 var pcf: @TypeOf(&c.a) = undefined;1878 var pcf: @TypeOf(&c.a) = undefined;
1879 pcf = &c.a;1879 pcf = &c.a;
1880 var pc: *const C = undefined;1880 var pc: *const C = undefined;
1881 pc = @alignCast(@fieldParentPtr(*align(1) const C, "a", pcf));1881 pc = @alignCast(@fieldParentPtr("a", pcf));
1882 try expect(pc == &c);1882 try expect(pc == &c);
1883 }1883 }
1884 {1884 {
...@@ -1887,21 +1887,21 @@ test "@fieldParentPtr tagged union all zero-bit fields" {...@@ -1887,21 +1887,21 @@ test "@fieldParentPtr tagged union all zero-bit fields" {
1887 var pcf: @TypeOf(&c.a) = undefined;1887 var pcf: @TypeOf(&c.a) = undefined;
1888 pcf = &c.a;1888 pcf = &c.a;
1889 var pc: *C = undefined;1889 var pc: *C = undefined;
1890 pc = @alignCast(@fieldParentPtr(*align(1) C, "a", pcf));1890 pc = @alignCast(@fieldParentPtr("a", pcf));
1891 try expect(pc == &c);1891 try expect(pc == &c);
1892 }1892 }
18931893
1894 {1894 {
1895 const c: C = .{ .b = 0 };1895 const c: C = .{ .b = 0 };
1896 const pcf = &c.b;1896 const pcf = &c.b;
1897 const pc: *const C = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1897 const pc: *const C = @alignCast(@fieldParentPtr("b", pcf));
1898 try expect(pc == &c);1898 try expect(pc == &c);
1899 }1899 }
1900 {1900 {
1901 const c: C = .{ .b = 0 };1901 const c: C = .{ .b = 0 };
1902 const pcf = &c.b;1902 const pcf = &c.b;
1903 var pc: *const C = undefined;1903 var pc: *const C = undefined;
1904 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1904 pc = @alignCast(@fieldParentPtr("b", pcf));
1905 try expect(pc == &c);1905 try expect(pc == &c);
1906 }1906 }
1907 {1907 {
...@@ -1909,7 +1909,7 @@ test "@fieldParentPtr tagged union all zero-bit fields" {...@@ -1909,7 +1909,7 @@ test "@fieldParentPtr tagged union all zero-bit fields" {
1909 var pcf: @TypeOf(&c.b) = undefined;1909 var pcf: @TypeOf(&c.b) = undefined;
1910 pcf = &c.b;1910 pcf = &c.b;
1911 var pc: *const C = undefined;1911 var pc: *const C = undefined;
1912 pc = @alignCast(@fieldParentPtr(*align(1) const C, "b", pcf));1912 pc = @alignCast(@fieldParentPtr("b", pcf));
1913 try expect(pc == &c);1913 try expect(pc == &c);
1914 }1914 }
1915 {1915 {
...@@ -1918,7 +1918,7 @@ test "@fieldParentPtr tagged union all zero-bit fields" {...@@ -1918,7 +1918,7 @@ test "@fieldParentPtr tagged union all zero-bit fields" {
1918 var pcf: @TypeOf(&c.b) = undefined;1918 var pcf: @TypeOf(&c.b) = undefined;
1919 pcf = &c.b;1919 pcf = &c.b;
1920 var pc: *C = undefined;1920 var pc: *C = undefined;
1921 pc = @alignCast(@fieldParentPtr(*align(1) C, "b", pcf));1921 pc = @alignCast(@fieldParentPtr("b", pcf));
1922 try expect(pc == &c);1922 try expect(pc == &c);
1923 }1923 }
1924}1924}
test/behavior/struct.zig+6-6
...@@ -1392,13 +1392,13 @@ test "fieldParentPtr of a zero-bit field" {...@@ -1392,13 +1392,13 @@ test "fieldParentPtr of a zero-bit field" {
1392 {1392 {
1393 const a = A{ .u = 0 };1393 const a = A{ .u = 0 };
1394 const b_ptr = &a.b;1394 const b_ptr = &a.b;
1395 const a_ptr = @fieldParentPtr(*const A, "b", b_ptr);1395 const a_ptr: *const A = @fieldParentPtr("b", b_ptr);
1396 try std.testing.expectEqual(&a, a_ptr);1396 try std.testing.expectEqual(&a, a_ptr);
1397 }1397 }
1398 {1398 {
1399 var a = A{ .u = 0 };1399 var a = A{ .u = 0 };
1400 const b_ptr = &a.b;1400 const b_ptr = &a.b;
1401 const a_ptr = @fieldParentPtr(*const A, "b", b_ptr);1401 const a_ptr: *A = @fieldParentPtr("b", b_ptr);
1402 try std.testing.expectEqual(&a, a_ptr);1402 try std.testing.expectEqual(&a, a_ptr);
1403 }1403 }
1404 }1404 }
...@@ -1406,17 +1406,17 @@ test "fieldParentPtr of a zero-bit field" {...@@ -1406,17 +1406,17 @@ test "fieldParentPtr of a zero-bit field" {
1406 {1406 {
1407 const a = A{ .u = 0 };1407 const a = A{ .u = 0 };
1408 const c_ptr = &a.b.c;1408 const c_ptr = &a.b.c;
1409 const b_ptr = @fieldParentPtr(*const @TypeOf(a.b), "c", c_ptr);1409 const b_ptr: @TypeOf(&a.b) = @fieldParentPtr("c", c_ptr);
1410 try std.testing.expectEqual(&a.b, b_ptr);1410 try std.testing.expectEqual(&a.b, b_ptr);
1411 const a_ptr = @fieldParentPtr(*const A, "b", b_ptr);1411 const a_ptr: *const A = @fieldParentPtr("b", b_ptr);
1412 try std.testing.expectEqual(&a, a_ptr);1412 try std.testing.expectEqual(&a, a_ptr);
1413 }1413 }
1414 {1414 {
1415 var a = A{ .u = 0 };1415 var a = A{ .u = 0 };
1416 const c_ptr = &a.b.c;1416 const c_ptr = &a.b.c;
1417 const b_ptr = @fieldParentPtr(*const @TypeOf(a.b), "c", c_ptr);1417 const b_ptr: @TypeOf(&a.b) = @fieldParentPtr("c", c_ptr);
1418 try std.testing.expectEqual(&a.b, b_ptr);1418 try std.testing.expectEqual(&a.b, b_ptr);
1419 const a_ptr = @fieldParentPtr(*const A, "b", b_ptr);1419 const a_ptr: *const A = @fieldParentPtr("b", b_ptr);
1420 try std.testing.expectEqual(&a, a_ptr);1420 try std.testing.expectEqual(&a, a_ptr);
1421 }1421 }
1422 }1422 }
test/behavior/tuple.zig+2-2
...@@ -222,7 +222,7 @@ test "fieldParentPtr of tuple" {...@@ -222,7 +222,7 @@ test "fieldParentPtr of tuple" {
222 var x: u32 = 0;222 var x: u32 = 0;
223 _ = &x;223 _ = &x;
224 const tuple = .{ x, x };224 const tuple = .{ x, x };
225 try testing.expect(&tuple == @fieldParentPtr(*const @TypeOf(tuple), "1", &tuple[1]));225 try testing.expect(&tuple == @as(@TypeOf(&tuple), @fieldParentPtr("1", &tuple[1])));
226}226}
227227
228test "fieldParentPtr of anon struct" {228test "fieldParentPtr of anon struct" {
...@@ -233,7 +233,7 @@ test "fieldParentPtr of anon struct" {...@@ -233,7 +233,7 @@ test "fieldParentPtr of anon struct" {
233 var x: u32 = 0;233 var x: u32 = 0;
234 _ = &x;234 _ = &x;
235 const anon_st = .{ .foo = x, .bar = x };235 const anon_st = .{ .foo = x, .bar = x };
236 try testing.expect(&anon_st == @fieldParentPtr(*const @TypeOf(anon_st), "bar", &anon_st.bar));236 try testing.expect(&anon_st == @as(@TypeOf(&anon_st), @fieldParentPtr("bar", &anon_st.bar)));
237}237}
238238
239test "offsetOf tuple" {239test "offsetOf tuple" {
test/cases/compile_errors/fieldParentPtr-bad_field_name.zig+2-2
...@@ -2,12 +2,12 @@ const Foo = extern struct {...@@ -2,12 +2,12 @@ const Foo = extern struct {
2 derp: i32,2 derp: i32,
3};3};
4export fn foo(a: *i32) *Foo {4export fn foo(a: *i32) *Foo {
5 return @fieldParentPtr(*Foo, "a", a);5 return @fieldParentPtr("a", a);
6}6}
77
8// error8// error
9// backend=stage29// backend=stage2
10// target=native10// target=native
11//11//
12// :5:34: error: no field named 'a' in struct 'tmp.Foo'12// :5:28: error: no field named 'a' in struct 'tmp.Foo'
13// :1:20: note: struct declared here13// :1:20: note: struct declared here
test/cases/compile_errors/fieldParentPtr-comptime_field_ptr_not_based_on_struct.zig+1-1
...@@ -9,7 +9,7 @@ const foo = Foo{...@@ -9,7 +9,7 @@ const foo = Foo{
99
10comptime {10comptime {
11 const field_ptr: *i32 = @ptrFromInt(0x1234);11 const field_ptr: *i32 = @ptrFromInt(0x1234);
12 const another_foo_ptr = @fieldParentPtr(*const Foo, "b", field_ptr);12 const another_foo_ptr: *const Foo = @fieldParentPtr("b", field_ptr);
13 _ = another_foo_ptr;13 _ = another_foo_ptr;
14}14}
1515
test/cases/compile_errors/fieldParentPtr-comptime_wrong_field_index.zig+2-2
...@@ -8,7 +8,7 @@ const foo = Foo{...@@ -8,7 +8,7 @@ const foo = Foo{
8};8};
99
10comptime {10comptime {
11 const another_foo_ptr = @fieldParentPtr(*const Foo, "b", &foo.a);11 const another_foo_ptr: *const Foo = @fieldParentPtr("b", &foo.a);
12 _ = another_foo_ptr;12 _ = another_foo_ptr;
13}13}
1414
...@@ -16,5 +16,5 @@ comptime {...@@ -16,5 +16,5 @@ comptime {
16// backend=stage216// backend=stage2
17// target=native17// target=native
18//18//
19// :11:29: error: field 'b' has index '1' but pointer value is index '0' of struct 'tmp.Foo'19// :11:41: error: field 'b' has index '1' but pointer value is index '0' of struct 'tmp.Foo'
20// :1:13: note: struct declared here20// :1:13: note: struct declared here
test/cases/compile_errors/fieldParentPtr-field_pointer_is_not_pointer.zig+3-3
...@@ -1,12 +1,12 @@...@@ -1,12 +1,12 @@
1const Foo = extern struct {1const Foo = extern struct {
2 a: i32,2 a: i32,
3};3};
4export fn foo(a: i32) *Foo {4export fn foo(a: i32) *const Foo {
5 return @fieldParentPtr(*const Foo, "a", a);5 return @fieldParentPtr("a", a);
6}6}
77
8// error8// error
9// backend=stage29// backend=stage2
10// target=native10// target=native
11//11//
12// :5:45: error: expected pointer type, found 'i32'12// :5:33: error: expected pointer type, found 'i32'
test/cases/compile_errors/fieldParentPtr-non_pointer.zig+3-3
...@@ -1,10 +1,10 @@...@@ -1,10 +1,10 @@
1const Foo = i32;1const Foo = i32;
2export fn foo(a: *i32) *Foo {2export fn foo(a: *i32) Foo {
3 return @fieldParentPtr(Foo, "a", a);3 return @fieldParentPtr("a", a);
4}4}
55
6// error6// error
7// backend=llvm7// backend=llvm
8// target=native8// target=native
9//9//
10// :3:28: error: expected pointer type, found 'i32'10// :3:12: error: expected pointer type, found 'i32'
test/cases/compile_errors/fieldParentPtr_on_comptime_field.zig+2-2
...@@ -5,7 +5,7 @@ pub export fn entry1() void {...@@ -5,7 +5,7 @@ pub export fn entry1() void {
5 @offsetOf(T, "a");5 @offsetOf(T, "a");
6}6}
7pub export fn entry2() void {7pub export fn entry2() void {
8 @fieldParentPtr(*T, "a", undefined);8 @as(*T, @fieldParentPtr("a", undefined));
9}9}
1010
11// error11// error
...@@ -13,4 +13,4 @@ pub export fn entry2() void {...@@ -13,4 +13,4 @@ pub export fn entry2() void {
13// target=native13// target=native
14//14//
15// :5:5: error: no offset available for comptime field15// :5:5: error: no offset available for comptime field
16// :8:25: error: cannot get @fieldParentPtr of a comptime field16// :8:29: error: cannot get @fieldParentPtr of a comptime field
test/standalone/cmakedefine/build.zig+1-1
...@@ -86,7 +86,7 @@ fn compare_headers(step: *std.Build.Step, prog_node: *std.Progress.Node) !void {...@@ -86,7 +86,7 @@ fn compare_headers(step: *std.Build.Step, prog_node: *std.Progress.Node) !void {
86 const expected_fmt = "expected_{s}";86 const expected_fmt = "expected_{s}";
8787
88 for (step.dependencies.items) |config_header_step| {88 for (step.dependencies.items) |config_header_step| {
89 const config_header = @fieldParentPtr(*ConfigHeader, "step", config_header_step);89 const config_header: *ConfigHeader = @fieldParentPtr("step", config_header_step);
9090
91 const zig_header_path = config_header.output_file.path orelse @panic("Could not locate header file");91 const zig_header_path = config_header.output_file.path orelse @panic("Could not locate header file");
9292