| ... | @@ -12,11 +12,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -12,11 +12,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 12 | , &[_][]const u8{ | 12 | , &[_][]const u8{ |
| 13 | \\pub export fn foo(arg_x: c_ulong) c_ulong { | 13 | \\pub export fn foo(arg_x: c_ulong) c_ulong { |
| 14 | \\ var x = arg_x; | 14 | \\ var x = arg_x; |
| 15 | \\ _ = x; | | |
| 16 | \\ const union_unnamed_1 = extern union { | 15 | \\ const union_unnamed_1 = extern union { |
| 17 | \\ _x: c_ulong, | 16 | \\ _x: c_ulong, |
| 18 | \\ }; | 17 | \\ }; |
| 19 | \\ _ = union_unnamed_1; | | |
| 20 | \\ return (union_unnamed_1{ | 18 | \\ return (union_unnamed_1{ |
| 21 | \\ ._x = x, | 19 | \\ ._x = x, |
| 22 | \\ })._x; | 20 | \\ })._x; |
| ... | @@ -75,7 +73,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -75,7 +73,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 75 | \\pub extern fn bar(...) c_int; | 73 | \\pub extern fn bar(...) c_int; |
| 76 | \\pub export fn foo() void { | 74 | \\pub export fn foo() void { |
| 77 | \\ var a: c_int = undefined; | 75 | \\ var a: c_int = undefined; |
| 78 | \\ _ = a; | | |
| 79 | \\ if (a != 0) a = 2 else _ = bar(); | 76 | \\ if (a != 0) a = 2 else _ = bar(); |
| 80 | \\} | 77 | \\} |
| 81 | }); | 78 | }); |
| ... | @@ -128,7 +125,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -128,7 +125,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 128 | \\ B: c_int, | 125 | \\ B: c_int, |
| 129 | \\ C: c_int, | 126 | \\ C: c_int, |
| 130 | \\ }; | 127 | \\ }; |
| 131 | \\ _ = struct_Foo; | | |
| 132 | \\ var a: struct_Foo = struct_Foo{ | 128 | \\ var a: struct_Foo = struct_Foo{ |
| 133 | \\ .A = @as(c_int, 0), | 129 | \\ .A = @as(c_int, 0), |
| 134 | \\ .B = 0, | 130 | \\ .B = 0, |
| ... | @@ -141,7 +137,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -141,7 +137,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 141 | \\ B: c_int, | 137 | \\ B: c_int, |
| 142 | \\ C: c_int, | 138 | \\ C: c_int, |
| 143 | \\ }; | 139 | \\ }; |
| 144 | \\ _ = struct_Foo_1; | | |
| 145 | \\ var a_2: struct_Foo_1 = struct_Foo_1{ | 140 | \\ var a_2: struct_Foo_1 = struct_Foo_1{ |
| 146 | \\ .A = @as(c_int, 0), | 141 | \\ .A = @as(c_int, 0), |
| 147 | \\ .B = 0, | 142 | \\ .B = 0, |
| ... | @@ -178,7 +173,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -178,7 +173,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 178 | \\ }; | 173 | \\ }; |
| 179 | \\ _ = union_unnamed_1; | 174 | \\ _ = union_unnamed_1; |
| 180 | \\ const Foo = union_unnamed_1; | 175 | \\ const Foo = union_unnamed_1; |
| 181 | \\ _ = Foo; | | |
| 182 | \\ var a: Foo = Foo{ | 176 | \\ var a: Foo = Foo{ |
| 183 | \\ .A = @as(c_int, 0), | 177 | \\ .A = @as(c_int, 0), |
| 184 | \\ }; | 178 | \\ }; |
| ... | @@ -191,7 +185,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -191,7 +185,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 191 | \\ }; | 185 | \\ }; |
| 192 | \\ _ = union_unnamed_2; | 186 | \\ _ = union_unnamed_2; |
| 193 | \\ const Foo_1 = union_unnamed_2; | 187 | \\ const Foo_1 = union_unnamed_2; |
| 194 | \\ _ = Foo_1; | | |
| 195 | \\ var a_2: Foo_1 = Foo_1{ | 188 | \\ var a_2: Foo_1 = Foo_1{ |
| 196 | \\ .A = @as(c_int, 0), | 189 | \\ .A = @as(c_int, 0), |
| 197 | \\ }; | 190 | \\ }; |
| ... | @@ -205,7 +198,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -205,7 +198,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 205 | \\#define MEM_PHYSICAL_TO_K0(x) (void*)((uint32_t)(x) + SYS_BASE_CACHED) | 198 | \\#define MEM_PHYSICAL_TO_K0(x) (void*)((uint32_t)(x) + SYS_BASE_CACHED) |
| 206 | , &[_][]const u8{ | 199 | , &[_][]const u8{ |
| 207 | \\pub inline fn MEM_PHYSICAL_TO_K0(x: anytype) ?*c_void { | 200 | \\pub inline fn MEM_PHYSICAL_TO_K0(x: anytype) ?*c_void { |
| 208 | \\ _ = x; | | |
| 209 | \\ return @import("std").zig.c_translation.cast(?*c_void, @import("std").zig.c_translation.cast(u32, x) + SYS_BASE_CACHED); | 201 | \\ return @import("std").zig.c_translation.cast(?*c_void, @import("std").zig.c_translation.cast(u32, x) + SYS_BASE_CACHED); |
| 210 | \\} | 202 | \\} |
| 211 | }); | 203 | }); |
| ... | @@ -247,7 +239,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -247,7 +239,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 247 | \\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)); | 239 | \\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)); |
| 248 | , | 240 | , |
| 249 | \\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))) { | 241 | \\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; | | |
| 251 | \\ 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)); | 242 | \\ 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)); |
| 252 | \\} | 243 | \\} |
| 253 | }); | 244 | }); |
| ... | @@ -328,7 +319,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -328,7 +319,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 328 | \\pub const Color = struct_Color; | 319 | \\pub const Color = struct_Color; |
| 329 | , | 320 | , |
| 330 | \\pub inline fn CLITERAL(type_1: anytype) @TypeOf(type_1) { | 321 | \\pub inline fn CLITERAL(type_1: anytype) @TypeOf(type_1) { |
| 331 | \\ _ = type_1; | | |
| 332 | \\ return type_1; | 322 | \\ return type_1; |
| 333 | \\} | 323 | \\} |
| 334 | , | 324 | , |
| ... | @@ -346,7 +336,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -346,7 +336,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 346 | \\}; | 336 | \\}; |
| 347 | , | 337 | , |
| 348 | \\pub inline fn A(_x: anytype) MyCStruct { | 338 | \\pub inline fn A(_x: anytype) MyCStruct { |
| 349 | \\ _ = _x; | | |
| 350 | \\ return @import("std").mem.zeroInit(MyCStruct, .{ | 339 | \\ return @import("std").mem.zeroInit(MyCStruct, .{ |
| 351 | \\ .x = _x, | 340 | \\ .x = _x, |
| 352 | \\ }); | 341 | \\ }); |
| ... | @@ -377,7 +366,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -377,7 +366,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 377 | \\#define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0) | 366 | \\#define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0) |
| 378 | , &[_][]const u8{ | 367 | , &[_][]const u8{ |
| 379 | \\pub inline fn __ferror_unlocked_body(_fp: anytype) @TypeOf((_fp.*._flags & _IO_ERR_SEEN) != @as(c_int, 0)) { | 368 | \\pub inline fn __ferror_unlocked_body(_fp: anytype) @TypeOf((_fp.*._flags & _IO_ERR_SEEN) != @as(c_int, 0)) { |
| 380 | \\ _ = _fp; | | |
| 381 | \\ return (_fp.*._flags & _IO_ERR_SEEN) != @as(c_int, 0); | 369 | \\ return (_fp.*._flags & _IO_ERR_SEEN) != @as(c_int, 0); |
| 382 | \\} | 370 | \\} |
| 383 | }); | 371 | }); |
| ... | @@ -387,7 +375,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -387,7 +375,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 387 | \\#define BAR 1 && 2 > 4 | 375 | \\#define BAR 1 && 2 > 4 |
| 388 | , &[_][]const u8{ | 376 | , &[_][]const u8{ |
| 389 | \\pub inline fn FOO(x: anytype) @TypeOf(@boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0))) { | 377 | \\pub inline fn FOO(x: anytype) @TypeOf(@boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0))) { |
| 390 | \\ _ = x; | | |
| 391 | \\ return @boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0)); | 378 | \\ return @boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0)); |
| 392 | \\} | 379 | \\} |
| 393 | , | 380 | , |
| ... | @@ -450,7 +437,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -450,7 +437,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 450 | \\}; | 437 | \\}; |
| 451 | , | 438 | , |
| 452 | \\pub inline fn bar(x: anytype) @TypeOf(baz(@as(c_int, 1), @as(c_int, 2))) { | 439 | \\pub inline fn bar(x: anytype) @TypeOf(baz(@as(c_int, 1), @as(c_int, 2))) { |
| 453 | \\ _ = x; | | |
| 454 | \\ return blk: { | 440 | \\ return blk: { |
| 455 | \\ _ = &x; | 441 | \\ _ = &x; |
| 456 | \\ _ = @as(c_int, 3); | 442 | \\ _ = @as(c_int, 3); |
| ... | @@ -580,7 +566,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -580,7 +566,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 580 | \\}; | 566 | \\}; |
| 581 | \\pub export fn foo(arg_x: [*c]outer) void { | 567 | \\pub export fn foo(arg_x: [*c]outer) void { |
| 582 | \\ var x = arg_x; | 568 | \\ var x = arg_x; |
| 583 | \\ _ = x; | | |
| 584 | \\ x.*.unnamed_0.unnamed_0.y = @bitCast(c_int, @as(c_uint, x.*.unnamed_0.x)); | 569 | \\ x.*.unnamed_0.unnamed_0.y = @bitCast(c_int, @as(c_uint, x.*.unnamed_0.x)); |
| 585 | \\} | 570 | \\} |
| 586 | }); | 571 | }); |
| ... | @@ -667,7 +652,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -667,7 +652,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 667 | \\pub const struct_opaque_2 = opaque {}; | 652 | \\pub const struct_opaque_2 = opaque {}; |
| 668 | \\pub export fn function(arg_opaque_1: ?*struct_opaque) void { | 653 | \\pub export fn function(arg_opaque_1: ?*struct_opaque) void { |
| 669 | \\ var opaque_1 = arg_opaque_1; | 654 | \\ var opaque_1 = arg_opaque_1; |
| 670 | \\ _ = opaque_1; | | |
| 671 | \\ var cast: ?*struct_opaque_2 = @ptrCast(?*struct_opaque_2, opaque_1); | 655 | \\ var cast: ?*struct_opaque_2 = @ptrCast(?*struct_opaque_2, opaque_1); |
| 672 | \\ _ = cast; | 656 | \\ _ = cast; |
| 673 | \\} | 657 | \\} |
| ... | @@ -763,7 +747,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -763,7 +747,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 763 | , &[_][]const u8{ | 747 | , &[_][]const u8{ |
| 764 | \\pub export fn foo() void { | 748 | \\pub export fn foo() void { |
| 765 | \\ var a: c_int = undefined; | 749 | \\ var a: c_int = undefined; |
| 766 | \\ _ = a; | | |
| 767 | \\ _ = @as(c_int, 1); | 750 | \\ _ = @as(c_int, 1); |
| 768 | \\ _ = "hey"; | 751 | \\ _ = "hey"; |
| 769 | \\ _ = @as(c_int, 1) + @as(c_int, 1); | 752 | \\ _ = @as(c_int, 1) + @as(c_int, 1); |
| ... | @@ -849,7 +832,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -849,7 +832,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 849 | \\pub extern fn foo() void; | 832 | \\pub extern fn foo() void; |
| 850 | \\pub export fn bar() void { | 833 | \\pub export fn bar() void { |
| 851 | \\ var func_ptr: ?*c_void = @ptrCast(?*c_void, foo); | 834 | \\ var func_ptr: ?*c_void = @ptrCast(?*c_void, foo); |
| 852 | \\ _ = func_ptr; | | |
| 853 | \\ var typed_func_ptr: ?fn () callconv(.C) void = @intToPtr(?fn () callconv(.C) void, @intCast(c_ulong, @ptrToInt(func_ptr))); | 835 | \\ var typed_func_ptr: ?fn () callconv(.C) void = @intToPtr(?fn () callconv(.C) void, @intCast(c_ulong, @ptrToInt(func_ptr))); |
| 854 | \\ _ = typed_func_ptr; | 836 | \\ _ = typed_func_ptr; |
| 855 | \\} | 837 | \\} |
| ... | @@ -881,11 +863,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -881,11 +863,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 881 | , &[_][]const u8{ | 863 | , &[_][]const u8{ |
| 882 | \\pub export fn s() c_int { | 864 | \\pub export fn s() c_int { |
| 883 | \\ var a: c_int = undefined; | 865 | \\ var a: c_int = undefined; |
| 884 | \\ _ = a; | | |
| 885 | \\ var b: c_int = undefined; | 866 | \\ var b: c_int = undefined; |
| 886 | \\ _ = b; | | |
| 887 | \\ var c: c_int = undefined; | 867 | \\ var c: c_int = undefined; |
| 888 | \\ _ = c; | | |
| 889 | \\ c = a + b; | 868 | \\ c = a + b; |
| 890 | \\ c = a - b; | 869 | \\ c = a - b; |
| 891 | \\ c = a * b; | 870 | \\ c = a * b; |
| ... | @@ -895,11 +874,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -895,11 +874,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 895 | \\} | 874 | \\} |
| 896 | \\pub export fn u() c_uint { | 875 | \\pub export fn u() c_uint { |
| 897 | \\ var a: c_uint = undefined; | 876 | \\ var a: c_uint = undefined; |
| 898 | \\ _ = a; | | |
| 899 | \\ var b: c_uint = undefined; | 877 | \\ var b: c_uint = undefined; |
| 900 | \\ _ = b; | | |
| 901 | \\ var c: c_uint = undefined; | 878 | \\ var c: c_uint = undefined; |
| 902 | \\ _ = c; | | |
| 903 | \\ c = a +% b; | 879 | \\ c = a +% b; |
| 904 | \\ c = a -% b; | 880 | \\ c = a -% b; |
| 905 | \\ c = a *% b; | 881 | \\ c = a *% b; |
| ... | @@ -1263,7 +1239,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1263,7 +1239,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1263 | \\pub export fn foo() void { | 1239 | \\pub export fn foo() void { |
| 1264 | \\ var a: c_int = undefined; | 1240 | \\ var a: c_int = undefined; |
| 1265 | \\ _ = a; | 1241 | \\ _ = a; |
| 1266 | \\ _ = a; | | |
| 1267 | \\} | 1242 | \\} |
| 1268 | }); | 1243 | }); |
| 1269 | | 1244 | |
| ... | @@ -1275,7 +1250,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1275,7 +1250,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1275 | , &[_][]const u8{ | 1250 | , &[_][]const u8{ |
| 1276 | \\pub export fn foo() ?*c_void { | 1251 | \\pub export fn foo() ?*c_void { |
| 1277 | \\ var x: [*c]c_ushort = undefined; | 1252 | \\ var x: [*c]c_ushort = undefined; |
| 1278 | \\ _ = x; | | |
| 1279 | \\ return @ptrCast(?*c_void, x); | 1253 | \\ return @ptrCast(?*c_void, x); |
| 1280 | \\} | 1254 | \\} |
| 1281 | }); | 1255 | }); |
| ... | @@ -1332,7 +1306,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1332,7 +1306,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1332 | \\pub export fn foo() void { | 1306 | \\pub export fn foo() void { |
| 1333 | \\ { | 1307 | \\ { |
| 1334 | \\ var i: c_int = 0; | 1308 | \\ var i: c_int = 0; |
| 1335 | \\ _ = i; | | |
| 1336 | \\ while (i != 0) : (i += 1) {} | 1309 | \\ while (i != 0) : (i += 1) {} |
| 1337 | \\ } | 1310 | \\ } |
| 1338 | \\} | 1311 | \\} |
| ... | @@ -1356,7 +1329,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1356,7 +1329,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1356 | , &[_][]const u8{ | 1329 | , &[_][]const u8{ |
| 1357 | \\pub export fn foo() void { | 1330 | \\pub export fn foo() void { |
| 1358 | \\ var i: c_int = undefined; | 1331 | \\ var i: c_int = undefined; |
| 1359 | \\ _ = i; | | |
| 1360 | \\ { | 1332 | \\ { |
| 1361 | \\ i = 3; | 1333 | \\ i = 3; |
| 1362 | \\ while (i != 0) : (i -= 1) {} | 1334 | \\ while (i != 0) : (i -= 1) {} |
| ... | @@ -1400,7 +1372,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1400,7 +1372,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1400 | , &[_][]const u8{ | 1372 | , &[_][]const u8{ |
| 1401 | \\pub export fn ptrcast() [*c]f32 { | 1373 | \\pub export fn ptrcast() [*c]f32 { |
| 1402 | \\ var a: [*c]c_int = undefined; | 1374 | \\ var a: [*c]c_int = undefined; |
| 1403 | \\ _ = a; | | |
| 1404 | \\ return @ptrCast([*c]f32, @alignCast(@import("std").meta.alignment(f32), a)); | 1375 | \\ return @ptrCast([*c]f32, @alignCast(@import("std").meta.alignment(f32), a)); |
| 1405 | \\} | 1376 | \\} |
| 1406 | }); | 1377 | }); |
| ... | @@ -1424,7 +1395,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1424,7 +1395,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1424 | , &[_][]const u8{ | 1395 | , &[_][]const u8{ |
| 1425 | \\pub export fn test_ptr_cast() void { | 1396 | \\pub export fn test_ptr_cast() void { |
| 1426 | \\ var p: ?*c_void = undefined; | 1397 | \\ var p: ?*c_void = undefined; |
| 1427 | \\ _ = p; | | |
| 1428 | \\ { | 1398 | \\ { |
| 1429 | \\ var to_char: [*c]u8 = @ptrCast([*c]u8, @alignCast(@import("std").meta.alignment(u8), p)); | 1399 | \\ var to_char: [*c]u8 = @ptrCast([*c]u8, @alignCast(@import("std").meta.alignment(u8), p)); |
| 1430 | \\ _ = to_char; | 1400 | \\ _ = to_char; |
| ... | @@ -1461,11 +1431,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1461,11 +1431,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1461 | , &[_][]const u8{ | 1431 | , &[_][]const u8{ |
| 1462 | \\pub export fn while_none_bool() c_int { | 1432 | \\pub export fn while_none_bool() c_int { |
| 1463 | \\ var a: c_int = undefined; | 1433 | \\ var a: c_int = undefined; |
| 1464 | \\ _ = a; | | |
| 1465 | \\ var b: f32 = undefined; | 1434 | \\ var b: f32 = undefined; |
| 1466 | \\ _ = b; | | |
| 1467 | \\ var c: ?*c_void = undefined; | 1435 | \\ var c: ?*c_void = undefined; |
| 1468 | \\ _ = c; | | |
| 1469 | \\ while (a != 0) return 0; | 1436 | \\ while (a != 0) return 0; |
| 1470 | \\ while (b != 0) return 1; | 1437 | \\ while (b != 0) return 1; |
| 1471 | \\ while (c != null) return 2; | 1438 | \\ while (c != null) return 2; |
| ... | @@ -1486,11 +1453,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1486,11 +1453,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1486 | , &[_][]const u8{ | 1453 | , &[_][]const u8{ |
| 1487 | \\pub export fn for_none_bool() c_int { | 1454 | \\pub export fn for_none_bool() c_int { |
| 1488 | \\ var a: c_int = undefined; | 1455 | \\ var a: c_int = undefined; |
| 1489 | \\ _ = a; | | |
| 1490 | \\ var b: f32 = undefined; | 1456 | \\ var b: f32 = undefined; |
| 1491 | \\ _ = b; | | |
| 1492 | \\ var c: ?*c_void = undefined; | 1457 | \\ var c: ?*c_void = undefined; |
| 1493 | \\ _ = c; | | |
| 1494 | \\ while (a != 0) return 0; | 1458 | \\ while (a != 0) return 0; |
| 1495 | \\ while (b != 0) return 1; | 1459 | \\ while (b != 0) return 1; |
| 1496 | \\ while (c != null) return 2; | 1460 | \\ while (c != null) return 2; |
| ... | @@ -1527,7 +1491,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1527,7 +1491,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1527 | , &[_][]const u8{ | 1491 | , &[_][]const u8{ |
| 1528 | \\pub export fn foo() void { | 1492 | \\pub export fn foo() void { |
| 1529 | \\ var x: [*c]c_int = undefined; | 1493 | \\ var x: [*c]c_int = undefined; |
| 1530 | \\ _ = x; | | |
| 1531 | \\ x.* = 1; | 1494 | \\ x.* = 1; |
| 1532 | \\} | 1495 | \\} |
| 1533 | }); | 1496 | }); |
| ... | @@ -1541,9 +1504,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1541,9 +1504,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1541 | , &[_][]const u8{ | 1504 | , &[_][]const u8{ |
| 1542 | \\pub export fn foo() c_int { | 1505 | \\pub export fn foo() c_int { |
| 1543 | \\ var x: c_int = 1234; | 1506 | \\ var x: c_int = 1234; |
| 1544 | \\ _ = x; | | |
| 1545 | \\ var ptr: [*c]c_int = &x; | 1507 | \\ var ptr: [*c]c_int = &x; |
| 1546 | \\ _ = ptr; | | |
| 1547 | \\ return ptr.*; | 1508 | \\ return ptr.*; |
| 1548 | \\} | 1509 | \\} |
| 1549 | }); | 1510 | }); |
| ... | @@ -1556,7 +1517,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1556,7 +1517,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1556 | , &[_][]const u8{ | 1517 | , &[_][]const u8{ |
| 1557 | \\pub export fn foo() c_int { | 1518 | \\pub export fn foo() c_int { |
| 1558 | \\ var x: c_int = undefined; | 1519 | \\ var x: c_int = undefined; |
| 1559 | \\ _ = x; | | |
| 1560 | \\ return ~x; | 1520 | \\ return ~x; |
| 1561 | \\} | 1521 | \\} |
| 1562 | }); | 1522 | }); |
| ... | @@ -1574,11 +1534,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1574,11 +1534,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1574 | , &[_][]const u8{ | 1534 | , &[_][]const u8{ |
| 1575 | \\pub export fn foo() c_int { | 1535 | \\pub export fn foo() c_int { |
| 1576 | \\ var a: c_int = undefined; | 1536 | \\ var a: c_int = undefined; |
| 1577 | \\ _ = a; | | |
| 1578 | \\ var b: f32 = undefined; | 1537 | \\ var b: f32 = undefined; |
| 1579 | \\ _ = b; | | |
| 1580 | \\ var c: ?*c_void = undefined; | 1538 | \\ var c: ?*c_void = undefined; |
| 1581 | \\ _ = c; | | |
| 1582 | \\ return @boolToInt(!(a == @as(c_int, 0))); | 1539 | \\ return @boolToInt(!(a == @as(c_int, 0))); |
| 1583 | \\ return @boolToInt(!(a != 0)); | 1540 | \\ return @boolToInt(!(a != 0)); |
| 1584 | \\ return @boolToInt(!(b != 0)); | 1541 | \\ return @boolToInt(!(b != 0)); |
| ... | @@ -1891,13 +1848,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1891,13 +1848,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1891 | \\pub extern var c: c_int; | 1848 | \\pub extern var c: c_int; |
| 1892 | , | 1849 | , |
| 1893 | \\pub inline fn BASIC(c_1: anytype) @TypeOf(c_1 * @as(c_int, 2)) { | 1850 | \\pub inline fn BASIC(c_1: anytype) @TypeOf(c_1 * @as(c_int, 2)) { |
| 1894 | \\ _ = c_1; | | |
| 1895 | \\ return c_1 * @as(c_int, 2); | 1851 | \\ return c_1 * @as(c_int, 2); |
| 1896 | \\} | 1852 | \\} |
| 1897 | , | 1853 | , |
| 1898 | \\pub inline fn FOO(L: anytype, b: anytype) @TypeOf(L + b) { | 1854 | \\pub inline fn FOO(L: anytype, b: anytype) @TypeOf(L + b) { |
| 1899 | \\ _ = L; | | |
| 1900 | \\ _ = b; | | |
| 1901 | \\ return L + b; | 1855 | \\ return L + b; |
| 1902 | \\} | 1856 | \\} |
| 1903 | , | 1857 | , |
| ... | @@ -1951,9 +1905,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1951,9 +1905,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1951 | \\ var c_1 = arg_c_1; | 1905 | \\ var c_1 = arg_c_1; |
| 1952 | \\ _ = c_1; | 1906 | \\ _ = c_1; |
| 1953 | \\ var a_2: c_int = undefined; | 1907 | \\ var a_2: c_int = undefined; |
| 1954 | \\ _ = a_2; | | |
| 1955 | \\ var b_3: u8 = 123; | 1908 | \\ var b_3: u8 = 123; |
| 1956 | \\ _ = b_3; | | |
| 1957 | \\ b_3 = @bitCast(u8, @truncate(i8, a_2)); | 1909 | \\ b_3 = @bitCast(u8, @truncate(i8, a_2)); |
| 1958 | \\ { | 1910 | \\ { |
| 1959 | \\ var d: c_int = 5; | 1911 | \\ var d: c_int = 5; |
| ... | @@ -1994,9 +1946,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1994,9 +1946,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1994 | , &[_][]const u8{ | 1946 | , &[_][]const u8{ |
| 1995 | \\pub export fn foo() void { | 1947 | \\pub export fn foo() void { |
| 1996 | \\ var a: c_int = undefined; | 1948 | \\ var a: c_int = undefined; |
| 1997 | \\ _ = a; | | |
| 1998 | \\ var b: c_int = undefined; | 1949 | \\ var b: c_int = undefined; |
| 1999 | \\ _ = b; | | |
| 2000 | \\ a = blk: { | 1950 | \\ a = blk: { |
| 2001 | \\ const tmp = @as(c_int, 2); | 1951 | \\ const tmp = @as(c_int, 2); |
| 2002 | \\ b = tmp; | 1952 | \\ b = tmp; |
| ... | @@ -2026,13 +1976,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2026,13 +1976,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2026 | , &[_][]const u8{ | 1976 | , &[_][]const u8{ |
| 2027 | \\pub export fn foo() c_int { | 1977 | \\pub export fn foo() c_int { |
| 2028 | \\ var a: c_int = 5; | 1978 | \\ var a: c_int = 5; |
| 2029 | \\ _ = a; | | |
| 2030 | \\ while (true) { | 1979 | \\ while (true) { |
| 2031 | \\ a = 2; | 1980 | \\ a = 2; |
| 2032 | \\ } | 1981 | \\ } |
| 2033 | \\ while (true) { | 1982 | \\ while (true) { |
| 2034 | \\ var a_1: c_int = 4; | 1983 | \\ var a_1: c_int = 4; |
| 2035 | \\ _ = a_1; | | |
| 2036 | \\ a_1 = 9; | 1984 | \\ a_1 = 9; |
| 2037 | \\ return blk: { | 1985 | \\ return blk: { |
| 2038 | \\ _ = @as(c_int, 6); | 1986 | \\ _ = @as(c_int, 6); |
| ... | @@ -2041,7 +1989,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2041,7 +1989,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2041 | \\ } | 1989 | \\ } |
| 2042 | \\ while (true) { | 1990 | \\ while (true) { |
| 2043 | \\ var a_1: c_int = 2; | 1991 | \\ var a_1: c_int = 2; |
| 2044 | \\ _ = a_1; | | |
| 2045 | \\ a_1 = 12; | 1992 | \\ a_1 = 12; |
| 2046 | \\ } | 1993 | \\ } |
| 2047 | \\ while (true) { | 1994 | \\ while (true) { |
| ... | @@ -2063,12 +2010,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2063,12 +2010,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2063 | \\pub export fn foo() void { | 2010 | \\pub export fn foo() void { |
| 2064 | \\ { | 2011 | \\ { |
| 2065 | \\ var i: c_int = 2; | 2012 | \\ var i: c_int = 2; |
| 2066 | \\ _ = i; | | |
| 2067 | \\ var b: c_int = 4; | 2013 | \\ var b: c_int = 4; |
| 2068 | \\ _ = b; | 2014 | \\ _ = b; |
| 2069 | \\ while ((i + @as(c_int, 2)) != 0) : (i = 2) { | 2015 | \\ while ((i + @as(c_int, 2)) != 0) : (i = 2) { |
| 2070 | \\ var a: c_int = 2; | 2016 | \\ var a: c_int = 2; |
| 2071 | \\ _ = a; | | |
| 2072 | \\ _ = blk: { | 2017 | \\ _ = blk: { |
| 2073 | \\ _ = blk_1: { | 2018 | \\ _ = blk_1: { |
| 2074 | \\ a = 6; | 2019 | \\ a = 6; |
| ... | @@ -2152,9 +2097,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2152,9 +2097,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2152 | , &[_][]const u8{ | 2097 | , &[_][]const u8{ |
| 2153 | \\pub export fn switch_fn(arg_i: c_int) void { | 2098 | \\pub export fn switch_fn(arg_i: c_int) void { |
| 2154 | \\ var i = arg_i; | 2099 | \\ var i = arg_i; |
| 2155 | \\ _ = i; | | |
| 2156 | \\ var res: c_int = 0; | 2100 | \\ var res: c_int = 0; |
| 2157 | \\ _ = res; | | |
| 2158 | \\ while (true) { | 2101 | \\ while (true) { |
| 2159 | \\ switch (i) { | 2102 | \\ switch (i) { |
| 2160 | \\ @as(c_int, 0) => { | 2103 | \\ @as(c_int, 0) => { |
| ... | @@ -2243,9 +2186,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2243,9 +2186,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2243 | , &[_][]const u8{ | 2186 | , &[_][]const u8{ |
| 2244 | \\pub export fn max(arg_a: c_int) void { | 2187 | \\pub export fn max(arg_a: c_int) void { |
| 2245 | \\ var a = arg_a; | 2188 | \\ var a = arg_a; |
| 2246 | \\ _ = a; | | |
| 2247 | \\ var tmp: c_int = undefined; | 2189 | \\ var tmp: c_int = undefined; |
| 2248 | \\ _ = tmp; | | |
| 2249 | \\ tmp = a; | 2190 | \\ tmp = a; |
| 2250 | \\ a = tmp; | 2191 | \\ a = tmp; |
| 2251 | \\} | 2192 | \\} |
| ... | @@ -2259,11 +2200,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2259,11 +2200,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2259 | , &[_][]const u8{ | 2200 | , &[_][]const u8{ |
| 2260 | \\pub export fn max(arg_a: c_int) void { | 2201 | \\pub export fn max(arg_a: c_int) void { |
| 2261 | \\ var a = arg_a; | 2202 | \\ var a = arg_a; |
| 2262 | \\ _ = a; | | |
| 2263 | \\ var b: c_int = undefined; | 2203 | \\ var b: c_int = undefined; |
| 2264 | \\ _ = b; | | |
| 2265 | \\ var c: c_int = undefined; | 2204 | \\ var c: c_int = undefined; |
| 2266 | \\ _ = c; | | |
| 2267 | \\ c = blk: { | 2205 | \\ c = blk: { |
| 2268 | \\ const tmp = a; | 2206 | \\ const tmp = a; |
| 2269 | \\ b = tmp; | 2207 | \\ b = tmp; |
| ... | @@ -2292,7 +2230,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2292,7 +2230,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2292 | , &[_][]const u8{ | 2230 | , &[_][]const u8{ |
| 2293 | \\pub export fn float_to_int(arg_a: f32) c_int { | 2231 | \\pub export fn float_to_int(arg_a: f32) c_int { |
| 2294 | \\ var a = arg_a; | 2232 | \\ var a = arg_a; |
| 2295 | \\ _ = a; | | |
| 2296 | \\ return @floatToInt(c_int, a); | 2233 | \\ return @floatToInt(c_int, a); |
| 2297 | \\} | 2234 | \\} |
| 2298 | }); | 2235 | }); |
| ... | @@ -2356,13 +2293,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2356,13 +2293,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2356 | , &[_][]const u8{ | 2293 | , &[_][]const u8{ |
| 2357 | \\pub export fn foo() void { | 2294 | \\pub export fn foo() void { |
| 2358 | \\ var a: c_int = 2; | 2295 | \\ var a: c_int = 2; |
| 2359 | \\ _ = a; | | |
| 2360 | \\ while (true) { | 2296 | \\ while (true) { |
| 2361 | \\ a = a - @as(c_int, 1); | 2297 | \\ a = a - @as(c_int, 1); |
| 2362 | \\ if (!(a != 0)) break; | 2298 | \\ if (!(a != 0)) break; |
| 2363 | \\ } | 2299 | \\ } |
| 2364 | \\ var b: c_int = 2; | 2300 | \\ var b: c_int = 2; |
| 2365 | \\ _ = b; | | |
| 2366 | \\ while (true) { | 2301 | \\ while (true) { |
| 2367 | \\ b = b - @as(c_int, 1); | 2302 | \\ b = b - @as(c_int, 1); |
| 2368 | \\ if (!(b != 0)) break; | 2303 | \\ if (!(b != 0)) break; |
| ... | @@ -2403,37 +2338,21 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2403,37 +2338,21 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2403 | \\pub const SomeTypedef = c_int; | 2338 | \\pub const SomeTypedef = c_int; |
| 2404 | \\pub export fn and_or_non_bool(arg_a: c_int, arg_b: f32, arg_c: ?*c_void) c_int { | 2339 | \\pub export fn and_or_non_bool(arg_a: c_int, arg_b: f32, arg_c: ?*c_void) c_int { |
| 2405 | \\ var a = arg_a; | 2340 | \\ var a = arg_a; |
| 2406 | \\ _ = a; | | |
| 2407 | \\ var b = arg_b; | 2341 | \\ var b = arg_b; |
| 2408 | \\ _ = b; | | |
| 2409 | \\ var c = arg_c; | 2342 | \\ var c = arg_c; |
| 2410 | \\ _ = c; | | |
| 2411 | \\ var d: enum_Foo = @bitCast(c_uint, FooA); | 2343 | \\ var d: enum_Foo = @bitCast(c_uint, FooA); |
| 2412 | \\ _ = d; | | |
| 2413 | \\ var e: c_int = @boolToInt((a != 0) and (b != 0)); | 2344 | \\ var e: c_int = @boolToInt((a != 0) and (b != 0)); |
| 2414 | \\ _ = e; | | |
| 2415 | \\ var f: c_int = @boolToInt((b != 0) and (c != null)); | 2345 | \\ var f: c_int = @boolToInt((b != 0) and (c != null)); |
| 2416 | \\ _ = f; | | |
| 2417 | \\ var g: c_int = @boolToInt((a != 0) and (c != null)); | 2346 | \\ var g: c_int = @boolToInt((a != 0) and (c != null)); |
| 2418 | \\ _ = g; | | |
| 2419 | \\ var h: c_int = @boolToInt((a != 0) or (b != 0)); | 2347 | \\ var h: c_int = @boolToInt((a != 0) or (b != 0)); |
| 2420 | \\ _ = h; | | |
| 2421 | \\ var i: c_int = @boolToInt((b != 0) or (c != null)); | 2348 | \\ var i: c_int = @boolToInt((b != 0) or (c != null)); |
| 2422 | \\ _ = i; | | |
| 2423 | \\ var j: c_int = @boolToInt((a != 0) or (c != null)); | 2349 | \\ var j: c_int = @boolToInt((a != 0) or (c != null)); |
| 2424 | \\ _ = j; | | |
| 2425 | \\ var k: c_int = @boolToInt((a != 0) or (@bitCast(c_int, d) != 0)); | 2350 | \\ var k: c_int = @boolToInt((a != 0) or (@bitCast(c_int, d) != 0)); |
| 2426 | \\ _ = k; | | |
| 2427 | \\ var l: c_int = @boolToInt((@bitCast(c_int, d) != 0) and (b != 0)); | 2351 | \\ var l: c_int = @boolToInt((@bitCast(c_int, d) != 0) and (b != 0)); |
| 2428 | \\ _ = l; | | |
| 2429 | \\ var m: c_int = @boolToInt((c != null) or (d != 0)); | 2352 | \\ var m: c_int = @boolToInt((c != null) or (d != 0)); |
| 2430 | \\ _ = m; | | |
| 2431 | \\ var td: SomeTypedef = 44; | 2353 | \\ var td: SomeTypedef = 44; |
| 2432 | \\ _ = td; | | |
| 2433 | \\ var o: c_int = @boolToInt((td != 0) or (b != 0)); | 2354 | \\ var o: c_int = @boolToInt((td != 0) or (b != 0)); |
| 2434 | \\ _ = o; | | |
| 2435 | \\ var p: c_int = @boolToInt((c != null) and (td != 0)); | 2355 | \\ var p: c_int = @boolToInt((c != null) and (td != 0)); |
| 2436 | \\ _ = p; | | |
| 2437 | \\ return (((((((((e + f) + g) + h) + i) + j) + k) + l) + m) + o) + p; | 2356 | \\ return (((((((((e + f) + g) + h) + i) + j) + k) + l) + m) + o) + p; |
| 2438 | \\} | 2357 | \\} |
| 2439 | , | 2358 | , |
| ... | @@ -2473,9 +2392,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2473,9 +2392,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2473 | , &[_][]const u8{ | 2392 | , &[_][]const u8{ |
| 2474 | \\pub export fn max(arg_a: c_int, arg_b: c_int) c_int { | 2393 | \\pub export fn max(arg_a: c_int, arg_b: c_int) c_int { |
| 2475 | \\ var a = arg_a; | 2394 | \\ var a = arg_a; |
| 2476 | \\ _ = a; | | |
| 2477 | \\ var b = arg_b; | 2395 | \\ var b = arg_b; |
| 2478 | \\ _ = b; | | |
| 2479 | \\ return (a & b) ^ (a | b); | 2396 | \\ return (a & b) ^ (a | b); |
| 2480 | \\} | 2397 | \\} |
| 2481 | }); | 2398 | }); |
| ... | @@ -2494,23 +2411,14 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2494,23 +2411,14 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2494 | , &[_][]const u8{ | 2411 | , &[_][]const u8{ |
| 2495 | \\pub export fn test_comparisons(arg_a: c_int, arg_b: c_int) c_int { | 2412 | \\pub export fn test_comparisons(arg_a: c_int, arg_b: c_int) c_int { |
| 2496 | \\ var a = arg_a; | 2413 | \\ var a = arg_a; |
| 2497 | \\ _ = a; | | |
| 2498 | \\ var b = arg_b; | 2414 | \\ var b = arg_b; |
| 2499 | \\ _ = b; | | |
| 2500 | \\ var c: c_int = @boolToInt(a < b); | 2415 | \\ var c: c_int = @boolToInt(a < b); |
| 2501 | \\ _ = c; | | |
| 2502 | \\ var d: c_int = @boolToInt(a > b); | 2416 | \\ var d: c_int = @boolToInt(a > b); |
| 2503 | \\ _ = d; | | |
| 2504 | \\ var e: c_int = @boolToInt(a <= b); | 2417 | \\ var e: c_int = @boolToInt(a <= b); |
| 2505 | \\ _ = e; | | |
| 2506 | \\ var f: c_int = @boolToInt(a >= b); | 2418 | \\ var f: c_int = @boolToInt(a >= b); |
| 2507 | \\ _ = f; | | |
| 2508 | \\ var g: c_int = @boolToInt(c < d); | 2419 | \\ var g: c_int = @boolToInt(c < d); |
| 2509 | \\ _ = g; | | |
| 2510 | \\ var h: c_int = @boolToInt(e < f); | 2420 | \\ var h: c_int = @boolToInt(e < f); |
| 2511 | \\ _ = h; | | |
| 2512 | \\ var i: c_int = @boolToInt(g < h); | 2421 | \\ var i: c_int = @boolToInt(g < h); |
| 2513 | \\ _ = i; | | |
| 2514 | \\ return i; | 2422 | \\ return i; |
| 2515 | \\} | 2423 | \\} |
| 2516 | }); | 2424 | }); |
| ... | @@ -2526,9 +2434,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2526,9 +2434,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2526 | , &[_][]const u8{ | 2434 | , &[_][]const u8{ |
| 2527 | \\pub export fn max(arg_a: c_int, arg_b: c_int) c_int { | 2435 | \\pub export fn max(arg_a: c_int, arg_b: c_int) c_int { |
| 2528 | \\ var a = arg_a; | 2436 | \\ var a = arg_a; |
| 2529 | \\ _ = a; | | |
| 2530 | \\ var b = arg_b; | 2437 | \\ var b = arg_b; |
| 2531 | \\ _ = b; | | |
| 2532 | \\ if (a == b) return a; | 2438 | \\ if (a == b) return a; |
| 2533 | \\ if (a != b) return b; | 2439 | \\ if (a != b) return b; |
| 2534 | \\ return a; | 2440 | \\ return a; |
| ... | @@ -2545,7 +2451,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2545,7 +2451,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2545 | \\pub const yes = [*c]u8; | 2451 | \\pub const yes = [*c]u8; |
| 2546 | \\pub export fn foo() void { | 2452 | \\pub export fn foo() void { |
| 2547 | \\ var a: yes = undefined; | 2453 | \\ var a: yes = undefined; |
| 2548 | \\ _ = a; | | |
| 2549 | \\ if (a != null) { | 2454 | \\ if (a != null) { |
| 2550 | \\ _ = @as(c_int, 2); | 2455 | \\ _ = @as(c_int, 2); |
| 2551 | \\ } | 2456 | \\ } |
| ... | @@ -2565,7 +2470,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2565,7 +2470,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2565 | \\ return blk: { | 2470 | \\ return blk: { |
| 2566 | \\ var a: c_int = 1; | 2471 | \\ var a: c_int = 1; |
| 2567 | \\ _ = a; | 2472 | \\ _ = a; |
| 2568 | \\ _ = a; | | |
| 2569 | \\ break :blk a; | 2473 | \\ break :blk a; |
| 2570 | \\ }; | 2474 | \\ }; |
| 2571 | \\} | 2475 | \\} |
| ... | @@ -2591,7 +2495,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2591,7 +2495,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2591 | \\pub export var b: f32 = 2.0; | 2495 | \\pub export var b: f32 = 2.0; |
| 2592 | \\pub export fn foo() void { | 2496 | \\pub export fn foo() void { |
| 2593 | \\ var c: [*c]struct_Foo = undefined; | 2497 | \\ var c: [*c]struct_Foo = undefined; |
| 2594 | \\ _ = c; | | |
| 2595 | \\ _ = a.b; | 2498 | \\ _ = a.b; |
| 2596 | \\ _ = c.*.b; | 2499 | \\ _ = c.*.b; |
| 2597 | \\} | 2500 | \\} |
| ... | @@ -2611,7 +2514,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2611,7 +2514,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2611 | \\pub export var array: [100]c_int = [1]c_int{0} ** 100; | 2514 | \\pub export var array: [100]c_int = [1]c_int{0} ** 100; |
| 2612 | \\pub export fn foo(arg_index: c_int) c_int { | 2515 | \\pub export fn foo(arg_index: c_int) c_int { |
| 2613 | \\ var index = arg_index; | 2516 | \\ var index = arg_index; |
| 2614 | \\ _ = index; | | |
| 2615 | \\ return array[@intCast(c_uint, index)]; | 2517 | \\ return array[@intCast(c_uint, index)]; |
| 2616 | \\} | 2518 | \\} |
| 2617 | , | 2519 | , |
| ... | @@ -2626,9 +2528,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2626,9 +2528,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2626 | , &[_][]const u8{ | 2528 | , &[_][]const u8{ |
| 2627 | \\pub export fn foo() void { | 2529 | \\pub export fn foo() void { |
| 2628 | \\ var a: [10]c_int = undefined; | 2530 | \\ var a: [10]c_int = undefined; |
| 2629 | \\ _ = a; | | |
| 2630 | \\ var i: c_int = 0; | 2531 | \\ var i: c_int = 0; |
| 2631 | \\ _ = i; | | |
| 2632 | \\ a[@intCast(c_uint, i)] = 0; | 2532 | \\ a[@intCast(c_uint, i)] = 0; |
| 2633 | \\} | 2533 | \\} |
| 2634 | }); | 2534 | }); |
| ... | @@ -2641,9 +2541,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2641,9 +2541,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2641 | , &[_][]const u8{ | 2541 | , &[_][]const u8{ |
| 2642 | \\pub export fn foo() void { | 2542 | \\pub export fn foo() void { |
| 2643 | \\ var a: [10]c_longlong = undefined; | 2543 | \\ var a: [10]c_longlong = undefined; |
| 2644 | \\ _ = a; | | |
| 2645 | \\ var i: c_longlong = 0; | 2544 | \\ var i: c_longlong = 0; |
| 2646 | \\ _ = i; | | |
| 2647 | \\ a[@intCast(usize, i)] = 0; | 2545 | \\ a[@intCast(usize, i)] = 0; |
| 2648 | \\} | 2546 | \\} |
| 2649 | }); | 2547 | }); |
| ... | @@ -2656,9 +2554,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2656,9 +2554,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2656 | , &[_][]const u8{ | 2554 | , &[_][]const u8{ |
| 2657 | \\pub export fn foo() void { | 2555 | \\pub export fn foo() void { |
| 2658 | \\ var a: [10]c_uint = undefined; | 2556 | \\ var a: [10]c_uint = undefined; |
| 2659 | \\ _ = a; | | |
| 2660 | \\ var i: c_uint = 0; | 2557 | \\ var i: c_uint = 0; |
| 2661 | \\ _ = i; | | |
| 2662 | \\ a[i] = 0; | 2558 | \\ a[i] = 0; |
| 2663 | \\} | 2559 | \\} |
| 2664 | }); | 2560 | }); |
| ... | @@ -2667,7 +2563,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2667,7 +2563,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2667 | \\#define CALL(arg) bar(arg) | 2563 | \\#define CALL(arg) bar(arg) |
| 2668 | , &[_][]const u8{ | 2564 | , &[_][]const u8{ |
| 2669 | \\pub inline fn CALL(arg: anytype) @TypeOf(bar(arg)) { | 2565 | \\pub inline fn CALL(arg: anytype) @TypeOf(bar(arg)) { |
| 2670 | \\ _ = arg; | | |
| 2671 | \\ return bar(arg); | 2566 | \\ return bar(arg); |
| 2672 | \\} | 2567 | \\} |
| 2673 | }); | 2568 | }); |
| ... | @@ -2692,9 +2587,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2692,9 +2587,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2692 | , &[_][]const u8{ | 2587 | , &[_][]const u8{ |
| 2693 | \\pub export fn max(arg_a: c_int, arg_b: c_int) c_int { | 2588 | \\pub export fn max(arg_a: c_int, arg_b: c_int) c_int { |
| 2694 | \\ var a = arg_a; | 2589 | \\ var a = arg_a; |
| 2695 | \\ _ = a; | | |
| 2696 | \\ var b = arg_b; | 2590 | \\ var b = arg_b; |
| 2697 | \\ _ = b; | | |
| 2698 | \\ if ((a < b) or (a == b)) return b; | 2591 | \\ if ((a < b) or (a == b)) return b; |
| 2699 | \\ if ((a >= b) and (a == b)) return a; | 2592 | \\ if ((a >= b) and (a == b)) return a; |
| 2700 | \\ return a; | 2593 | \\ return a; |
| ... | @@ -2716,9 +2609,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2716,9 +2609,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2716 | , &[_][]const u8{ | 2609 | , &[_][]const u8{ |
| 2717 | \\pub export fn max(arg_a: c_int, arg_b: c_int) c_int { | 2610 | \\pub export fn max(arg_a: c_int, arg_b: c_int) c_int { |
| 2718 | \\ var a = arg_a; | 2611 | \\ var a = arg_a; |
| 2719 | \\ _ = a; | | |
| 2720 | \\ var b = arg_b; | 2612 | \\ var b = arg_b; |
| 2721 | \\ _ = b; | | |
| 2722 | \\ if (a < b) return b; | 2613 | \\ if (a < b) return b; |
| 2723 | \\ if (a < b) return b else return a; | 2614 | \\ if (a < b) return b else return a; |
| 2724 | \\ if (a < b) {} else {} | 2615 | \\ if (a < b) {} else {} |
| ... | @@ -2769,13 +2660,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2769,13 +2660,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2769 | \\; | 2660 | \\; |
| 2770 | \\pub export fn if_none_bool(arg_a: c_int, arg_b: f32, arg_c: ?*c_void, arg_d: enum_SomeEnum) c_int { | 2661 | \\pub export fn if_none_bool(arg_a: c_int, arg_b: f32, arg_c: ?*c_void, arg_d: enum_SomeEnum) c_int { |
| 2771 | \\ var a = arg_a; | 2662 | \\ var a = arg_a; |
| 2772 | \\ _ = a; | | |
| 2773 | \\ var b = arg_b; | 2663 | \\ var b = arg_b; |
| 2774 | \\ _ = b; | | |
| 2775 | \\ var c = arg_c; | 2664 | \\ var c = arg_c; |
| 2776 | \\ _ = c; | | |
| 2777 | \\ var d = arg_d; | 2665 | \\ var d = arg_d; |
| 2778 | \\ _ = d; | | |
| 2779 | \\ if (a != 0) return 0; | 2666 | \\ if (a != 0) return 0; |
| 2780 | \\ if (b != 0) return 1; | 2667 | \\ if (b != 0) return 1; |
| 2781 | \\ if (c != null) return 2; | 2668 | \\ if (c != null) return 2; |
| ... | @@ -2803,7 +2690,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2803,7 +2690,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2803 | , &[_][]const u8{ | 2690 | , &[_][]const u8{ |
| 2804 | \\pub export fn abs(arg_a: c_int) c_int { | 2691 | \\pub export fn abs(arg_a: c_int) c_int { |
| 2805 | \\ var a = arg_a; | 2692 | \\ var a = arg_a; |
| 2806 | \\ _ = a; | | |
| 2807 | \\ return if (a < @as(c_int, 0)) -a else a; | 2693 | \\ return if (a < @as(c_int, 0)) -a else a; |
| 2808 | \\} | 2694 | \\} |
| 2809 | }); | 2695 | }); |
| ... | @@ -2824,19 +2710,16 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2824,19 +2710,16 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2824 | , &[_][]const u8{ | 2710 | , &[_][]const u8{ |
| 2825 | \\pub export fn foo1(arg_a: c_uint) c_uint { | 2711 | \\pub export fn foo1(arg_a: c_uint) c_uint { |
| 2826 | \\ var a = arg_a; | 2712 | \\ var a = arg_a; |
| 2827 | \\ _ = a; | | |
| 2828 | \\ a +%= 1; | 2713 | \\ a +%= 1; |
| 2829 | \\ return a; | 2714 | \\ return a; |
| 2830 | \\} | 2715 | \\} |
| 2831 | \\pub export fn foo2(arg_a: c_int) c_int { | 2716 | \\pub export fn foo2(arg_a: c_int) c_int { |
| 2832 | \\ var a = arg_a; | 2717 | \\ var a = arg_a; |
| 2833 | \\ _ = a; | | |
| 2834 | \\ a += 1; | 2718 | \\ a += 1; |
| 2835 | \\ return a; | 2719 | \\ return a; |
| 2836 | \\} | 2720 | \\} |
| 2837 | \\pub export fn foo3(arg_a: [*c]c_int) [*c]c_int { | 2721 | \\pub export fn foo3(arg_a: [*c]c_int) [*c]c_int { |
| 2838 | \\ var a = arg_a; | 2722 | \\ var a = arg_a; |
| 2839 | \\ _ = a; | | |
| 2840 | \\ a += 1; | 2723 | \\ a += 1; |
| 2841 | \\ return a; | 2724 | \\ return a; |
| 2842 | \\} | 2725 | \\} |
| ... | @@ -2862,9 +2745,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2862,9 +2745,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2862 | \\} | 2745 | \\} |
| 2863 | \\pub export fn bar() void { | 2746 | \\pub export fn bar() void { |
| 2864 | \\ var f: ?fn () callconv(.C) void = foo; | 2747 | \\ var f: ?fn () callconv(.C) void = foo; |
| 2865 | \\ _ = f; | | |
| 2866 | \\ var b: ?fn () callconv(.C) c_int = baz; | 2748 | \\ var b: ?fn () callconv(.C) c_int = baz; |
| 2867 | \\ _ = b; | | |
| 2868 | \\ f.?(); | 2749 | \\ f.?(); |
| 2869 | \\ f.?(); | 2750 | \\ f.?(); |
| 2870 | \\ foo(); | 2751 | \\ foo(); |
| ... | @@ -2890,9 +2771,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2890,9 +2771,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2890 | , &[_][]const u8{ | 2771 | , &[_][]const u8{ |
| 2891 | \\pub export fn foo() void { | 2772 | \\pub export fn foo() void { |
| 2892 | \\ var i: c_int = 0; | 2773 | \\ var i: c_int = 0; |
| 2893 | \\ _ = i; | | |
| 2894 | \\ var u: c_uint = 0; | 2774 | \\ var u: c_uint = 0; |
| 2895 | \\ _ = u; | | |
| 2896 | \\ i += 1; | 2775 | \\ i += 1; |
| 2897 | \\ i -= 1; | 2776 | \\ i -= 1; |
| 2898 | \\ u +%= 1; | 2777 | \\ u +%= 1; |
| ... | @@ -2931,9 +2810,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2931,9 +2810,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2931 | , &[_][]const u8{ | 2810 | , &[_][]const u8{ |
| 2932 | \\pub export fn log2(arg_a: c_uint) c_int { | 2811 | \\pub export fn log2(arg_a: c_uint) c_int { |
| 2933 | \\ var a = arg_a; | 2812 | \\ var a = arg_a; |
| 2934 | \\ _ = a; | | |
| 2935 | \\ var i: c_int = 0; | 2813 | \\ var i: c_int = 0; |
| 2936 | \\ _ = i; | | |
| 2937 | \\ while (a > @bitCast(c_uint, @as(c_int, 0))) { | 2814 | \\ while (a > @bitCast(c_uint, @as(c_int, 0))) { |
| 2938 | \\ a >>= @intCast(@import("std").math.Log2Int(c_int), @as(c_int, 1)); | 2815 | \\ a >>= @intCast(@import("std").math.Log2Int(c_int), @as(c_int, 1)); |
| 2939 | \\ } | 2816 | \\ } |
| ... | @@ -2953,9 +2830,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2953,9 +2830,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2953 | , &[_][]const u8{ | 2830 | , &[_][]const u8{ |
| 2954 | \\pub export fn log2(arg_a: u32) c_int { | 2831 | \\pub export fn log2(arg_a: u32) c_int { |
| 2955 | \\ var a = arg_a; | 2832 | \\ var a = arg_a; |
| 2956 | \\ _ = a; | | |
| 2957 | \\ var i: c_int = 0; | 2833 | \\ var i: c_int = 0; |
| 2958 | \\ _ = i; | | |
| 2959 | \\ while (a > @bitCast(c_uint, @as(c_int, 0))) { | 2834 | \\ while (a > @bitCast(c_uint, @as(c_int, 0))) { |
| 2960 | \\ a >>= @intCast(@import("std").math.Log2Int(c_int), @as(c_int, 1)); | 2835 | \\ a >>= @intCast(@import("std").math.Log2Int(c_int), @as(c_int, 1)); |
| 2961 | \\ } | 2836 | \\ } |
| ... | @@ -2983,9 +2858,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2983,9 +2858,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2983 | , &[_][]const u8{ | 2858 | , &[_][]const u8{ |
| 2984 | \\pub export fn foo() void { | 2859 | \\pub export fn foo() void { |
| 2985 | \\ var a: c_int = 0; | 2860 | \\ var a: c_int = 0; |
| 2986 | \\ _ = a; | | |
| 2987 | \\ var b: c_uint = 0; | 2861 | \\ var b: c_uint = 0; |
| 2988 | \\ _ = b; | | |
| 2989 | \\ a += blk: { | 2862 | \\ a += blk: { |
| 2990 | \\ const ref = &a; | 2863 | \\ const ref = &a; |
| 2991 | \\ ref.* += @as(c_int, 1); | 2864 | \\ ref.* += @as(c_int, 1); |
| ... | @@ -3064,7 +2937,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3064,7 +2937,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3064 | , &[_][]const u8{ | 2937 | , &[_][]const u8{ |
| 3065 | \\pub export fn foo() void { | 2938 | \\pub export fn foo() void { |
| 3066 | \\ var a: c_uint = 0; | 2939 | \\ var a: c_uint = 0; |
| 3067 | \\ _ = a; | | |
| 3068 | \\ a +%= blk: { | 2940 | \\ a +%= blk: { |
| 3069 | \\ const ref = &a; | 2941 | \\ const ref = &a; |
| 3070 | \\ ref.* +%= @bitCast(c_uint, @as(c_int, 1)); | 2942 | \\ ref.* +%= @bitCast(c_uint, @as(c_int, 1)); |
| ... | @@ -3124,9 +2996,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3124,9 +2996,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3124 | , &[_][]const u8{ | 2996 | , &[_][]const u8{ |
| 3125 | \\pub export fn foo() void { | 2997 | \\pub export fn foo() void { |
| 3126 | \\ var i: c_int = 0; | 2998 | \\ var i: c_int = 0; |
| 3127 | \\ _ = i; | | |
| 3128 | \\ var u: c_uint = 0; | 2999 | \\ var u: c_uint = 0; |
| 3129 | \\ _ = u; | | |
| 3130 | \\ i += 1; | 3000 | \\ i += 1; |
| 3131 | \\ i -= 1; | 3001 | \\ i -= 1; |
| 3132 | \\ u +%= 1; | 3002 | \\ u +%= 1; |
| ... | @@ -3221,7 +3091,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3221,7 +3091,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3221 | \\pub fn bar() callconv(.C) void {} | 3091 | \\pub fn bar() callconv(.C) void {} |
| 3222 | \\pub export fn foo(arg_baz: ?fn () callconv(.C) [*c]c_int) void { | 3092 | \\pub export fn foo(arg_baz: ?fn () callconv(.C) [*c]c_int) void { |
| 3223 | \\ var baz = arg_baz; | 3093 | \\ var baz = arg_baz; |
| 3224 | \\ _ = baz; | | |
| 3225 | \\ bar(); | 3094 | \\ bar(); |
| 3226 | \\ _ = baz.?(); | 3095 | \\ _ = baz.?(); |
| 3227 | \\} | 3096 | \\} |
| ... | @@ -3304,14 +3173,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3304,14 +3173,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3304 | \\#define MAX(a, b) ((b) > (a) ? (b) : (a)) | 3173 | \\#define MAX(a, b) ((b) > (a) ? (b) : (a)) |
| 3305 | , &[_][]const u8{ | 3174 | , &[_][]const u8{ |
| 3306 | \\pub inline fn MIN(a: anytype, b: anytype) @TypeOf(if (b < a) b else a) { | 3175 | \\pub inline fn MIN(a: anytype, b: anytype) @TypeOf(if (b < a) b else a) { |
| 3307 | \\ _ = a; | | |
| 3308 | \\ _ = b; | | |
| 3309 | \\ return if (b < a) b else a; | 3176 | \\ return if (b < a) b else a; |
| 3310 | \\} | 3177 | \\} |
| 3311 | , | 3178 | , |
| 3312 | \\pub inline fn MAX(a: anytype, b: anytype) @TypeOf(if (b > a) b else a) { | 3179 | \\pub inline fn MAX(a: anytype, b: anytype) @TypeOf(if (b > a) b else a) { |
| 3313 | \\ _ = a; | | |
| 3314 | \\ _ = b; | | |
| 3315 | \\ return if (b > a) b else a; | 3180 | \\ return if (b > a) b else a; |
| 3316 | \\} | 3181 | \\} |
| 3317 | }); | 3182 | }); |
| ... | @@ -3323,9 +3188,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3323,9 +3188,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3323 | , &[_][]const u8{ | 3188 | , &[_][]const u8{ |
| 3324 | \\pub export fn foo(arg_p: [*c]c_int, arg_x: c_int) c_int { | 3189 | \\pub export fn foo(arg_p: [*c]c_int, arg_x: c_int) c_int { |
| 3325 | \\ var p = arg_p; | 3190 | \\ var p = arg_p; |
| 3326 | \\ _ = p; | | |
| 3327 | \\ var x = arg_x; | 3191 | \\ var x = arg_x; |
| 3328 | \\ _ = x; | | |
| 3329 | \\ return blk: { | 3192 | \\ return blk: { |
| 3330 | \\ const tmp = x; | 3193 | \\ const tmp = x; |
| 3331 | \\ (blk_1: { | 3194 | \\ (blk_1: { |
| ... | @@ -3352,7 +3215,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3352,7 +3215,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3352 | \\} | 3215 | \\} |
| 3353 | \\pub export fn bar(arg_x: c_long) c_ushort { | 3216 | \\pub export fn bar(arg_x: c_long) c_ushort { |
| 3354 | \\ var x = arg_x; | 3217 | \\ var x = arg_x; |
| 3355 | \\ _ = x; | | |
| 3356 | \\ return @bitCast(c_ushort, @truncate(c_short, x)); | 3218 | \\ return @bitCast(c_ushort, @truncate(c_short, x)); |
| 3357 | \\} | 3219 | \\} |
| 3358 | }); | 3220 | }); |
| ... | @@ -3365,7 +3227,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3365,7 +3227,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3365 | , &[_][]const u8{ | 3227 | , &[_][]const u8{ |
| 3366 | \\pub export fn foo(arg_bar_1: c_int) void { | 3228 | \\pub export fn foo(arg_bar_1: c_int) void { |
| 3367 | \\ var bar_1 = arg_bar_1; | 3229 | \\ var bar_1 = arg_bar_1; |
| 3368 | \\ _ = bar_1; | | |
| 3369 | \\ bar_1 = 2; | 3230 | \\ bar_1 = 2; |
| 3370 | \\} | 3231 | \\} |
| 3371 | \\pub export var bar: c_int = 4; | 3232 | \\pub export var bar: c_int = 4; |
| ... | @@ -3379,7 +3240,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3379,7 +3240,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3379 | , &[_][]const u8{ | 3240 | , &[_][]const u8{ |
| 3380 | \\pub export fn foo(arg_bar_1: c_int) void { | 3241 | \\pub export fn foo(arg_bar_1: c_int) void { |
| 3381 | \\ var bar_1 = arg_bar_1; | 3242 | \\ var bar_1 = arg_bar_1; |
| 3382 | \\ _ = bar_1; | | |
| 3383 | \\ bar_1 = 2; | 3243 | \\ bar_1 = 2; |
| 3384 | \\} | 3244 | \\} |
| 3385 | , | 3245 | , |
| ... | @@ -3413,12 +3273,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3413,12 +3273,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3413 | \\} | 3273 | \\} |
| 3414 | \\pub export fn bar(arg_a: [*c]const c_int) void { | 3274 | \\pub export fn bar(arg_a: [*c]const c_int) void { |
| 3415 | \\ var a = arg_a; | 3275 | \\ var a = arg_a; |
| 3416 | \\ _ = a; | | |
| 3417 | \\ foo(@intToPtr([*c]c_int, @ptrToInt(a))); | 3276 | \\ foo(@intToPtr([*c]c_int, @ptrToInt(a))); |
| 3418 | \\} | 3277 | \\} |
| 3419 | \\pub export fn baz(arg_a: [*c]volatile c_int) void { | 3278 | \\pub export fn baz(arg_a: [*c]volatile c_int) void { |
| 3420 | \\ var a = arg_a; | 3279 | \\ var a = arg_a; |
| 3421 | \\ _ = a; | | |
| 3422 | \\ foo(@intToPtr([*c]c_int, @ptrToInt(a))); | 3280 | \\ foo(@intToPtr([*c]c_int, @ptrToInt(a))); |
| 3423 | \\} | 3281 | \\} |
| 3424 | }); | 3282 | }); |
| ... | @@ -3433,13 +3291,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3433,13 +3291,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3433 | , &[_][]const u8{ | 3291 | , &[_][]const u8{ |
| 3434 | \\pub export fn foo(arg_x: bool) bool { | 3292 | \\pub export fn foo(arg_x: bool) bool { |
| 3435 | \\ var x = arg_x; | 3293 | \\ var x = arg_x; |
| 3436 | \\ _ = x; | | |
| 3437 | \\ var a: bool = @as(c_int, @boolToInt(x)) != @as(c_int, 1); | 3294 | \\ var a: bool = @as(c_int, @boolToInt(x)) != @as(c_int, 1); |
| 3438 | \\ _ = a; | | |
| 3439 | \\ var b: bool = @as(c_int, @boolToInt(a)) != @as(c_int, 0); | 3295 | \\ var b: bool = @as(c_int, @boolToInt(a)) != @as(c_int, 0); |
| 3440 | \\ _ = b; | | |
| 3441 | \\ var c: bool = @ptrToInt(foo) != 0; | 3296 | \\ var c: bool = @ptrToInt(foo) != 0; |
| 3442 | \\ _ = c; | | |
| 3443 | \\ return foo(@as(c_int, @boolToInt(c)) != @as(c_int, @boolToInt(b))); | 3297 | \\ return foo(@as(c_int, @boolToInt(c)) != @as(c_int, @boolToInt(b))); |
| 3444 | \\} | 3298 | \\} |
| 3445 | }); | 3299 | }); |
| ... | @@ -3450,9 +3304,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3450,9 +3304,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3450 | \\} | 3304 | \\} |
| 3451 | , &[_][]const u8{ | 3305 | , &[_][]const u8{ |
| 3452 | \\pub export fn max(x: c_int, arg_y: c_int) c_int { | 3306 | \\pub export fn max(x: c_int, arg_y: c_int) c_int { |
| 3453 | \\ _ = x; | | |
| 3454 | \\ var y = arg_y; | 3307 | \\ var y = arg_y; |
| 3455 | \\ _ = y; | | |
| 3456 | \\ return if (x > y) x else y; | 3308 | \\ return if (x > y) x else y; |
| 3457 | \\} | 3309 | \\} |
| 3458 | }); | 3310 | }); |
| ... | @@ -3513,7 +3365,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3513,7 +3365,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3513 | \\ | 3365 | \\ |
| 3514 | , &[_][]const u8{ | 3366 | , &[_][]const u8{ |
| 3515 | \\pub inline fn DefaultScreen(dpy: anytype) @TypeOf(@import("std").zig.c_translation.cast(_XPrivDisplay, dpy).*.default_screen) { | 3367 | \\pub inline fn DefaultScreen(dpy: anytype) @TypeOf(@import("std").zig.c_translation.cast(_XPrivDisplay, dpy).*.default_screen) { |
| 3516 | \\ _ = dpy; | | |
| 3517 | \\ return @import("std").zig.c_translation.cast(_XPrivDisplay, dpy).*.default_screen; | 3368 | \\ return @import("std").zig.c_translation.cast(_XPrivDisplay, dpy).*.default_screen; |
| 3518 | \\} | 3369 | \\} |
| 3519 | }); | 3370 | }); |
| ... | @@ -3733,7 +3584,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3733,7 +3584,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3733 | \\ const foo = struct { | 3584 | \\ const foo = struct { |
| 3734 | \\ var static: struct_FOO = @import("std").mem.zeroes(struct_FOO); | 3585 | \\ var static: struct_FOO = @import("std").mem.zeroes(struct_FOO); |
| 3735 | \\ }; | 3586 | \\ }; |
| 3736 | \\ _ = foo; | | |
| 3737 | \\ return foo.static.x; | 3587 | \\ return foo.static.x; |
| 3738 | \\} | 3588 | \\} |
| 3739 | }); | 3589 | }); |
| ... | @@ -3747,24 +3597,22 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3747,24 +3597,22 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3747 | \\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))); | 3597 | \\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))); |
| 3748 | }); | 3598 | }); |
| 3749 | | 3599 | |
| 3750 | cases.add("discard local variables and function parameters", | 3600 | cases.add("discard unused local variables and function parameters", |
| 3751 | \\#define FOO(A, B) (A) + (B) | 3601 | \\#define FOO(A, B) (A) |
| 3752 | \\int bar(int x, int y) { | 3602 | \\int bar(int x, int y) { |
| 3753 | \\ return x; | 3603 | \\ return x; |
| 3754 | \\} | 3604 | \\} |
| 3755 | , &[_][]const u8{ | 3605 | , &[_][]const u8{ |
| 3756 | \\pub export fn bar(arg_x: c_int, arg_y: c_int) c_int { | 3606 | \\pub export fn bar(arg_x: c_int, arg_y: c_int) c_int { |
| 3757 | \\ var x = arg_x; | 3607 | \\ var x = arg_x; |
| 3758 | \\ _ = x; | | |
| 3759 | \\ var y = arg_y; | 3608 | \\ var y = arg_y; |
| 3760 | \\ _ = y; | 3609 | \\ _ = y; |
| 3761 | \\ return x; | 3610 | \\ return x; |
| 3762 | \\} | 3611 | \\} |
| 3763 | , | 3612 | , |
| 3764 | \\pub inline fn FOO(A: anytype, B: anytype) @TypeOf(A + B) { | 3613 | \\pub inline fn FOO(A: anytype, B: anytype) @TypeOf(A) { |
| 3765 | \\ _ = A; | | |
| 3766 | \\ _ = B; | 3614 | \\ _ = B; |
| 3767 | \\ return A + B; | 3615 | \\ return A; |
| 3768 | \\} | 3616 | \\} |
| 3769 | }); | 3617 | }); |
| 3770 | | 3618 | |