authorgravatar for evan@lagerdata.comEvan Haas <evan@lagerdata.com> 2021-07-04 14:06:43-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-07-05 17:51:53-04:00
logb5659e02331ad1d4c273b3efe551c70bb5d92464
tree8c56ba1fcc25224753ef46f93a46a31810803a78
parentb7da1b2d45bc42a56eea3a143e4237a0712c4769

translate-c: Don't discard variables unless necessary

Closes #9205

3 files changed, 69 insertions(+), 173 deletions(-)

src/translate_c.zig+53-15
......@@ -67,6 +67,12 @@ const Scope = struct {
6767 mangle_count: u32 = 0,
6868 label: ?[]const u8 = null,
6969
70 /// By default all variables are discarded, since we do not know in advance if they
71 /// will be used. This maps the variable's name to the Discard payload, so that if
72 /// the variable is subsequently referenced we can indicate that the discard should
73 /// be skipped during the intermediate AST -> Zig AST render step.
74 variable_discards: std.StringArrayHashMap(*ast.Payload.Discard),
75
7076 /// When the block corresponds to a function, keep track of the return type
7177 /// so that the return expression can be cast, if necessary
7278 return_type: ?clang.QualType = null,
......@@ -84,6 +90,7 @@ const Scope = struct {
8490 },
8591 .statements = std.ArrayList(Node).init(c.gpa),
8692 .variables = AliasList.init(c.gpa),
93 .variable_discards = std.StringArrayHashMap(*ast.Payload.Discard).init(c.gpa),
8794 };
8895 if (labeled) {
8996 blk.label = try blk.makeMangledName(c, "blk");
......@@ -94,6 +101,7 @@ const Scope = struct {
94101 fn deinit(self: *Block) void {
95102 self.statements.deinit();
96103 self.variables.deinit();
104 self.variable_discards.deinit();
97105 self.* = undefined;
98106 }
99107
......@@ -154,8 +162,9 @@ const Scope = struct {
154162
155163 fn discardVariable(scope: *Block, c: *Context, name: []const u8) Error!void {
156164 const name_node = try Tag.identifier.create(c.arena, name);
157 const discard = try Tag.discard.create(c.arena, name_node);
165 const discard = try Tag.discard.create(c.arena, .{ .should_skip = false, .value = name_node });
158166 try scope.statements.append(discard);
167 try scope.variable_discards.putNoClobber(name, discard.castTag(.discard).?);
159168 }
160169 };
161170
......@@ -271,6 +280,24 @@ const Scope = struct {
271280 }
272281 }
273282 }
283
284 fn skipVariableDiscard(inner: *Scope, name: []const u8) void {
285 var scope = inner;
286 while (true) {
287 switch (scope.id) {
288 .root => return,
289 .block => {
290 const block = @fieldParentPtr(Block, "base", scope);
291 if (block.variable_discards.get(name)) |discard| {
292 discard.data.should_skip = true;
293 return;
294 }
295 },
296 else => {},
297 }
298 scope = scope.parent.?;
299 }
300 }
274301};
275302
276303pub const Context = struct {
......@@ -834,7 +861,9 @@ fn transTypeDef(c: *Context, scope: *Scope, typedef_decl: *const clang.TypedefNa
834861 try addTopLevelDecl(c, name, node);
835862 } else {
836863 try scope.appendNode(node);
837 try bs.discardVariable(c, name);
864 if (node.tag() != .pub_var_simple) {
865 try bs.discardVariable(c, name);
866 }
838867 }
839868}
840869
......@@ -1078,14 +1107,16 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD
10781107 .init = init_node,
10791108 },
10801109 };
1081
1110 const node = Node.initPayload(&payload.base);
10821111 if (toplevel) {
1083 try addTopLevelDecl(c, name, Node.initPayload(&payload.base));
1112 try addTopLevelDecl(c, name, node);
10841113 if (!is_unnamed)
10851114 try c.alias_list.append(.{ .alias = bare_name, .name = name });
10861115 } else {
1087 try scope.appendNode(Node.initPayload(&payload.base));
1088 try bs.discardVariable(c, name);
1116 try scope.appendNode(node);
1117 if (node.tag() != .pub_var_simple) {
1118 try bs.discardVariable(c, name);
1119 }
10891120 }
10901121}
10911122
......@@ -1172,14 +1203,16 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const clang.EnumDecl) E
11721203 .name = name,
11731204 },
11741205 };
1175
1206 const node = Node.initPayload(&payload.base);
11761207 if (toplevel) {
1177 try addTopLevelDecl(c, name, Node.initPayload(&payload.base));
1208 try addTopLevelDecl(c, name, node);
11781209 if (!is_unnamed)
11791210 try c.alias_list.append(.{ .alias = bare_name, .name = name });
11801211 } else {
1181 try scope.appendNode(Node.initPayload(&payload.base));
1182 try bs.discardVariable(c, name);
1212 try scope.appendNode(node);
1213 if (node.tag() != .pub_var_simple) {
1214 try bs.discardVariable(c, name);
1215 }
11831216 }
11841217}
11851218
......@@ -1789,7 +1822,7 @@ fn transDeclStmtOne(
17891822 args[0] = try Tag.address_of.create(c.arena, varname);
17901823
17911824 const cleanup_call = try Tag.call.create(c.arena, .{ .lhs = fn_id, .args = args });
1792 const discard = try Tag.discard.create(c.arena, cleanup_call);
1825 const discard = try Tag.discard.create(c.arena, .{ .should_skip = false, .value = cleanup_call });
17931826 const deferred_cleanup = try Tag.@"defer".create(c.arena, discard);
17941827
17951828 try block_scope.statements.append(deferred_cleanup);
......@@ -1844,6 +1877,7 @@ fn transDeclRefExpr(
18441877 });
18451878 }
18461879 }
1880 scope.skipVariableDiscard(mangled_name);
18471881 return ref_expr;
18481882}
18491883
......@@ -2478,7 +2512,9 @@ fn transInitListExprRecord(
24782512 .value = try transExpr(c, scope, elem_expr, .used),
24792513 });
24802514 }
2481
2515 if (ty_node.castTag(.identifier)) |ident_node| {
2516 scope.skipVariableDiscard(ident_node.data);
2517 }
24822518 return Tag.container_init.create(c.arena, .{
24832519 .lhs = ty_node,
24842520 .inits = try c.arena.dupe(ast.Payload.ContainerInit.Initializer, field_inits.items),
......@@ -3870,7 +3906,7 @@ fn maybeSuppressResult(
38703906) TransError!Node {
38713907 _ = scope;
38723908 if (used == .used) return result;
3873 return Tag.discard.create(c.arena, result);
3909 return Tag.discard.create(c.arena, .{ .should_skip = false, .value = result });
38743910}
38753911
38763912fn addTopLevelDecl(c: *Context, name: []const u8, decl_node: Node) !void {
......@@ -5004,7 +5040,7 @@ fn parseCExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node {
50045040 var last = node;
50055041 while (true) {
50065042 // suppress result
5007 const ignore = try Tag.discard.create(c.arena, last);
5043 const ignore = try Tag.discard.create(c.arena, .{ .should_skip = false, .value = last });
50085044 try block_scope.statements.append(ignore);
50095045
50105046 last = try parseCCondExpr(c, m, scope);
......@@ -5303,7 +5339,9 @@ fn parseCPrimaryExprInner(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!N
53035339 try m.fail(c, "TODO implement function '{s}' in std.c.builtins", .{mangled_name});
53045340 return error.ParseError;
53055341 }
5306 return Tag.identifier.create(c.arena, builtin_typedef_map.get(mangled_name) orelse mangled_name);
5342 const identifier = try Tag.identifier.create(c.arena, builtin_typedef_map.get(mangled_name) orelse mangled_name);
5343 scope.skipVariableDiscard(identifier.castTag(.identifier).?.data);
5344 return identifier;
53075345 },
53085346 .LParen => {
53095347 const inner_node = try parseCExpr(c, m, scope);
src/translate_c/ast.zig+12-2
......@@ -248,7 +248,6 @@ pub const Node = extern union {
248248 .@"comptime",
249249 .@"defer",
250250 .asm_simple,
251 .discard,
252251 .std_math_Log2Int,
253252 .negate,
254253 .negate_wrap,
......@@ -341,6 +340,7 @@ pub const Node = extern union {
341340 .warning,
342341 .type,
343342 => Payload.Value,
343 .discard => Payload.Discard,
344344 .@"if" => Payload.If,
345345 .@"while" => Payload.While,
346346 .@"switch", .array_init, .switch_prong => Payload.Switch,
......@@ -463,6 +463,14 @@ pub const Payload = struct {
463463 },
464464 };
465465
466 pub const Discard = struct {
467 base: Payload,
468 data: struct {
469 should_skip: bool,
470 value: Node,
471 },
472 };
473
466474 pub const If = struct {
467475 base: Payload,
468476 data: struct {
......@@ -1491,6 +1499,8 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
14911499 .pub_inline_fn => return renderMacroFunc(c, node),
14921500 .discard => {
14931501 const payload = node.castTag(.discard).?.data;
1502 if (payload.should_skip) return @as(NodeIndex, 0);
1503
14941504 const lhs = try c.addNode(.{
14951505 .tag = .identifier,
14961506 .main_token = try c.addToken(.identifier, "_"),
......@@ -1501,7 +1511,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
15011511 .main_token = try c.addToken(.equal, "="),
15021512 .data = .{
15031513 .lhs = lhs,
1504 .rhs = try renderNode(c, payload),
1514 .rhs = try renderNode(c, payload.value),
15051515 },
15061516 });
15071517 },
test/translate_c.zig+4-156
......@@ -12,11 +12,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1212 , &[_][]const u8{
1313 \\pub export fn foo(arg_x: c_ulong) c_ulong {
1414 \\ var x = arg_x;
15 \\ _ = x;
1615 \\ const union_unnamed_1 = extern union {
1716 \\ _x: c_ulong,
1817 \\ };
19 \\ _ = union_unnamed_1;
2018 \\ return (union_unnamed_1{
2119 \\ ._x = x,
2220 \\ })._x;
......@@ -75,7 +73,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
7573 \\pub extern fn bar(...) c_int;
7674 \\pub export fn foo() void {
7775 \\ var a: c_int = undefined;
78 \\ _ = a;
7976 \\ if (a != 0) a = 2 else _ = bar();
8077 \\}
8178 });
......@@ -128,7 +125,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
128125 \\ B: c_int,
129126 \\ C: c_int,
130127 \\ };
131 \\ _ = struct_Foo;
132128 \\ var a: struct_Foo = struct_Foo{
133129 \\ .A = @as(c_int, 0),
134130 \\ .B = 0,
......@@ -141,7 +137,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
141137 \\ B: c_int,
142138 \\ C: c_int,
143139 \\ };
144 \\ _ = struct_Foo_1;
145140 \\ var a_2: struct_Foo_1 = struct_Foo_1{
146141 \\ .A = @as(c_int, 0),
147142 \\ .B = 0,
......@@ -178,7 +173,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
178173 \\ };
179174 \\ _ = union_unnamed_1;
180175 \\ const Foo = union_unnamed_1;
181 \\ _ = Foo;
182176 \\ var a: Foo = Foo{
183177 \\ .A = @as(c_int, 0),
184178 \\ };
......@@ -191,7 +185,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
191185 \\ };
192186 \\ _ = union_unnamed_2;
193187 \\ const Foo_1 = union_unnamed_2;
194 \\ _ = Foo_1;
195188 \\ var a_2: Foo_1 = Foo_1{
196189 \\ .A = @as(c_int, 0),
197190 \\ };
......@@ -205,7 +198,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
205198 \\#define MEM_PHYSICAL_TO_K0(x) (void*)((uint32_t)(x) + SYS_BASE_CACHED)
206199 , &[_][]const u8{
207200 \\pub inline fn MEM_PHYSICAL_TO_K0(x: anytype) ?*c_void {
208 \\ _ = x;
209201 \\ return @import("std").zig.c_translation.cast(?*c_void, @import("std").zig.c_translation.cast(u32, x) + SYS_BASE_CACHED);
210202 \\}
211203 });
......@@ -247,7 +239,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
247239 \\pub const VALUE = ((((@as(c_int, 1) + (@as(c_int, 2) * @as(c_int, 3))) + (@as(c_int, 4) * @as(c_int, 5))) + @as(c_int, 6)) << @as(c_int, 7)) | @boolToInt(@as(c_int, 8) == @as(c_int, 9));
248240 ,
249241 \\pub inline fn _AL_READ3BYTES(p: anytype) @TypeOf((@import("std").zig.c_translation.cast([*c]u8, p).* | ((@import("std").zig.c_translation.cast([*c]u8, p) + @as(c_int, 1)).* << @as(c_int, 8))) | ((@import("std").zig.c_translation.cast([*c]u8, p) + @as(c_int, 2)).* << @as(c_int, 16))) {
250 \\ _ = p;
251242 \\ return (@import("std").zig.c_translation.cast([*c]u8, p).* | ((@import("std").zig.c_translation.cast([*c]u8, p) + @as(c_int, 1)).* << @as(c_int, 8))) | ((@import("std").zig.c_translation.cast([*c]u8, p) + @as(c_int, 2)).* << @as(c_int, 16));
252243 \\}
253244 });
......@@ -328,7 +319,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
328319 \\pub const Color = struct_Color;
329320 ,
330321 \\pub inline fn CLITERAL(type_1: anytype) @TypeOf(type_1) {
331 \\ _ = type_1;
332322 \\ return type_1;
333323 \\}
334324 ,
......@@ -346,7 +336,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
346336 \\};
347337 ,
348338 \\pub inline fn A(_x: anytype) MyCStruct {
349 \\ _ = _x;
350339 \\ return @import("std").mem.zeroInit(MyCStruct, .{
351340 \\ .x = _x,
352341 \\ });
......@@ -377,7 +366,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
377366 \\#define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0)
378367 , &[_][]const u8{
379368 \\pub inline fn __ferror_unlocked_body(_fp: anytype) @TypeOf((_fp.*._flags & _IO_ERR_SEEN) != @as(c_int, 0)) {
380 \\ _ = _fp;
381369 \\ return (_fp.*._flags & _IO_ERR_SEEN) != @as(c_int, 0);
382370 \\}
383371 });
......@@ -387,7 +375,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
387375 \\#define BAR 1 && 2 > 4
388376 , &[_][]const u8{
389377 \\pub inline fn FOO(x: anytype) @TypeOf(@boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0))) {
390 \\ _ = x;
391378 \\ return @boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0));
392379 \\}
393380 ,
......@@ -450,7 +437,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
450437 \\};
451438 ,
452439 \\pub inline fn bar(x: anytype) @TypeOf(baz(@as(c_int, 1), @as(c_int, 2))) {
453 \\ _ = x;
454440 \\ return blk: {
455441 \\ _ = &x;
456442 \\ _ = @as(c_int, 3);
......@@ -580,7 +566,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
580566 \\};
581567 \\pub export fn foo(arg_x: [*c]outer) void {
582568 \\ var x = arg_x;
583 \\ _ = x;
584569 \\ x.*.unnamed_0.unnamed_0.y = @bitCast(c_int, @as(c_uint, x.*.unnamed_0.x));
585570 \\}
586571 });
......@@ -667,7 +652,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
667652 \\pub const struct_opaque_2 = opaque {};
668653 \\pub export fn function(arg_opaque_1: ?*struct_opaque) void {
669654 \\ var opaque_1 = arg_opaque_1;
670 \\ _ = opaque_1;
671655 \\ var cast: ?*struct_opaque_2 = @ptrCast(?*struct_opaque_2, opaque_1);
672656 \\ _ = cast;
673657 \\}
......@@ -763,7 +747,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
763747 , &[_][]const u8{
764748 \\pub export fn foo() void {
765749 \\ var a: c_int = undefined;
766 \\ _ = a;
767750 \\ _ = @as(c_int, 1);
768751 \\ _ = "hey";
769752 \\ _ = @as(c_int, 1) + @as(c_int, 1);
......@@ -849,7 +832,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
849832 \\pub extern fn foo() void;
850833 \\pub export fn bar() void {
851834 \\ var func_ptr: ?*c_void = @ptrCast(?*c_void, foo);
852 \\ _ = func_ptr;
853835 \\ var typed_func_ptr: ?fn () callconv(.C) void = @intToPtr(?fn () callconv(.C) void, @intCast(c_ulong, @ptrToInt(func_ptr)));
854836 \\ _ = typed_func_ptr;
855837 \\}
......@@ -881,11 +863,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
881863 , &[_][]const u8{
882864 \\pub export fn s() c_int {
883865 \\ var a: c_int = undefined;
884 \\ _ = a;
885866 \\ var b: c_int = undefined;
886 \\ _ = b;
887867 \\ var c: c_int = undefined;
888 \\ _ = c;
889868 \\ c = a + b;
890869 \\ c = a - b;
891870 \\ c = a * b;
......@@ -895,11 +874,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
895874 \\}
896875 \\pub export fn u() c_uint {
897876 \\ var a: c_uint = undefined;
898 \\ _ = a;
899877 \\ var b: c_uint = undefined;
900 \\ _ = b;
901878 \\ var c: c_uint = undefined;
902 \\ _ = c;
903879 \\ c = a +% b;
904880 \\ c = a -% b;
905881 \\ c = a *% b;
......@@ -1263,7 +1239,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
12631239 \\pub export fn foo() void {
12641240 \\ var a: c_int = undefined;
12651241 \\ _ = a;
1266 \\ _ = a;
12671242 \\}
12681243 });
12691244
......@@ -1275,7 +1250,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
12751250 , &[_][]const u8{
12761251 \\pub export fn foo() ?*c_void {
12771252 \\ var x: [*c]c_ushort = undefined;
1278 \\ _ = x;
12791253 \\ return @ptrCast(?*c_void, x);
12801254 \\}
12811255 });
......@@ -1332,7 +1306,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
13321306 \\pub export fn foo() void {
13331307 \\ {
13341308 \\ var i: c_int = 0;
1335 \\ _ = i;
13361309 \\ while (i != 0) : (i += 1) {}
13371310 \\ }
13381311 \\}
......@@ -1356,7 +1329,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
13561329 , &[_][]const u8{
13571330 \\pub export fn foo() void {
13581331 \\ var i: c_int = undefined;
1359 \\ _ = i;
13601332 \\ {
13611333 \\ i = 3;
13621334 \\ while (i != 0) : (i -= 1) {}
......@@ -1400,7 +1372,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
14001372 , &[_][]const u8{
14011373 \\pub export fn ptrcast() [*c]f32 {
14021374 \\ var a: [*c]c_int = undefined;
1403 \\ _ = a;
14041375 \\ return @ptrCast([*c]f32, @alignCast(@import("std").meta.alignment(f32), a));
14051376 \\}
14061377 });
......@@ -1424,7 +1395,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
14241395 , &[_][]const u8{
14251396 \\pub export fn test_ptr_cast() void {
14261397 \\ var p: ?*c_void = undefined;
1427 \\ _ = p;
14281398 \\ {
14291399 \\ var to_char: [*c]u8 = @ptrCast([*c]u8, @alignCast(@import("std").meta.alignment(u8), p));
14301400 \\ _ = to_char;
......@@ -1461,11 +1431,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
14611431 , &[_][]const u8{
14621432 \\pub export fn while_none_bool() c_int {
14631433 \\ var a: c_int = undefined;
1464 \\ _ = a;
14651434 \\ var b: f32 = undefined;
1466 \\ _ = b;
14671435 \\ var c: ?*c_void = undefined;
1468 \\ _ = c;
14691436 \\ while (a != 0) return 0;
14701437 \\ while (b != 0) return 1;
14711438 \\ while (c != null) return 2;
......@@ -1486,11 +1453,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
14861453 , &[_][]const u8{
14871454 \\pub export fn for_none_bool() c_int {
14881455 \\ var a: c_int = undefined;
1489 \\ _ = a;
14901456 \\ var b: f32 = undefined;
1491 \\ _ = b;
14921457 \\ var c: ?*c_void = undefined;
1493 \\ _ = c;
14941458 \\ while (a != 0) return 0;
14951459 \\ while (b != 0) return 1;
14961460 \\ while (c != null) return 2;
......@@ -1527,7 +1491,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
15271491 , &[_][]const u8{
15281492 \\pub export fn foo() void {
15291493 \\ var x: [*c]c_int = undefined;
1530 \\ _ = x;
15311494 \\ x.* = 1;
15321495 \\}
15331496 });
......@@ -1541,9 +1504,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
15411504 , &[_][]const u8{
15421505 \\pub export fn foo() c_int {
15431506 \\ var x: c_int = 1234;
1544 \\ _ = x;
15451507 \\ var ptr: [*c]c_int = &x;
1546 \\ _ = ptr;
15471508 \\ return ptr.*;
15481509 \\}
15491510 });
......@@ -1556,7 +1517,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
15561517 , &[_][]const u8{
15571518 \\pub export fn foo() c_int {
15581519 \\ var x: c_int = undefined;
1559 \\ _ = x;
15601520 \\ return ~x;
15611521 \\}
15621522 });
......@@ -1574,11 +1534,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
15741534 , &[_][]const u8{
15751535 \\pub export fn foo() c_int {
15761536 \\ var a: c_int = undefined;
1577 \\ _ = a;
15781537 \\ var b: f32 = undefined;
1579 \\ _ = b;
15801538 \\ var c: ?*c_void = undefined;
1581 \\ _ = c;
15821539 \\ return @boolToInt(!(a == @as(c_int, 0)));
15831540 \\ return @boolToInt(!(a != 0));
15841541 \\ return @boolToInt(!(b != 0));
......@@ -1891,13 +1848,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
18911848 \\pub extern var c: c_int;
18921849 ,
18931850 \\pub inline fn BASIC(c_1: anytype) @TypeOf(c_1 * @as(c_int, 2)) {
1894 \\ _ = c_1;
18951851 \\ return c_1 * @as(c_int, 2);
18961852 \\}
18971853 ,
18981854 \\pub inline fn FOO(L: anytype, b: anytype) @TypeOf(L + b) {
1899 \\ _ = L;
1900 \\ _ = b;
19011855 \\ return L + b;
19021856 \\}
19031857 ,
......@@ -1951,9 +1905,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
19511905 \\ var c_1 = arg_c_1;
19521906 \\ _ = c_1;
19531907 \\ var a_2: c_int = undefined;
1954 \\ _ = a_2;
19551908 \\ var b_3: u8 = 123;
1956 \\ _ = b_3;
19571909 \\ b_3 = @bitCast(u8, @truncate(i8, a_2));
19581910 \\ {
19591911 \\ var d: c_int = 5;
......@@ -1994,9 +1946,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
19941946 , &[_][]const u8{
19951947 \\pub export fn foo() void {
19961948 \\ var a: c_int = undefined;
1997 \\ _ = a;
19981949 \\ var b: c_int = undefined;
1999 \\ _ = b;
20001950 \\ a = blk: {
20011951 \\ const tmp = @as(c_int, 2);
20021952 \\ b = tmp;
......@@ -2026,13 +1976,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
20261976 , &[_][]const u8{
20271977 \\pub export fn foo() c_int {
20281978 \\ var a: c_int = 5;
2029 \\ _ = a;
20301979 \\ while (true) {
20311980 \\ a = 2;
20321981 \\ }
20331982 \\ while (true) {
20341983 \\ var a_1: c_int = 4;
2035 \\ _ = a_1;
20361984 \\ a_1 = 9;
20371985 \\ return blk: {
20381986 \\ _ = @as(c_int, 6);
......@@ -2041,7 +1989,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
20411989 \\ }
20421990 \\ while (true) {
20431991 \\ var a_1: c_int = 2;
2044 \\ _ = a_1;
20451992 \\ a_1 = 12;
20461993 \\ }
20471994 \\ while (true) {
......@@ -2063,12 +2010,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
20632010 \\pub export fn foo() void {
20642011 \\ {
20652012 \\ var i: c_int = 2;
2066 \\ _ = i;
20672013 \\ var b: c_int = 4;
20682014 \\ _ = b;
20692015 \\ while ((i + @as(c_int, 2)) != 0) : (i = 2) {
20702016 \\ var a: c_int = 2;
2071 \\ _ = a;
20722017 \\ _ = blk: {
20732018 \\ _ = blk_1: {
20742019 \\ a = 6;
......@@ -2152,9 +2097,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
21522097 , &[_][]const u8{
21532098 \\pub export fn switch_fn(arg_i: c_int) void {
21542099 \\ var i = arg_i;
2155 \\ _ = i;
21562100 \\ var res: c_int = 0;
2157 \\ _ = res;
21582101 \\ while (true) {
21592102 \\ switch (i) {
21602103 \\ @as(c_int, 0) => {
......@@ -2243,9 +2186,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
22432186 , &[_][]const u8{
22442187 \\pub export fn max(arg_a: c_int) void {
22452188 \\ var a = arg_a;
2246 \\ _ = a;
22472189 \\ var tmp: c_int = undefined;
2248 \\ _ = tmp;
22492190 \\ tmp = a;
22502191 \\ a = tmp;
22512192 \\}
......@@ -2259,11 +2200,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
22592200 , &[_][]const u8{
22602201 \\pub export fn max(arg_a: c_int) void {
22612202 \\ var a = arg_a;
2262 \\ _ = a;
22632203 \\ var b: c_int = undefined;
2264 \\ _ = b;
22652204 \\ var c: c_int = undefined;
2266 \\ _ = c;
22672205 \\ c = blk: {
22682206 \\ const tmp = a;
22692207 \\ b = tmp;
......@@ -2292,7 +2230,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
22922230 , &[_][]const u8{
22932231 \\pub export fn float_to_int(arg_a: f32) c_int {
22942232 \\ var a = arg_a;
2295 \\ _ = a;
22962233 \\ return @floatToInt(c_int, a);
22972234 \\}
22982235 });
......@@ -2356,13 +2293,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
23562293 , &[_][]const u8{
23572294 \\pub export fn foo() void {
23582295 \\ var a: c_int = 2;
2359 \\ _ = a;
23602296 \\ while (true) {
23612297 \\ a = a - @as(c_int, 1);
23622298 \\ if (!(a != 0)) break;
23632299 \\ }
23642300 \\ var b: c_int = 2;
2365 \\ _ = b;
23662301 \\ while (true) {
23672302 \\ b = b - @as(c_int, 1);
23682303 \\ if (!(b != 0)) break;
......@@ -2403,37 +2338,21 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
24032338 \\pub const SomeTypedef = c_int;
24042339 \\pub export fn and_or_non_bool(arg_a: c_int, arg_b: f32, arg_c: ?*c_void) c_int {
24052340 \\ var a = arg_a;
2406 \\ _ = a;
24072341 \\ var b = arg_b;
2408 \\ _ = b;
24092342 \\ var c = arg_c;
2410 \\ _ = c;
24112343 \\ var d: enum_Foo = @bitCast(c_uint, FooA);
2412 \\ _ = d;
24132344 \\ var e: c_int = @boolToInt((a != 0) and (b != 0));
2414 \\ _ = e;
24152345 \\ var f: c_int = @boolToInt((b != 0) and (c != null));
2416 \\ _ = f;
24172346 \\ var g: c_int = @boolToInt((a != 0) and (c != null));
2418 \\ _ = g;
24192347 \\ var h: c_int = @boolToInt((a != 0) or (b != 0));
2420 \\ _ = h;
24212348 \\ var i: c_int = @boolToInt((b != 0) or (c != null));
2422 \\ _ = i;
24232349 \\ var j: c_int = @boolToInt((a != 0) or (c != null));
2424 \\ _ = j;
24252350 \\ var k: c_int = @boolToInt((a != 0) or (@bitCast(c_int, d) != 0));
2426 \\ _ = k;
24272351 \\ var l: c_int = @boolToInt((@bitCast(c_int, d) != 0) and (b != 0));
2428 \\ _ = l;
24292352 \\ var m: c_int = @boolToInt((c != null) or (d != 0));
2430 \\ _ = m;
24312353 \\ var td: SomeTypedef = 44;
2432 \\ _ = td;
24332354 \\ var o: c_int = @boolToInt((td != 0) or (b != 0));
2434 \\ _ = o;
24352355 \\ var p: c_int = @boolToInt((c != null) and (td != 0));
2436 \\ _ = p;
24372356 \\ return (((((((((e + f) + g) + h) + i) + j) + k) + l) + m) + o) + p;
24382357 \\}
24392358 ,
......@@ -2473,9 +2392,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
24732392 , &[_][]const u8{
24742393 \\pub export fn max(arg_a: c_int, arg_b: c_int) c_int {
24752394 \\ var a = arg_a;
2476 \\ _ = a;
24772395 \\ var b = arg_b;
2478 \\ _ = b;
24792396 \\ return (a & b) ^ (a | b);
24802397 \\}
24812398 });
......@@ -2494,23 +2411,14 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
24942411 , &[_][]const u8{
24952412 \\pub export fn test_comparisons(arg_a: c_int, arg_b: c_int) c_int {
24962413 \\ var a = arg_a;
2497 \\ _ = a;
24982414 \\ var b = arg_b;
2499 \\ _ = b;
25002415 \\ var c: c_int = @boolToInt(a < b);
2501 \\ _ = c;
25022416 \\ var d: c_int = @boolToInt(a > b);
2503 \\ _ = d;
25042417 \\ var e: c_int = @boolToInt(a <= b);
2505 \\ _ = e;
25062418 \\ var f: c_int = @boolToInt(a >= b);
2507 \\ _ = f;
25082419 \\ var g: c_int = @boolToInt(c < d);
2509 \\ _ = g;
25102420 \\ var h: c_int = @boolToInt(e < f);
2511 \\ _ = h;
25122421 \\ var i: c_int = @boolToInt(g < h);
2513 \\ _ = i;
25142422 \\ return i;
25152423 \\}
25162424 });
......@@ -2526,9 +2434,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
25262434 , &[_][]const u8{
25272435 \\pub export fn max(arg_a: c_int, arg_b: c_int) c_int {
25282436 \\ var a = arg_a;
2529 \\ _ = a;
25302437 \\ var b = arg_b;
2531 \\ _ = b;
25322438 \\ if (a == b) return a;
25332439 \\ if (a != b) return b;
25342440 \\ return a;
......@@ -2545,7 +2451,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
25452451 \\pub const yes = [*c]u8;
25462452 \\pub export fn foo() void {
25472453 \\ var a: yes = undefined;
2548 \\ _ = a;
25492454 \\ if (a != null) {
25502455 \\ _ = @as(c_int, 2);
25512456 \\ }
......@@ -2565,7 +2470,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
25652470 \\ return blk: {
25662471 \\ var a: c_int = 1;
25672472 \\ _ = a;
2568 \\ _ = a;
25692473 \\ break :blk a;
25702474 \\ };
25712475 \\}
......@@ -2591,7 +2495,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
25912495 \\pub export var b: f32 = 2.0;
25922496 \\pub export fn foo() void {
25932497 \\ var c: [*c]struct_Foo = undefined;
2594 \\ _ = c;
25952498 \\ _ = a.b;
25962499 \\ _ = c.*.b;
25972500 \\}
......@@ -2611,7 +2514,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
26112514 \\pub export var array: [100]c_int = [1]c_int{0} ** 100;
26122515 \\pub export fn foo(arg_index: c_int) c_int {
26132516 \\ var index = arg_index;
2614 \\ _ = index;
26152517 \\ return array[@intCast(c_uint, index)];
26162518 \\}
26172519 ,
......@@ -2626,9 +2528,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
26262528 , &[_][]const u8{
26272529 \\pub export fn foo() void {
26282530 \\ var a: [10]c_int = undefined;
2629 \\ _ = a;
26302531 \\ var i: c_int = 0;
2631 \\ _ = i;
26322532 \\ a[@intCast(c_uint, i)] = 0;
26332533 \\}
26342534 });
......@@ -2641,9 +2541,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
26412541 , &[_][]const u8{
26422542 \\pub export fn foo() void {
26432543 \\ var a: [10]c_longlong = undefined;
2644 \\ _ = a;
26452544 \\ var i: c_longlong = 0;
2646 \\ _ = i;
26472545 \\ a[@intCast(usize, i)] = 0;
26482546 \\}
26492547 });
......@@ -2656,9 +2554,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
26562554 , &[_][]const u8{
26572555 \\pub export fn foo() void {
26582556 \\ var a: [10]c_uint = undefined;
2659 \\ _ = a;
26602557 \\ var i: c_uint = 0;
2661 \\ _ = i;
26622558 \\ a[i] = 0;
26632559 \\}
26642560 });
......@@ -2667,7 +2563,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
26672563 \\#define CALL(arg) bar(arg)
26682564 , &[_][]const u8{
26692565 \\pub inline fn CALL(arg: anytype) @TypeOf(bar(arg)) {
2670 \\ _ = arg;
26712566 \\ return bar(arg);
26722567 \\}
26732568 });
......@@ -2692,9 +2587,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
26922587 , &[_][]const u8{
26932588 \\pub export fn max(arg_a: c_int, arg_b: c_int) c_int {
26942589 \\ var a = arg_a;
2695 \\ _ = a;
26962590 \\ var b = arg_b;
2697 \\ _ = b;
26982591 \\ if ((a < b) or (a == b)) return b;
26992592 \\ if ((a >= b) and (a == b)) return a;
27002593 \\ return a;
......@@ -2716,9 +2609,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
27162609 , &[_][]const u8{
27172610 \\pub export fn max(arg_a: c_int, arg_b: c_int) c_int {
27182611 \\ var a = arg_a;
2719 \\ _ = a;
27202612 \\ var b = arg_b;
2721 \\ _ = b;
27222613 \\ if (a < b) return b;
27232614 \\ if (a < b) return b else return a;
27242615 \\ if (a < b) {} else {}
......@@ -2769,13 +2660,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
27692660 \\;
27702661 \\pub export fn if_none_bool(arg_a: c_int, arg_b: f32, arg_c: ?*c_void, arg_d: enum_SomeEnum) c_int {
27712662 \\ var a = arg_a;
2772 \\ _ = a;
27732663 \\ var b = arg_b;
2774 \\ _ = b;
27752664 \\ var c = arg_c;
2776 \\ _ = c;
27772665 \\ var d = arg_d;
2778 \\ _ = d;
27792666 \\ if (a != 0) return 0;
27802667 \\ if (b != 0) return 1;
27812668 \\ if (c != null) return 2;
......@@ -2803,7 +2690,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
28032690 , &[_][]const u8{
28042691 \\pub export fn abs(arg_a: c_int) c_int {
28052692 \\ var a = arg_a;
2806 \\ _ = a;
28072693 \\ return if (a < @as(c_int, 0)) -a else a;
28082694 \\}
28092695 });
......@@ -2824,19 +2710,16 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
28242710 , &[_][]const u8{
28252711 \\pub export fn foo1(arg_a: c_uint) c_uint {
28262712 \\ var a = arg_a;
2827 \\ _ = a;
28282713 \\ a +%= 1;
28292714 \\ return a;
28302715 \\}
28312716 \\pub export fn foo2(arg_a: c_int) c_int {
28322717 \\ var a = arg_a;
2833 \\ _ = a;
28342718 \\ a += 1;
28352719 \\ return a;
28362720 \\}
28372721 \\pub export fn foo3(arg_a: [*c]c_int) [*c]c_int {
28382722 \\ var a = arg_a;
2839 \\ _ = a;
28402723 \\ a += 1;
28412724 \\ return a;
28422725 \\}
......@@ -2862,9 +2745,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
28622745 \\}
28632746 \\pub export fn bar() void {
28642747 \\ var f: ?fn () callconv(.C) void = foo;
2865 \\ _ = f;
28662748 \\ var b: ?fn () callconv(.C) c_int = baz;
2867 \\ _ = b;
28682749 \\ f.?();
28692750 \\ f.?();
28702751 \\ foo();
......@@ -2890,9 +2771,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
28902771 , &[_][]const u8{
28912772 \\pub export fn foo() void {
28922773 \\ var i: c_int = 0;
2893 \\ _ = i;
28942774 \\ var u: c_uint = 0;
2895 \\ _ = u;
28962775 \\ i += 1;
28972776 \\ i -= 1;
28982777 \\ u +%= 1;
......@@ -2931,9 +2810,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
29312810 , &[_][]const u8{
29322811 \\pub export fn log2(arg_a: c_uint) c_int {
29332812 \\ var a = arg_a;
2934 \\ _ = a;
29352813 \\ var i: c_int = 0;
2936 \\ _ = i;
29372814 \\ while (a > @bitCast(c_uint, @as(c_int, 0))) {
29382815 \\ a >>= @intCast(@import("std").math.Log2Int(c_int), @as(c_int, 1));
29392816 \\ }
......@@ -2953,9 +2830,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
29532830 , &[_][]const u8{
29542831 \\pub export fn log2(arg_a: u32) c_int {
29552832 \\ var a = arg_a;
2956 \\ _ = a;
29572833 \\ var i: c_int = 0;
2958 \\ _ = i;
29592834 \\ while (a > @bitCast(c_uint, @as(c_int, 0))) {
29602835 \\ a >>= @intCast(@import("std").math.Log2Int(c_int), @as(c_int, 1));
29612836 \\ }
......@@ -2983,9 +2858,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
29832858 , &[_][]const u8{
29842859 \\pub export fn foo() void {
29852860 \\ var a: c_int = 0;
2986 \\ _ = a;
29872861 \\ var b: c_uint = 0;
2988 \\ _ = b;
29892862 \\ a += blk: {
29902863 \\ const ref = &a;
29912864 \\ ref.* += @as(c_int, 1);
......@@ -3064,7 +2937,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
30642937 , &[_][]const u8{
30652938 \\pub export fn foo() void {
30662939 \\ var a: c_uint = 0;
3067 \\ _ = a;
30682940 \\ a +%= blk: {
30692941 \\ const ref = &a;
30702942 \\ ref.* +%= @bitCast(c_uint, @as(c_int, 1));
......@@ -3124,9 +2996,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
31242996 , &[_][]const u8{
31252997 \\pub export fn foo() void {
31262998 \\ var i: c_int = 0;
3127 \\ _ = i;
31282999 \\ var u: c_uint = 0;
3129 \\ _ = u;
31303000 \\ i += 1;
31313001 \\ i -= 1;
31323002 \\ u +%= 1;
......@@ -3221,7 +3091,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
32213091 \\pub fn bar() callconv(.C) void {}
32223092 \\pub export fn foo(arg_baz: ?fn () callconv(.C) [*c]c_int) void {
32233093 \\ var baz = arg_baz;
3224 \\ _ = baz;
32253094 \\ bar();
32263095 \\ _ = baz.?();
32273096 \\}
......@@ -3304,14 +3173,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
33043173 \\#define MAX(a, b) ((b) > (a) ? (b) : (a))
33053174 , &[_][]const u8{
33063175 \\pub inline fn MIN(a: anytype, b: anytype) @TypeOf(if (b < a) b else a) {
3307 \\ _ = a;
3308 \\ _ = b;
33093176 \\ return if (b < a) b else a;
33103177 \\}
33113178 ,
33123179 \\pub inline fn MAX(a: anytype, b: anytype) @TypeOf(if (b > a) b else a) {
3313 \\ _ = a;
3314 \\ _ = b;
33153180 \\ return if (b > a) b else a;
33163181 \\}
33173182 });
......@@ -3323,9 +3188,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
33233188 , &[_][]const u8{
33243189 \\pub export fn foo(arg_p: [*c]c_int, arg_x: c_int) c_int {
33253190 \\ var p = arg_p;
3326 \\ _ = p;
33273191 \\ var x = arg_x;
3328 \\ _ = x;
33293192 \\ return blk: {
33303193 \\ const tmp = x;
33313194 \\ (blk_1: {
......@@ -3352,7 +3215,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
33523215 \\}
33533216 \\pub export fn bar(arg_x: c_long) c_ushort {
33543217 \\ var x = arg_x;
3355 \\ _ = x;
33563218 \\ return @bitCast(c_ushort, @truncate(c_short, x));
33573219 \\}
33583220 });
......@@ -3365,7 +3227,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
33653227 , &[_][]const u8{
33663228 \\pub export fn foo(arg_bar_1: c_int) void {
33673229 \\ var bar_1 = arg_bar_1;
3368 \\ _ = bar_1;
33693230 \\ bar_1 = 2;
33703231 \\}
33713232 \\pub export var bar: c_int = 4;
......@@ -3379,7 +3240,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
33793240 , &[_][]const u8{
33803241 \\pub export fn foo(arg_bar_1: c_int) void {
33813242 \\ var bar_1 = arg_bar_1;
3382 \\ _ = bar_1;
33833243 \\ bar_1 = 2;
33843244 \\}
33853245 ,
......@@ -3413,12 +3273,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
34133273 \\}
34143274 \\pub export fn bar(arg_a: [*c]const c_int) void {
34153275 \\ var a = arg_a;
3416 \\ _ = a;
34173276 \\ foo(@intToPtr([*c]c_int, @ptrToInt(a)));
34183277 \\}
34193278 \\pub export fn baz(arg_a: [*c]volatile c_int) void {
34203279 \\ var a = arg_a;
3421 \\ _ = a;
34223280 \\ foo(@intToPtr([*c]c_int, @ptrToInt(a)));
34233281 \\}
34243282 });
......@@ -3433,13 +3291,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
34333291 , &[_][]const u8{
34343292 \\pub export fn foo(arg_x: bool) bool {
34353293 \\ var x = arg_x;
3436 \\ _ = x;
34373294 \\ var a: bool = @as(c_int, @boolToInt(x)) != @as(c_int, 1);
3438 \\ _ = a;
34393295 \\ var b: bool = @as(c_int, @boolToInt(a)) != @as(c_int, 0);
3440 \\ _ = b;
34413296 \\ var c: bool = @ptrToInt(foo) != 0;
3442 \\ _ = c;
34433297 \\ return foo(@as(c_int, @boolToInt(c)) != @as(c_int, @boolToInt(b)));
34443298 \\}
34453299 });
......@@ -3450,9 +3304,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
34503304 \\}
34513305 , &[_][]const u8{
34523306 \\pub export fn max(x: c_int, arg_y: c_int) c_int {
3453 \\ _ = x;
34543307 \\ var y = arg_y;
3455 \\ _ = y;
34563308 \\ return if (x > y) x else y;
34573309 \\}
34583310 });
......@@ -3513,7 +3365,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
35133365 \\
35143366 , &[_][]const u8{
35153367 \\pub inline fn DefaultScreen(dpy: anytype) @TypeOf(@import("std").zig.c_translation.cast(_XPrivDisplay, dpy).*.default_screen) {
3516 \\ _ = dpy;
35173368 \\ return @import("std").zig.c_translation.cast(_XPrivDisplay, dpy).*.default_screen;
35183369 \\}
35193370 });
......@@ -3733,7 +3584,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
37333584 \\ const foo = struct {
37343585 \\ var static: struct_FOO = @import("std").mem.zeroes(struct_FOO);
37353586 \\ };
3736 \\ _ = foo;
37373587 \\ return foo.static.x;
37383588 \\}
37393589 });
......@@ -3747,24 +3597,22 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
37473597 \\pub const INVALID_HANDLE_VALUE = @import("std").zig.c_translation.cast(?*c_void, @import("std").zig.c_translation.cast(LONG_PTR, -@as(c_int, 1)));
37483598 });
37493599
3750 cases.add("discard local variables and function parameters",
3751 \\#define FOO(A, B) (A) + (B)
3600 cases.add("discard unused local variables and function parameters",
3601 \\#define FOO(A, B) (A)
37523602 \\int bar(int x, int y) {
37533603 \\ return x;
37543604 \\}
37553605 , &[_][]const u8{
37563606 \\pub export fn bar(arg_x: c_int, arg_y: c_int) c_int {
37573607 \\ var x = arg_x;
3758 \\ _ = x;
37593608 \\ var y = arg_y;
37603609 \\ _ = y;
37613610 \\ return x;
37623611 \\}
37633612 ,
3764 \\pub inline fn FOO(A: anytype, B: anytype) @TypeOf(A + B) {
3765 \\ _ = A;
3613 \\pub inline fn FOO(A: anytype, B: anytype) @TypeOf(A) {
37663614 \\ _ = B;
3767 \\ return A + B;
3615 \\ return A;
37683616 \\}
37693617 });
37703618