authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-31 20:39:33-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-31 20:39:33-05:00
log42945a269ad5d746eed1acb20696723d18ec8653
tree5f243d0d9ecf6330f6bbca0872f6fa37f8ff6176
parent5749f706ef866b3c77d6fb8fda9ed08e5c118f58
signature Commit is signed but in an unrecognized format.

translate-c: better mangling strategy

Block-local identifiers have block-local mangling numbers, and more consistent mangling is applied within blocks. Parameters, for example, are treated the same as other block-local variables, and are not mangled unless they conflict with another name in scope.

2 files changed, 228 insertions(+), 227 deletions(-)

src-self-hosted/translate_c.zig+44-43
...@@ -64,6 +64,7 @@ const Scope = struct {...@@ -64,6 +64,7 @@ const Scope = struct {
64 block_node: *ast.Node.Block,64 block_node: *ast.Node.Block,
65 variables: AliasList,65 variables: AliasList,
66 label: ?[]const u8,66 label: ?[]const u8,
67 mangle_count: u32 = 0,
6768
68 /// Don't forget to set rbrace token and block_node later69 /// Don't forget to set rbrace token and block_node later
69 fn init(c: *Context, parent: *Scope, label: ?[]const u8) !*Block {70 fn init(c: *Context, parent: *Scope, label: ?[]const u8) !*Block {
...@@ -80,7 +81,18 @@ const Scope = struct {...@@ -80,7 +81,18 @@ const Scope = struct {
80 return block;81 return block;
81 }82 }
8283
83 fn getAlias(scope: *Block, name: []const u8) ?[]const u8 {84 /// Given the desired name, return a name that does not shadow anything from outer scopes.
85 fn makeMangledName(scope: *Block, c: *Context, name: []const u8) ![]const u8 {
86 var proposed_name = name;
87 while (scope.contains(proposed_name)) {
88 scope.mangle_count += 1;
89 proposed_name = try std.fmt.allocPrint(c.a(), "{}_{}", .{ name, scope.mangle_count });
90 }
91 try scope.variables.push(.{ .name = name, .alias = proposed_name });
92 return proposed_name;
93 }
94
95 fn getAlias(scope: *Block, name: []const u8) []const u8 {
84 var it = scope.variables.iterator(0);96 var it = scope.variables.iterator(0);
85 while (it.next()) |p| {97 while (it.next()) |p| {
86 if (mem.eql(u8, p.name, name))98 if (mem.eql(u8, p.name, name))
...@@ -89,12 +101,18 @@ const Scope = struct {...@@ -89,12 +101,18 @@ const Scope = struct {
89 return scope.base.parent.?.getAlias(name);101 return scope.base.parent.?.getAlias(name);
90 }102 }
91103
92 fn contains(scope: *Block, name: []const u8) bool {104 fn localContains(scope: *Block, name: []const u8) bool {
93 var it = scope.variables.iterator(0);105 var it = scope.variables.iterator(0);
94 while (it.next()) |p| {106 while (it.next()) |p| {
95 if (mem.eql(u8, p.name, name))107 if (mem.eql(u8, p.name, name))
96 return true;108 return true;
97 }109 }
110 return false;
111 }
112
113 fn contains(scope: *Block, name: []const u8) bool {
114 if (scope.localContains(name))
115 return true;
98 return scope.base.parent.?.contains(name);116 return scope.base.parent.?.contains(name);
99 }117 }
100 };118 };
...@@ -116,7 +134,9 @@ const Scope = struct {...@@ -116,7 +134,9 @@ const Scope = struct {
116 }134 }
117135
118 fn contains(scope: *Root, name: []const u8) bool {136 fn contains(scope: *Root, name: []const u8) bool {
119 return scope.sym_table.contains(name) or scope.macro_table.contains(name);137 return isZigPrimitiveType(name) or
138 scope.sym_table.contains(name) or
139 scope.macro_table.contains(name);
120 }140 }
121 };141 };
122142
...@@ -135,16 +155,9 @@ const Scope = struct {...@@ -135,16 +155,9 @@ const Scope = struct {
135 }155 }
136 }156 }
137157
138 fn createAlias(scope: *Scope, c: *Context, name: []const u8) !?[]const u8 {158 fn getAlias(scope: *Scope, name: []const u8) []const u8 {
139 if (isZigPrimitiveType(name) or scope.contains(name)) {
140 return try std.fmt.allocPrint(c.a(), "{}_{}", .{ name, c.getMangle() });
141 }
142 return null;
143 }
144
145 fn getAlias(scope: *Scope, name: []const u8) ?[]const u8 {
146 return switch (scope.id) {159 return switch (scope.id) {
147 .Root => null,160 .Root => return name,
148 .Block => @fieldParentPtr(Block, "base", scope).getAlias(name),161 .Block => @fieldParentPtr(Block, "base", scope).getAlias(name),
149 .Switch, .Loop, .Condition => scope.parent.?.getAlias(name),162 .Switch, .Loop, .Condition => scope.parent.?.getAlias(name),
150 };163 };
...@@ -191,9 +204,9 @@ pub const Context = struct {...@@ -191,9 +204,9 @@ pub const Context = struct {
191 alias_list: AliasList,204 alias_list: AliasList,
192 global_scope: *Scope.Root,205 global_scope: *Scope.Root,
193 clang_context: *ZigClangASTContext,206 clang_context: *ZigClangASTContext,
194 mangle_count: u64 = 0,207 mangle_count: u32 = 0,
195208
196 fn getMangle(c: *Context) u64 {209 fn getMangle(c: *Context) u32 {
197 c.mangle_count += 1;210 c.mangle_count += 1;
198 return c.mangle_count;211 return c.mangle_count;
199 }212 }
...@@ -410,19 +423,14 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void {...@@ -410,19 +423,14 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void {
410 const param_name = tokenSlice(c, param.name_token orelse423 const param_name = tokenSlice(c, param.name_token orelse
411 return failDecl(c, fn_decl_loc, fn_name, "function {} parameter has no name", .{fn_name}));424 return failDecl(c, fn_decl_loc, fn_name, "function {} parameter has no name", .{fn_name}));
412425
413 // in Zig top level declarations are order-independent so this might be shadowed later426 const mangled_param_name = try block_scope.makeMangledName(c, param_name);
414 const checked_param_name = try std.fmt.allocPrint(c.a(), "{}_{}", .{ param_name, c.getMangle() });
415 try block_scope.variables.push(.{ .name = param_name, .alias = checked_param_name });
416427
417 const arg_name = blk: {428 const arg_name = blk: {
418 const bare_arg_name = try std.fmt.allocPrint(c.a(), "_arg_{}", .{checked_param_name});429 const bare_arg_name = try std.fmt.allocPrint(c.a(), "arg_{}", .{mangled_param_name});
419 break :blk if (try scope.createAlias(rp.c, bare_arg_name)) |a|430 break :blk try block_scope.makeMangledName(c, bare_arg_name);
420 a
421 else
422 bare_arg_name;
423 };431 };
424432
425 const node = try transCreateNodeVarDecl(c, false, false, checked_param_name);433 const node = try transCreateNodeVarDecl(c, false, false, mangled_param_name);
426 node.eq_token = try appendToken(c, .Equal, "=");434 node.eq_token = try appendToken(c, .Equal, "=");
427 node.init_node = try transCreateNodeIdentifier(c, arg_name);435 node.init_node = try transCreateNodeIdentifier(c, arg_name);
428 node.semicolon_token = try appendToken(c, .Semicolon, ";");436 node.semicolon_token = try appendToken(c, .Semicolon, ";");
...@@ -1143,11 +1151,8 @@ fn transDeclStmt(rp: RestorePoint, scope: *Scope, stmt: *const ZigClangDeclStmt)...@@ -1143,11 +1151,8 @@ fn transDeclStmt(rp: RestorePoint, scope: *Scope, stmt: *const ZigClangDeclStmt)
1143 const name = try c.str(ZigClangDecl_getName_bytes_begin(1151 const name = try c.str(ZigClangDecl_getName_bytes_begin(
1144 @ptrCast(*const ZigClangDecl, var_decl),1152 @ptrCast(*const ZigClangDecl, var_decl),
1145 ));1153 ));
1146 const checked_name = if (try scope.createAlias(c, name)) |a| blk: {1154 const mangled_name = try block_scope.makeMangledName(c, name);
1147 try block_scope.variables.push(.{ .name = name, .alias = a });1155 const node = try transCreateNodeVarDecl(c, false, ZigClangQualType_isConstQualified(qual_type), mangled_name);
1148 break :blk a;
1149 } else name;
1150 const node = try transCreateNodeVarDecl(c, false, ZigClangQualType_isConstQualified(qual_type), checked_name);
11511156
1152 _ = try appendToken(c, .Colon, ":");1157 _ = try appendToken(c, .Colon, ":");
1153 const loc = ZigClangStmt_getBeginLoc(@ptrCast(*const ZigClangStmt, stmt));1158 const loc = ZigClangStmt_getBeginLoc(@ptrCast(*const ZigClangStmt, stmt));
...@@ -1188,8 +1193,8 @@ fn transDeclRefExpr(...@@ -1188,8 +1193,8 @@ fn transDeclRefExpr(
1188) TransError!*ast.Node {1193) TransError!*ast.Node {
1189 const value_decl = ZigClangDeclRefExpr_getDecl(expr);1194 const value_decl = ZigClangDeclRefExpr_getDecl(expr);
1190 const name = try rp.c.str(ZigClangDecl_getName_bytes_begin(@ptrCast(*const ZigClangDecl, value_decl)));1195 const name = try rp.c.str(ZigClangDecl_getName_bytes_begin(@ptrCast(*const ZigClangDecl, value_decl)));
1191 const checked_name = if (scope.getAlias(name)) |a| a else name;1196 const mangled_name = scope.getAlias(name);
1192 return transCreateNodeIdentifier(rp.c, checked_name);1197 return transCreateNodeIdentifier(rp.c, mangled_name);
1193}1198}
11941199
1195fn transImplicitCastExpr(1200fn transImplicitCastExpr(
...@@ -2318,7 +2323,7 @@ fn transCreatePreCrement(...@@ -2318,7 +2323,7 @@ fn transCreatePreCrement(
2318 // zig: })2323 // zig: })
2319 const block_scope = try Scope.Block.init(rp.c, scope, "blk");2324 const block_scope = try Scope.Block.init(rp.c, scope, "blk");
2320 block_scope.block_node = try transCreateNodeBlock(rp.c, block_scope.label);2325 block_scope.block_node = try transCreateNodeBlock(rp.c, block_scope.label);
2321 const ref = try std.fmt.allocPrint(rp.c.a(), "_ref_{}", .{rp.c.getMangle()});2326 const ref = try block_scope.makeMangledName(rp.c, "ref");
23222327
2323 const node = try transCreateNodeVarDecl(rp.c, false, true, ref);2328 const node = try transCreateNodeVarDecl(rp.c, false, true, ref);
2324 node.eq_token = try appendToken(rp.c, .Equal, "=");2329 node.eq_token = try appendToken(rp.c, .Equal, "=");
...@@ -2383,7 +2388,7 @@ fn transCreatePostCrement(...@@ -2383,7 +2388,7 @@ fn transCreatePostCrement(
2383 // zig: })2388 // zig: })
2384 const block_scope = try Scope.Block.init(rp.c, scope, "blk");2389 const block_scope = try Scope.Block.init(rp.c, scope, "blk");
2385 block_scope.block_node = try transCreateNodeBlock(rp.c, block_scope.label);2390 block_scope.block_node = try transCreateNodeBlock(rp.c, block_scope.label);
2386 const ref = try std.fmt.allocPrint(rp.c.a(), "_ref_{}", .{rp.c.getMangle()});2391 const ref = try block_scope.makeMangledName(rp.c, "ref");
23872392
2388 const node = try transCreateNodeVarDecl(rp.c, false, true, ref);2393 const node = try transCreateNodeVarDecl(rp.c, false, true, ref);
2389 node.eq_token = try appendToken(rp.c, .Equal, "=");2394 node.eq_token = try appendToken(rp.c, .Equal, "=");
...@@ -2397,7 +2402,7 @@ fn transCreatePostCrement(...@@ -2397,7 +2402,7 @@ fn transCreatePostCrement(
2397 const ref_node = try transCreateNodePtrDeref(rp.c, lhs_node);2402 const ref_node = try transCreateNodePtrDeref(rp.c, lhs_node);
2398 _ = try appendToken(rp.c, .Semicolon, ";");2403 _ = try appendToken(rp.c, .Semicolon, ";");
23992404
2400 const tmp = try std.fmt.allocPrint(rp.c.a(), "_tmp_{}", .{rp.c.getMangle()});2405 const tmp = try block_scope.makeMangledName(rp.c, "tmp");
2401 const tmp_node = try transCreateNodeVarDecl(rp.c, false, true, tmp);2406 const tmp_node = try transCreateNodeVarDecl(rp.c, false, true, tmp);
2402 tmp_node.eq_token = try appendToken(rp.c, .Equal, "=");2407 tmp_node.eq_token = try appendToken(rp.c, .Equal, "=");
2403 tmp_node.init_node = ref_node;2408 tmp_node.init_node = ref_node;
...@@ -2499,7 +2504,7 @@ fn transCreateCompoundAssign(...@@ -2499,7 +2504,7 @@ fn transCreateCompoundAssign(
2499 // zig: })2504 // zig: })
2500 const block_scope = try Scope.Block.init(rp.c, scope, "blk");2505 const block_scope = try Scope.Block.init(rp.c, scope, "blk");
2501 block_scope.block_node = try transCreateNodeBlock(rp.c, block_scope.label);2506 block_scope.block_node = try transCreateNodeBlock(rp.c, block_scope.label);
2502 const ref = try std.fmt.allocPrint(rp.c.a(), "_ref_{}", .{rp.c.getMangle()});2507 const ref = try block_scope.makeMangledName(rp.c, "ref");
25032508
2504 const node = try transCreateNodeVarDecl(rp.c, false, true, ref);2509 const node = try transCreateNodeVarDecl(rp.c, false, true, ref);
2505 node.eq_token = try appendToken(rp.c, .Equal, "=");2510 node.eq_token = try appendToken(rp.c, .Equal, "=");
...@@ -2962,7 +2967,7 @@ fn transCreateNodeAssign(...@@ -2962,7 +2967,7 @@ fn transCreateNodeAssign(
2962 // zig: })2967 // zig: })
2963 const block_scope = try Scope.Block.init(rp.c, scope, "blk");2968 const block_scope = try Scope.Block.init(rp.c, scope, "blk");
2964 block_scope.block_node = try transCreateNodeBlock(rp.c, block_scope.label);2969 block_scope.block_node = try transCreateNodeBlock(rp.c, block_scope.label);
2965 const tmp = try std.fmt.allocPrint(rp.c.a(), "_tmp_{}", .{rp.c.getMangle()});2970 const tmp = try block_scope.makeMangledName(rp.c, "tmp");
29662971
2967 const node = try transCreateNodeVarDecl(rp.c, false, true, tmp);2972 const node = try transCreateNodeVarDecl(rp.c, false, true, tmp);
2968 node.eq_token = try appendToken(rp.c, .Equal, "=");2973 node.eq_token = try appendToken(rp.c, .Equal, "=");
...@@ -4198,12 +4203,8 @@ fn transMacroFnDefine(c: *Context, it: *ctok.TokenList.Iterator, name: []const u...@@ -4198,12 +4203,8 @@ fn transMacroFnDefine(c: *Context, it: *ctok.TokenList.Iterator, name: []const u
4198 );4203 );
4199 }4204 }
42004205
4201 const checked_name = if (try scope.createAlias(c, param_tok.bytes)) |alias| blk: {4206 const mangled_name = try block_scope.makeMangledName(c, param_tok.bytes);
4202 try block_scope.variables.push(.{ .name = param_tok.bytes, .alias = alias });4207 const param_name_tok = try appendIdentifier(c, mangled_name);
4203 break :blk alias;
4204 } else param_tok.bytes;
4205
4206 const param_name_tok = try appendIdentifier(c, checked_name);
4207 _ = try appendToken(c, .Colon, ":");4208 _ = try appendToken(c, .Colon, ":");
42084209
4209 const token_index = try appendToken(c, .Keyword_var, "var");4210 const token_index = try appendToken(c, .Keyword_var, "var");
...@@ -4384,8 +4385,8 @@ fn parseCPrimaryExpr(c: *Context, it: *ctok.TokenList.Iterator, source_loc: ZigC...@@ -4384,8 +4385,8 @@ fn parseCPrimaryExpr(c: *Context, it: *ctok.TokenList.Iterator, source_loc: ZigC
4384 return parseCNumLit(c, tok, source_loc);4385 return parseCNumLit(c, tok, source_loc);
4385 },4386 },
4386 .Identifier => {4387 .Identifier => {
4387 const name = if (scope.getAlias(tok.bytes)) |a| a else tok.bytes;4388 const mangled_name = scope.getAlias(tok.bytes);
4388 return transCreateNodeIdentifier(c, name);4389 return transCreateNodeIdentifier(c, mangled_name);
4389 },4390 },
4390 .LParen => {4391 .LParen => {
4391 const inner_node = try parseCExpr(c, it, source_loc, scope);4392 const inner_node = try parseCExpr(c, it, source_loc, scope);
test/translate_c.zig+184-184
...@@ -1106,8 +1106,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1106,8 +1106,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1106 \\pub var a: c_long = @intCast(c_long, 2);1106 \\pub var a: c_long = @intCast(c_long, 2);
1107 \\pub var b: c_long = @intCast(c_long, 2);1107 \\pub var b: c_long = @intCast(c_long, 2);
1108 \\pub var c: c_int = 4;1108 \\pub var c: c_int = 4;
1109 \\pub export fn foo(_arg_c_1: u8) void {1109 \\pub export fn foo(arg_c_1: u8) void {
1110 \\ var c_1 = _arg_c_1;1110 \\ var c_1 = arg_c_1;
1111 \\ var a_2: c_int = undefined;1111 \\ var a_2: c_int = undefined;
1112 \\ var b_3: u8 = @intCast(u8, 123);1112 \\ var b_3: u8 = @intCast(u8, 123);
1113 \\ b_3 = @intCast(u8, a_2);1113 \\ b_3 = @intCast(u8, a_2);
...@@ -1144,9 +1144,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1144,9 +1144,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1144 \\ var a: c_int = undefined;1144 \\ var a: c_int = undefined;
1145 \\ var b: c_int = undefined;1145 \\ var b: c_int = undefined;
1146 \\ a = blk: {1146 \\ a = blk: {
1147 \\ const _tmp_1 = 2;1147 \\ const tmp = 2;
1148 \\ b = _tmp_1;1148 \\ b = tmp;
1149 \\ break :blk _tmp_1;1149 \\ break :blk tmp;
1150 \\ };1150 \\ };
1151 \\}1151 \\}
1152 });1152 });
...@@ -1197,14 +1197,14 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1197,14 +1197,14 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1197 \\ var a: c_int = 5;1197 \\ var a: c_int = 5;
1198 \\ while (2 != 0) a = 2;1198 \\ while (2 != 0) a = 2;
1199 \\ while (4 != 0) {1199 \\ while (4 != 0) {
1200 \\ var a: c_int = 4;1200 \\ var a_1: c_int = 4;
1201 \\ a = 9;1201 \\ a_1 = 9;
1202 \\ _ = 6;1202 \\ _ = 6;
1203 \\ return a;1203 \\ return a_1;
1204 \\ }1204 \\ }
1205 \\ while (true) {1205 \\ while (true) {
1206 \\ var a: c_int = 2;1206 \\ var a_1: c_int = 2;
1207 \\ a = 12;1207 \\ a_1 = 12;
1208 \\ if (!(4 != 0)) break;1208 \\ if (!(4 != 0)) break;
1209 \\ }1209 \\ }
1210 \\ while (true) {1210 \\ while (true) {
...@@ -1284,15 +1284,15 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1284,15 +1284,15 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1284 \\ }1284 \\ }
1285 \\}1285 \\}
1286 , &[_][]const u8{1286 , &[_][]const u8{
1287 \\pub export fn switch_fn(_arg_i_1: c_int) c_int {1287 \\pub export fn switch_fn(arg_i: c_int) c_int {
1288 \\ var i_1 = _arg_i_1;1288 \\ var i = arg_i;
1289 \\ var res: c_int = 0;1289 \\ var res: c_int = 0;
1290 \\ __switch: {1290 \\ __switch: {
1291 \\ __case_2: {1291 \\ __case_2: {
1292 \\ __default: {1292 \\ __default: {
1293 \\ __case_1: {1293 \\ __case_1: {
1294 \\ __case_0: {1294 \\ __case_0: {
1295 \\ switch (i_1) {1295 \\ switch (i) {
1296 \\ 0 => break :__case_0,1296 \\ 0 => break :__case_0,
1297 \\ 1...3 => break :__case_1,1297 \\ 1...3 => break :__case_1,
1298 \\ else => break :__default,1298 \\ else => break :__default,
...@@ -1303,7 +1303,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1303,7 +1303,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1303 \\ }1303 \\ }
1304 \\ res = 2;1304 \\ res = 2;
1305 \\ }1305 \\ }
1306 \\ res = (3 * i_1);1306 \\ res = (3 * i);
1307 \\ break :__switch;1307 \\ break :__switch;
1308 \\ }1308 \\ }
1309 \\ res = 5;1309 \\ res = 5;
...@@ -1346,11 +1346,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1346,11 +1346,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1346 \\ a = tmp;1346 \\ a = tmp;
1347 \\}1347 \\}
1348 , &[_][]const u8{1348 , &[_][]const u8{
1349 \\pub export fn max(_arg_a_1: c_int) c_int {1349 \\pub export fn max(arg_a: c_int) c_int {
1350 \\ var a_1 = _arg_a_1;1350 \\ var a = arg_a;
1351 \\ var tmp: c_int = undefined;1351 \\ var tmp: c_int = undefined;
1352 \\ tmp = a_1;1352 \\ tmp = a;
1353 \\ a_1 = tmp;1353 \\ a = tmp;
1354 \\}1354 \\}
1355 });1355 });
13561356
...@@ -1360,14 +1360,14 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1360,14 +1360,14 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1360 \\ c = b = a;1360 \\ c = b = a;
1361 \\}1361 \\}
1362 , &[_][]const u8{1362 , &[_][]const u8{
1363 \\pub export fn max(_arg_a_1: c_int) void {1363 \\pub export fn max(arg_a: c_int) void {
1364 \\ var a_1 = _arg_a_1;1364 \\ var a = arg_a;
1365 \\ var b: c_int = undefined;1365 \\ var b: c_int = undefined;
1366 \\ var c: c_int = undefined;1366 \\ var c: c_int = undefined;
1367 \\ c = blk: {1367 \\ c = blk: {
1368 \\ const _tmp_2 = a_1;1368 \\ const tmp = a;
1369 \\ b = _tmp_2;1369 \\ b = tmp;
1370 \\ break :blk _tmp_2;1370 \\ break :blk tmp;
1371 \\ };1371 \\ };
1372 \\}1372 \\}
1373 });1373 });
...@@ -1391,9 +1391,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1391,9 +1391,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1391 \\ return (int)a;1391 \\ return (int)a;
1392 \\}1392 \\}
1393 , &[_][]const u8{1393 , &[_][]const u8{
1394 \\pub export fn float_to_int(_arg_a_1: f32) c_int {1394 \\pub export fn float_to_int(arg_a: f32) c_int {
1395 \\ var a_1 = _arg_a_1;1395 \\ var a = arg_a;
1396 \\ return @floatToInt(c_int, a_1);1396 \\ return @floatToInt(c_int, a);
1397 \\}1397 \\}
1398 });1398 });
13991399
...@@ -1487,23 +1487,23 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1487,23 +1487,23 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1487 \\ C,1487 \\ C,
1488 \\};1488 \\};
1489 \\pub const SomeTypedef = c_int;1489 \\pub const SomeTypedef = c_int;
1490 \\pub export fn and_or_non_bool(_arg_a_1: c_int, _arg_b_2: f32, _arg_c_3: ?*c_void) c_int {1490 \\pub export fn and_or_non_bool(arg_a: c_int, arg_b: f32, arg_c: ?*c_void) c_int {
1491 \\ var a_1 = _arg_a_1;1491 \\ var a = arg_a;
1492 \\ var b_2 = _arg_b_2;1492 \\ var b = arg_b;
1493 \\ var c_3 = _arg_c_3;1493 \\ var c = arg_c;
1494 \\ var d: enum_Foo = @intToEnum(enum_Foo, FooA);1494 \\ var d: enum_Foo = @intToEnum(enum_Foo, FooA);
1495 \\ var e: c_int = @boolToInt(((a_1 != 0) and (b_2 != 0)));1495 \\ var e: c_int = @boolToInt(((a != 0) and (b != 0)));
1496 \\ var f: c_int = @boolToInt(((b_2 != 0) and (c_3 != null)));1496 \\ var f: c_int = @boolToInt(((b != 0) and (c != null)));
1497 \\ var g: c_int = @boolToInt(((a_1 != 0) and (c_3 != null)));1497 \\ var g: c_int = @boolToInt(((a != 0) and (c != null)));
1498 \\ var h: c_int = @boolToInt(((a_1 != 0) or (b_2 != 0)));1498 \\ var h: c_int = @boolToInt(((a != 0) or (b != 0)));
1499 \\ var i: c_int = @boolToInt(((b_2 != 0) or (c_3 != null)));1499 \\ var i: c_int = @boolToInt(((b != 0) or (c != null)));
1500 \\ var j: c_int = @boolToInt(((a_1 != 0) or (c_3 != null)));1500 \\ var j: c_int = @boolToInt(((a != 0) or (c != null)));
1501 \\ var k: c_int = @boolToInt(((a_1 != 0) or (@enumToInt(d) != 0)));1501 \\ var k: c_int = @boolToInt(((a != 0) or (@enumToInt(d) != 0)));
1502 \\ var l: c_int = @boolToInt(((@enumToInt(d) != 0) and (b_2 != 0)));1502 \\ var l: c_int = @boolToInt(((@enumToInt(d) != 0) and (b != 0)));
1503 \\ var m: c_int = @boolToInt(((c_3 != null) or (@enumToInt(d) != 0)));1503 \\ var m: c_int = @boolToInt(((c != null) or (@enumToInt(d) != 0)));
1504 \\ var td: SomeTypedef = 44;1504 \\ var td: SomeTypedef = 44;
1505 \\ var o: c_int = @boolToInt(((td != 0) or (b_2 != 0)));1505 \\ var o: c_int = @boolToInt(((td != 0) or (b != 0)));
1506 \\ var p: c_int = @boolToInt(((c_3 != null) and (td != 0)));1506 \\ var p: c_int = @boolToInt(((c != null) and (td != 0)));
1507 \\ return ((((((((((e + f) + g) + h) + i) + j) + k) + l) + m) + o) + p);1507 \\ return ((((((((((e + f) + g) + h) + i) + j) + k) + l) + m) + o) + p);
1508 \\}1508 \\}
1509 ,1509 ,
...@@ -1541,10 +1541,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1541,10 +1541,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1541 \\ return (a & b) ^ (a | b);1541 \\ return (a & b) ^ (a | b);
1542 \\}1542 \\}
1543 , &[_][]const u8{1543 , &[_][]const u8{
1544 \\pub export fn max(_arg_a_1: c_int, _arg_b_2: c_int) c_int {1544 \\pub export fn max(arg_a: c_int, arg_b: c_int) c_int {
1545 \\ var a_1 = _arg_a_1;1545 \\ var a = arg_a;
1546 \\ var b_2 = _arg_b_2;1546 \\ var b = arg_b;
1547 \\ return ((a_1 & b_2) ^ (a_1 | b_2));1547 \\ return ((a & b) ^ (a | b));
1548 \\}1548 \\}
1549 });1549 });
15501550
...@@ -1560,13 +1560,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1560,13 +1560,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1560 \\ return i;1560 \\ return i;
1561 \\}1561 \\}
1562 , &[_][]const u8{1562 , &[_][]const u8{
1563 \\pub export fn test_comparisons(_arg_a_1: c_int, _arg_b_2: c_int) c_int {1563 \\pub export fn test_comparisons(arg_a: c_int, arg_b: c_int) c_int {
1564 \\ var a_1 = _arg_a_1;1564 \\ var a = arg_a;
1565 \\ var b_2 = _arg_b_2;1565 \\ var b = arg_b;
1566 \\ var c: c_int = @boolToInt((a_1 < b_2));1566 \\ var c: c_int = @boolToInt((a < b));
1567 \\ var d: c_int = @boolToInt((a_1 > b_2));1567 \\ var d: c_int = @boolToInt((a > b));
1568 \\ var e: c_int = @boolToInt((a_1 <= b_2));1568 \\ var e: c_int = @boolToInt((a <= b));
1569 \\ var f: c_int = @boolToInt((a_1 >= b_2));1569 \\ var f: c_int = @boolToInt((a >= b));
1570 \\ var g: c_int = @boolToInt((c < d));1570 \\ var g: c_int = @boolToInt((c < d));
1571 \\ var h: c_int = @boolToInt((e < f));1571 \\ var h: c_int = @boolToInt((e < f));
1572 \\ var i: c_int = @boolToInt((g < h));1572 \\ var i: c_int = @boolToInt((g < h));
...@@ -1583,12 +1583,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1583,12 +1583,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1583 \\ return a;1583 \\ return a;
1584 \\}1584 \\}
1585 , &[_][]const u8{1585 , &[_][]const u8{
1586 \\pub export fn max(_arg_a_1: c_int, _arg_b_2: c_int) c_int {1586 \\pub export fn max(arg_a: c_int, arg_b: c_int) c_int {
1587 \\ var a_1 = _arg_a_1;1587 \\ var a = arg_a;
1588 \\ var b_2 = _arg_b_2;1588 \\ var b = arg_b;
1589 \\ if (a_1 == b_2) return a_1;1589 \\ if (a == b) return a;
1590 \\ if (a_1 != b_2) return b_2;1590 \\ if (a != b) return b;
1591 \\ return a_1;1591 \\ return a;
1592 \\}1592 \\}
1593 });1593 });
15941594
...@@ -1661,9 +1661,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1661,9 +1661,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1661 \\}1661 \\}
1662 , &[_][]const u8{1662 , &[_][]const u8{
1663 \\pub export var array: [100]c_int = .{0} ** 100;1663 \\pub export var array: [100]c_int = .{0} ** 100;
1664 \\pub export fn foo(_arg_index_1: c_int) c_int {1664 \\pub export fn foo(arg_index: c_int) c_int {
1665 \\ var index_1 = _arg_index_1;1665 \\ var index = arg_index;
1666 \\ return array[index_1];1666 \\ return array[index];
1667 \\}1667 \\}
1668 ,1668 ,
1669 \\pub const ACCESS = array[2];1669 \\pub const ACCESS = array[2];
...@@ -1686,12 +1686,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1686,12 +1686,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1686 \\ return a;1686 \\ return a;
1687 \\}1687 \\}
1688 , &[_][]const u8{1688 , &[_][]const u8{
1689 \\pub export fn max(_arg_a_1: c_int, _arg_b_2: c_int) c_int {1689 \\pub export fn max(arg_a: c_int, arg_b: c_int) c_int {
1690 \\ var a_1 = _arg_a_1;1690 \\ var a = arg_a;
1691 \\ var b_2 = _arg_b_2;1691 \\ var b = arg_b;
1692 \\ if ((a_1 < b_2) or (a_1 == b_2)) return b_2;1692 \\ if ((a < b) or (a == b)) return b;
1693 \\ if ((a_1 >= b_2) and (a_1 == b_2)) return a_1;1693 \\ if ((a >= b) and (a == b)) return a;
1694 \\ return a_1;1694 \\ return a;
1695 \\}1695 \\}
1696 });1696 });
16971697
...@@ -1708,12 +1708,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1708,12 +1708,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1708 \\ if (a < b) ; else ;1708 \\ if (a < b) ; else ;
1709 \\}1709 \\}
1710 , &[_][]const u8{1710 , &[_][]const u8{
1711 \\pub export fn max(_arg_a_1: c_int, _arg_b_2: c_int) c_int {1711 \\pub export fn max(arg_a: c_int, arg_b: c_int) c_int {
1712 \\ var a_1 = _arg_a_1;1712 \\ var a = arg_a;
1713 \\ var b_2 = _arg_b_2;1713 \\ var b = arg_b;
1714 \\ if (a_1 < b_2) return b_2;1714 \\ if (a < b) return b;
1715 \\ if (a_1 < b_2) return b_2 else return a_1;1715 \\ if (a < b) return b else return a;
1716 \\ if (a_1 < b_2) {} else {}1716 \\ if (a < b) {} else {}
1717 \\}1717 \\}
1718 });1718 });
17191719
...@@ -1732,15 +1732,15 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1732,15 +1732,15 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1732 \\ B,1732 \\ B,
1733 \\ C,1733 \\ C,
1734 \\};1734 \\};
1735 \\pub export fn if_none_bool(_arg_a_1: c_int, _arg_b_2: f32, _arg_c_3: ?*c_void, _arg_d_4: enum_SomeEnum) c_int {1735 \\pub export fn if_none_bool(arg_a: c_int, arg_b: f32, arg_c: ?*c_void, arg_d: enum_SomeEnum) c_int {
1736 \\ var a_1 = _arg_a_1;1736 \\ var a = arg_a;
1737 \\ var b_2 = _arg_b_2;1737 \\ var b = arg_b;
1738 \\ var c_3 = _arg_c_3;1738 \\ var c = arg_c;
1739 \\ var d_4 = _arg_d_4;1739 \\ var d = arg_d;
1740 \\ if (a_1 != 0) return 0;1740 \\ if (a != 0) return 0;
1741 \\ if (b_2 != 0) return 1;1741 \\ if (b != 0) return 1;
1742 \\ if (c_3 != null) return 2;1742 \\ if (c != null) return 2;
1743 \\ if (d_4 != 0) return 3;1743 \\ if (d != 0) return 3;
1744 \\ return 4;1744 \\ return 4;
1745 \\}1745 \\}
1746 });1746 });
...@@ -1762,9 +1762,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1762,9 +1762,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1762 \\ return a < 0 ? -a : a;1762 \\ return a < 0 ? -a : a;
1763 \\}1763 \\}
1764 , &[_][]const u8{1764 , &[_][]const u8{
1765 \\pub export fn abs(_arg_a_1: c_int) c_int {1765 \\pub export fn abs(arg_a: c_int) c_int {
1766 \\ var a_1 = _arg_a_1;1766 \\ var a = arg_a;
1767 \\ return if (a_1 < 0) -a_1 else a_1;1767 \\ return if (a < 0) -a else a;
1768 \\}1768 \\}
1769 });1769 });
17701770
...@@ -1782,20 +1782,20 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1782,20 +1782,20 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1782 \\ return a;1782 \\ return a;
1783 \\}1783 \\}
1784 , &[_][]const u8{1784 , &[_][]const u8{
1785 \\pub export fn foo1(_arg_a_1: c_uint) c_uint {1785 \\pub export fn foo1(arg_a: c_uint) c_uint {
1786 \\ var a_1 = _arg_a_1;1786 \\ var a = arg_a;
1787 \\ a_1 +%= 1;1787 \\ a +%= 1;
1788 \\ return a_1;1788 \\ return a;
1789 \\}1789 \\}
1790 \\pub export fn foo2(_arg_a_2: c_int) c_int {1790 \\pub export fn foo2(arg_a: c_int) c_int {
1791 \\ var a_2 = _arg_a_2;1791 \\ var a = arg_a;
1792 \\ a_2 += 1;1792 \\ a += 1;
1793 \\ return a_2;1793 \\ return a;
1794 \\}1794 \\}
1795 \\pub export fn foo3(_arg_a_3: [*c]c_int) [*c]c_int {1795 \\pub export fn foo3(arg_a: [*c]c_int) [*c]c_int {
1796 \\ var a_3 = _arg_a_3;1796 \\ var a = arg_a;
1797 \\ a_3 += 1;1797 \\ a += 1;
1798 \\ return a_3;1798 \\ return a;
1799 \\}1799 \\}
1800 });1800 });
18011801
...@@ -1851,24 +1851,24 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1851,24 +1851,24 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1851 \\ u +%= 1;1851 \\ u +%= 1;
1852 \\ u -%= 1;1852 \\ u -%= 1;
1853 \\ i = (blk: {1853 \\ i = (blk: {
1854 \\ const _ref_1 = &i;1854 \\ const ref = &i;
1855 \\ _ref_1.* += 1;1855 \\ ref.* += 1;
1856 \\ break :blk _ref_1.*;1856 \\ break :blk ref.*;
1857 \\ });1857 \\ });
1858 \\ i = (blk: {1858 \\ i = (blk: {
1859 \\ const _ref_2 = &i;1859 \\ const ref = &i;
1860 \\ _ref_2.* -= 1;1860 \\ ref.* -= 1;
1861 \\ break :blk _ref_2.*;1861 \\ break :blk ref.*;
1862 \\ });1862 \\ });
1863 \\ u = (blk: {1863 \\ u = (blk: {
1864 \\ const _ref_3 = &u;1864 \\ const ref = &u;
1865 \\ _ref_3.* +%= 1;1865 \\ ref.* +%= 1;
1866 \\ break :blk _ref_3.*;1866 \\ break :blk ref.*;
1867 \\ });1867 \\ });
1868 \\ u = (blk: {1868 \\ u = (blk: {
1869 \\ const _ref_4 = &u;1869 \\ const ref = &u;
1870 \\ _ref_4.* -%= 1;1870 \\ ref.* -%= 1;
1871 \\ break :blk _ref_4.*;1871 \\ break :blk ref.*;
1872 \\ });1872 \\ });
1873 \\}1873 \\}
1874 });1874 });
...@@ -1882,11 +1882,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1882,11 +1882,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1882 \\ return i;1882 \\ return i;
1883 \\}1883 \\}
1884 , &[_][]const u8{1884 , &[_][]const u8{
1885 \\pub export fn log2(_arg_a_1: c_uint) c_int {1885 \\pub export fn log2(arg_a: c_uint) c_int {
1886 \\ var a_1 = _arg_a_1;1886 \\ var a = arg_a;
1887 \\ var i: c_int = 0;1887 \\ var i: c_int = 0;
1888 \\ while (a_1 > @intCast(c_uint, 0)) {1888 \\ while (a > @intCast(c_uint, 0)) {
1889 \\ a_1 >>= @as(@import("std").math.Log2Int(c_int), 1);1889 \\ a >>= @as(@import("std").math.Log2Int(c_int), 1);
1890 \\ }1890 \\ }
1891 \\ return i;1891 \\ return i;
1892 \\}1892 \\}
...@@ -1902,11 +1902,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1902,11 +1902,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1902 \\ return i;1902 \\ return i;
1903 \\}1903 \\}
1904 , &[_][]const u8{1904 , &[_][]const u8{
1905 \\pub export fn log2(_arg_a_1: u32) c_int {1905 \\pub export fn log2(arg_a: u32) c_int {
1906 \\ var a_1 = _arg_a_1;1906 \\ var a = arg_a;
1907 \\ var i: c_int = 0;1907 \\ var i: c_int = 0;
1908 \\ while (a_1 > @intCast(c_uint, 0)) {1908 \\ while (a > @intCast(c_uint, 0)) {
1909 \\ a_1 >>= @as(@import("std").math.Log2Int(c_int), 1);1909 \\ a >>= @as(@import("std").math.Log2Int(c_int), 1);
1910 \\ }1910 \\ }
1911 \\ return i;1911 \\ return i;
1912 \\}1912 \\}
...@@ -1928,44 +1928,44 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1928,44 +1928,44 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1928 \\pub export fn foo() void {1928 \\pub export fn foo() void {
1929 \\ var a: c_int = 0;1929 \\ var a: c_int = 0;
1930 \\ a += (blk: {1930 \\ a += (blk: {
1931 \\ const _ref_1 = &a;1931 \\ const ref = &a;
1932 \\ _ref_1.* = _ref_1.* + 1;1932 \\ ref.* = ref.* + 1;
1933 \\ break :blk _ref_1.*;1933 \\ break :blk ref.*;
1934 \\ });1934 \\ });
1935 \\ a -= (blk: {1935 \\ a -= (blk: {
1936 \\ const _ref_2 = &a;1936 \\ const ref = &a;
1937 \\ _ref_2.* = _ref_2.* - 1;1937 \\ ref.* = ref.* - 1;
1938 \\ break :blk _ref_2.*;1938 \\ break :blk ref.*;
1939 \\ });1939 \\ });
1940 \\ a *= (blk: {1940 \\ a *= (blk: {
1941 \\ const _ref_3 = &a;1941 \\ const ref = &a;
1942 \\ _ref_3.* = _ref_3.* * 1;1942 \\ ref.* = ref.* * 1;
1943 \\ break :blk _ref_3.*;1943 \\ break :blk ref.*;
1944 \\ });1944 \\ });
1945 \\ a &= (blk: {1945 \\ a &= (blk: {
1946 \\ const _ref_4 = &a;1946 \\ const ref = &a;
1947 \\ _ref_4.* = _ref_4.* & 1;1947 \\ ref.* = ref.* & 1;
1948 \\ break :blk _ref_4.*;1948 \\ break :blk ref.*;
1949 \\ });1949 \\ });
1950 \\ a |= (blk: {1950 \\ a |= (blk: {
1951 \\ const _ref_5 = &a;1951 \\ const ref = &a;
1952 \\ _ref_5.* = _ref_5.* | 1;1952 \\ ref.* = ref.* | 1;
1953 \\ break :blk _ref_5.*;1953 \\ break :blk ref.*;
1954 \\ });1954 \\ });
1955 \\ a ^= (blk: {1955 \\ a ^= (blk: {
1956 \\ const _ref_6 = &a;1956 \\ const ref = &a;
1957 \\ _ref_6.* = _ref_6.* ^ 1;1957 \\ ref.* = ref.* ^ 1;
1958 \\ break :blk _ref_6.*;1958 \\ break :blk ref.*;
1959 \\ });1959 \\ });
1960 \\ a >>= @as(@import("std").math.Log2Int(c_int), (blk: {1960 \\ a >>= @as(@import("std").math.Log2Int(c_int), (blk: {
1961 \\ const _ref_7 = &a;1961 \\ const ref = &a;
1962 \\ _ref_7.* = _ref_7.* >> @as(@import("std").math.Log2Int(c_int), 1);1962 \\ ref.* = ref.* >> @as(@import("std").math.Log2Int(c_int), 1);
1963 \\ break :blk _ref_7.*;1963 \\ break :blk ref.*;
1964 \\ }));1964 \\ }));
1965 \\ a <<= @as(@import("std").math.Log2Int(c_int), (blk: {1965 \\ a <<= @as(@import("std").math.Log2Int(c_int), (blk: {
1966 \\ const _ref_8 = &a;1966 \\ const ref = &a;
1967 \\ _ref_8.* = _ref_8.* << @as(@import("std").math.Log2Int(c_int), 1);1967 \\ ref.* = ref.* << @as(@import("std").math.Log2Int(c_int), 1);
1968 \\ break :blk _ref_8.*;1968 \\ break :blk ref.*;
1969 \\ }));1969 \\ }));
1970 \\}1970 \\}
1971 });1971 });
...@@ -1986,44 +1986,44 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1986,44 +1986,44 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1986 \\pub export fn foo() void {1986 \\pub export fn foo() void {
1987 \\ var a: c_uint = @intCast(c_uint, 0);1987 \\ var a: c_uint = @intCast(c_uint, 0);
1988 \\ a +%= (blk: {1988 \\ a +%= (blk: {
1989 \\ const _ref_1 = &a;1989 \\ const ref = &a;
1990 \\ _ref_1.* = _ref_1.* +% @intCast(c_uint, 1);1990 \\ ref.* = ref.* +% @intCast(c_uint, 1);
1991 \\ break :blk _ref_1.*;1991 \\ break :blk ref.*;
1992 \\ });1992 \\ });
1993 \\ a -%= (blk: {1993 \\ a -%= (blk: {
1994 \\ const _ref_2 = &a;1994 \\ const ref = &a;
1995 \\ _ref_2.* = _ref_2.* -% @intCast(c_uint, 1);1995 \\ ref.* = ref.* -% @intCast(c_uint, 1);
1996 \\ break :blk _ref_2.*;1996 \\ break :blk ref.*;
1997 \\ });1997 \\ });
1998 \\ a *%= (blk: {1998 \\ a *%= (blk: {
1999 \\ const _ref_3 = &a;1999 \\ const ref = &a;
2000 \\ _ref_3.* = _ref_3.* *% @intCast(c_uint, 1);2000 \\ ref.* = ref.* *% @intCast(c_uint, 1);
2001 \\ break :blk _ref_3.*;2001 \\ break :blk ref.*;
2002 \\ });2002 \\ });
2003 \\ a &= (blk: {2003 \\ a &= (blk: {
2004 \\ const _ref_4 = &a;2004 \\ const ref = &a;
2005 \\ _ref_4.* = _ref_4.* & @intCast(c_uint, 1);2005 \\ ref.* = ref.* & @intCast(c_uint, 1);
2006 \\ break :blk _ref_4.*;2006 \\ break :blk ref.*;
2007 \\ });2007 \\ });
2008 \\ a |= (blk: {2008 \\ a |= (blk: {
2009 \\ const _ref_5 = &a;2009 \\ const ref = &a;
2010 \\ _ref_5.* = _ref_5.* | @intCast(c_uint, 1);2010 \\ ref.* = ref.* | @intCast(c_uint, 1);
2011 \\ break :blk _ref_5.*;2011 \\ break :blk ref.*;
2012 \\ });2012 \\ });
2013 \\ a ^= (blk: {2013 \\ a ^= (blk: {
2014 \\ const _ref_6 = &a;2014 \\ const ref = &a;
2015 \\ _ref_6.* = _ref_6.* ^ @intCast(c_uint, 1);2015 \\ ref.* = ref.* ^ @intCast(c_uint, 1);
2016 \\ break :blk _ref_6.*;2016 \\ break :blk ref.*;
2017 \\ });2017 \\ });
2018 \\ a >>= @as(@import("std").math.Log2Int(c_uint), (blk: {2018 \\ a >>= @as(@import("std").math.Log2Int(c_uint), (blk: {
2019 \\ const _ref_7 = &a;2019 \\ const ref = &a;
2020 \\ _ref_7.* = _ref_7.* >> @as(@import("std").math.Log2Int(c_int), 1);2020 \\ ref.* = ref.* >> @as(@import("std").math.Log2Int(c_int), 1);
2021 \\ break :blk _ref_7.*;2021 \\ break :blk ref.*;
2022 \\ }));2022 \\ }));
2023 \\ a <<= @as(@import("std").math.Log2Int(c_uint), (blk: {2023 \\ a <<= @as(@import("std").math.Log2Int(c_uint), (blk: {
2024 \\ const _ref_8 = &a;2024 \\ const ref = &a;
2025 \\ _ref_8.* = _ref_8.* << @as(@import("std").math.Log2Int(c_int), 1);2025 \\ ref.* = ref.* << @as(@import("std").math.Log2Int(c_int), 1);
2026 \\ break :blk _ref_8.*;2026 \\ break :blk ref.*;
2027 \\ }));2027 \\ }));
2028 \\}2028 \\}
2029 });2029 });
...@@ -2050,28 +2050,28 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -2050,28 +2050,28 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
2050 \\ u +%= 1;2050 \\ u +%= 1;
2051 \\ u -%= 1;2051 \\ u -%= 1;
2052 \\ i = (blk: {2052 \\ i = (blk: {
2053 \\ const _ref_1 = &i;2053 \\ const ref = &i;
2054 \\ const _tmp_2 = _ref_1.*;2054 \\ const tmp = ref.*;
2055 \\ _ref_1.* += 1;2055 \\ ref.* += 1;
2056 \\ break :blk _tmp_2;2056 \\ break :blk tmp;
2057 \\ });2057 \\ });
2058 \\ i = (blk: {2058 \\ i = (blk: {
2059 \\ const _ref_3 = &i;2059 \\ const ref = &i;
2060 \\ const _tmp_4 = _ref_3.*;2060 \\ const tmp = ref.*;
2061 \\ _ref_3.* -= 1;2061 \\ ref.* -= 1;
2062 \\ break :blk _tmp_4;2062 \\ break :blk tmp;
2063 \\ });2063 \\ });
2064 \\ u = (blk: {2064 \\ u = (blk: {
2065 \\ const _ref_5 = &u;2065 \\ const ref = &u;
2066 \\ const _tmp_6 = _ref_5.*;2066 \\ const tmp = ref.*;
2067 \\ _ref_5.* +%= 1;2067 \\ ref.* +%= 1;
2068 \\ break :blk _tmp_6;2068 \\ break :blk tmp;
2069 \\ });2069 \\ });
2070 \\ u = (blk: {2070 \\ u = (blk: {
2071 \\ const _ref_7 = &u;2071 \\ const ref = &u;
2072 \\ const _tmp_8 = _ref_7.*;2072 \\ const tmp = ref.*;
2073 \\ _ref_7.* -%= 1;2073 \\ ref.* -%= 1;
2074 \\ break :blk _tmp_8;2074 \\ break :blk tmp;
2075 \\ });2075 \\ });
2076 \\}2076 \\}
2077 });2077 });
...@@ -2139,10 +2139,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -2139,10 +2139,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
2139 \\}2139 \\}
2140 , &[_][]const u8{2140 , &[_][]const u8{
2141 \\pub fn bar() void {}2141 \\pub fn bar() void {}
2142 \\pub export fn foo(_arg_baz_1: ?extern fn () [*c]c_int) void {2142 \\pub export fn foo(arg_baz: ?extern fn () [*c]c_int) void {
2143 \\ var baz_1 = _arg_baz_1;2143 \\ var baz = arg_baz;
2144 \\ bar();2144 \\ bar();
2145 \\ _ = baz_1.?();2145 \\ _ = baz.?();
2146 \\}2146 \\}
2147 });2147 });
21482148