authorgravatar for jacoblevgw@gmail.comJacob G-W <jacoblevgw@gmail.com> 2021-06-12 14:48:13-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-06-21 17:03:03-07:00
log18c1007a34e92c69fa87d3f2628fa076fae7941c
tree8a70e881ae3362ada3379191b3afd2d9f1b59441
parentf8b8f50b633babb9d8e8a17a70a214057274f2a0

stage2 tests: remove unused vars


6 files changed, 57 insertions(+), 36 deletions(-)

lib/std/debug.zig-1
......@@ -896,7 +896,6 @@ fn printLineFromFileAnyOs(out_stream: anytype, line_info: LineInfo) !void {
896896 var buf: [mem.page_size]u8 = undefined;
897897 var line: usize = 1;
898898 var column: usize = 1;
899 var abs_index: usize = 0;
900899 while (true) {
901900 const amt_read = try f.read(buf[0..]);
902901 const slice = buf[0..amt_read];
lib/std/pdb.zig+4-2
......@@ -590,7 +590,8 @@ pub const Pdb = struct {
590590
591591 var sect_cont_offset: usize = 0;
592592 if (section_contrib_size != 0) {
593 const version = reader.readEnum(SectionContrSubstreamVersion, .Little) catch |err| switch (err) {
593 // the version
594 _ = reader.readEnum(SectionContrSubstreamVersion, .Little) catch |err| switch (err) {
594595 error.InvalidValue => return error.InvalidDebugInfo,
595596 else => |e| return e,
596597 };
......@@ -616,7 +617,8 @@ pub const Pdb = struct {
616617
617618 // Parse the InfoStreamHeader.
618619 const version = try reader.readIntLittle(u32);
619 const signature = try reader.readIntLittle(u32);
620 // The signature
621 _ = try reader.readIntLittle(u32);
620622 const age = try reader.readIntLittle(u32);
621623 const guid = try reader.readBytesNoEof(16);
622624
lib/std/zig/parse.zig+2-2
......@@ -1005,7 +1005,7 @@ const Parser = struct {
10051005 },
10061006 });
10071007 };
1008 const else_payload = try p.parsePayload();
1008 _ = try p.parsePayload();
10091009 const else_expr = try p.expectStatement();
10101010 return p.addNode(.{
10111011 .tag = .@"if",
......@@ -1189,7 +1189,7 @@ const Parser = struct {
11891189 });
11901190 }
11911191 };
1192 const else_payload = try p.parsePayload();
1192 _ = try p.parsePayload();
11931193 const else_expr = try p.expectStatement();
11941194 return p.addNode(.{
11951195 .tag = .@"while",
test/stage2/cbe.zig+27-22
......@@ -93,16 +93,16 @@ pub fn addCases(ctx: *TestContext) !void {
9393 , "");
9494 case.addError(
9595 \\pub export fn main() c_int {
96 \\ const c = @intToError(0);
96 \\ _ = @intToError(0);
9797 \\ return 0;
9898 \\}
99 , &.{":2:27: error: integer value 0 represents no error"});
99 , &.{":2:21: error: integer value 0 represents no error"});
100100 case.addError(
101101 \\pub export fn main() c_int {
102 \\ const c = @intToError(3);
102 \\ _ = @intToError(3);
103103 \\ return 0;
104104 \\}
105 , &.{":2:27: error: integer value 3 represents no error"});
105 , &.{":2:21: error: integer value 3 represents no error"});
106106 }
107107
108108 {
......@@ -383,6 +383,7 @@ pub fn addCases(ctx: *TestContext) !void {
383383 \\ true => 2,
384384 \\ false => 3,
385385 \\ };
386 \\ _ = b;
386387 \\}
387388 , &.{
388389 ":6:9: error: duplicate switch value",
......@@ -398,6 +399,7 @@ pub fn addCases(ctx: *TestContext) !void {
398399 \\ f64, i32 => 3,
399400 \\ else => 4,
400401 \\ };
402 \\ _ = b;
401403 \\}
402404 , &.{
403405 ":6:14: error: duplicate switch value",
......@@ -414,6 +416,7 @@ pub fn addCases(ctx: *TestContext) !void {
414416 \\ f16...f64 => 3,
415417 \\ else => 4,
416418 \\ };
419 \\ _ = b;
417420 \\}
418421 , &.{
419422 ":3:30: error: ranges not allowed when switching on type 'type'",
......@@ -431,6 +434,7 @@ pub fn addCases(ctx: *TestContext) !void {
431434 \\ 3 => 40,
432435 \\ else => 50,
433436 \\ };
437 \\ _ = b;
434438 \\}
435439 , &.{
436440 ":8:14: error: unreachable else prong; all cases already handled",
......@@ -556,10 +560,10 @@ pub fn addCases(ctx: *TestContext) !void {
556560 \\const E1 = packed enum { a, b, c };
557561 \\const E2 = extern enum { a, b, c };
558562 \\export fn foo() void {
559 \\ const x = E1.a;
563 \\ _ = E1.a;
560564 \\}
561565 \\export fn bar() void {
562 \\ const x = E2.a;
566 \\ _ = E2.a;
563567 \\}
564568 , &.{
565569 ":1:12: error: enums do not support 'packed' or 'extern'; instead provide an explicit integer tag type",
......@@ -579,10 +583,10 @@ pub fn addCases(ctx: *TestContext) !void {
579583 \\ c,
580584 \\};
581585 \\export fn foo() void {
582 \\ const x = E1.a;
586 \\ _ = E1.a;
583587 \\}
584588 \\export fn bar() void {
585 \\ const x = E2.a;
589 \\ _ = E2.a;
586590 \\}
587591 , &.{
588592 ":3:5: error: enum fields cannot be marked comptime",
......@@ -621,7 +625,7 @@ pub fn addCases(ctx: *TestContext) !void {
621625 \\ c,
622626 \\};
623627 \\export fn foo() void {
624 \\ const x = E1.a;
628 \\ _ = E1.a;
625629 \\}
626630 , &.{
627631 ":3:7: error: expected ',', found 'align'",
......@@ -638,7 +642,7 @@ pub fn addCases(ctx: *TestContext) !void {
638642 \\ _,
639643 \\};
640644 \\export fn foo() void {
641 \\ const x = E1.a;
645 \\ _ = E1.a;
642646 \\}
643647 , &.{
644648 ":6:5: error: redundant non-exhaustive enum mark",
......@@ -653,7 +657,7 @@ pub fn addCases(ctx: *TestContext) !void {
653657 \\ _ = 10,
654658 \\};
655659 \\export fn foo() void {
656 \\ const x = E1.a;
660 \\ _ = E1.a;
657661 \\}
658662 , &.{
659663 ":5:9: error: '_' is used to mark an enum as non-exhaustive and cannot be assigned a value",
......@@ -662,7 +666,7 @@ pub fn addCases(ctx: *TestContext) !void {
662666 case.addError(
663667 \\const E1 = enum {};
664668 \\export fn foo() void {
665 \\ const x = E1.a;
669 \\ _ = E1.a;
666670 \\}
667671 , &.{
668672 ":1:12: error: enum declarations must have at least one tag",
......@@ -671,7 +675,7 @@ pub fn addCases(ctx: *TestContext) !void {
671675 case.addError(
672676 \\const E1 = enum { a, b, _ };
673677 \\export fn foo() void {
674 \\ const x = E1.a;
678 \\ _ = E1.a;
675679 \\}
676680 , &.{
677681 ":1:12: error: non-exhaustive enum missing integer tag type",
......@@ -681,7 +685,7 @@ pub fn addCases(ctx: *TestContext) !void {
681685 case.addError(
682686 \\const E1 = enum { a, b, c, b, d };
683687 \\pub export fn main() c_int {
684 \\ const x = E1.a;
688 \\ _ = E1.a;
685689 \\}
686690 , &.{
687691 ":1:28: error: duplicate enum tag",
......@@ -691,28 +695,28 @@ pub fn addCases(ctx: *TestContext) !void {
691695 case.addError(
692696 \\pub export fn main() c_int {
693697 \\ const a = true;
694 \\ const b = @enumToInt(a);
698 \\ _ = @enumToInt(a);
695699 \\}
696700 , &.{
697 ":3:26: error: expected enum or tagged union, found bool",
701 ":3:20: error: expected enum or tagged union, found bool",
698702 });
699703
700704 case.addError(
701705 \\pub export fn main() c_int {
702706 \\ const a = 1;
703 \\ const b = @intToEnum(bool, a);
707 \\ _ = @intToEnum(bool, a);
704708 \\}
705709 , &.{
706 ":3:26: error: expected enum, found bool",
710 ":3:20: error: expected enum, found bool",
707711 });
708712
709713 case.addError(
710714 \\const E = enum { a, b, c };
711715 \\pub export fn main() c_int {
712 \\ const b = @intToEnum(E, 3);
716 \\ _ = @intToEnum(E, 3);
713717 \\}
714718 , &.{
715 ":3:15: error: enum 'test_case.E' has no tag with value 3",
719 ":3:9: error: enum 'test_case.E' has no tag with value 3",
716720 ":1:11: note: enum declared here",
717721 });
718722
......@@ -780,10 +784,10 @@ pub fn addCases(ctx: *TestContext) !void {
780784 case.addError(
781785 \\const E = enum { a, b, c };
782786 \\pub export fn main() c_int {
783 \\ var x = E.d;
787 \\ _ = E.d;
784788 \\}
785789 , &.{
786 ":3:14: error: enum 'test_case.E' has no member named 'd'",
790 ":3:10: error: enum 'test_case.E' has no member named 'd'",
787791 ":1:11: note: enum declared here",
788792 });
789793
......@@ -791,6 +795,7 @@ pub fn addCases(ctx: *TestContext) !void {
791795 \\const E = enum { a, b, c };
792796 \\pub export fn main() c_int {
793797 \\ var x: E = .d;
798 \\ _ = x;
794799 \\}
795800 , &.{
796801 ":3:17: error: enum 'test_case.E' has no field named 'd'",
test/stage2/test.zig+15-9
......@@ -259,6 +259,7 @@ pub fn addCases(ctx: *TestContext) !void {
259259 case.addCompareOutput(
260260 \\pub fn main() void {
261261 \\ var x: usize = 0;
262 \\ _ = x;
262263 \\ const z = @TypeOf(x, @as(u128, 5));
263264 \\ assert(z == u128);
264265 \\}
......@@ -283,9 +284,9 @@ pub fn addCases(ctx: *TestContext) !void {
283284 );
284285 case.addError(
285286 \\pub fn main() void {
286 \\ const z = @TypeOf(true, 1);
287 \\ _ = @TypeOf(true, 1);
287288 \\}
288 , &[_][]const u8{":2:15: error: incompatible types: 'bool' and 'comptime_int'"});
289 , &[_][]const u8{":2:9: error: incompatible types: 'bool' and 'comptime_int'"});
289290 }
290291
291292 {
......@@ -746,6 +747,7 @@ pub fn addCases(ctx: *TestContext) !void {
746747 \\ \\ cool thx
747748 \\ \\
748749 \\ ;
750 \\ _ = ignore;
749751 \\ add('ぁ', '\x03');
750752 \\}
751753 \\
......@@ -987,6 +989,7 @@ pub fn addCases(ctx: *TestContext) !void {
987989 \\ return bar;
988990 \\ }
989991 \\ };
992 \\ _ = S;
990993 \\}
991994 , &.{
992995 ":5:20: error: 'bar' not accessible from inner function",
......@@ -1072,6 +1075,7 @@ pub fn addCases(ctx: *TestContext) !void {
10721075 \\ @compileLog(b, 20, f, x);
10731076 \\ @compileLog(1000);
10741077 \\ var bruh: usize = true;
1078 \\ _ = bruh;
10751079 \\ unreachable;
10761080 \\}
10771081 \\export fn other() void {
......@@ -1217,6 +1221,7 @@ pub fn addCases(ctx: *TestContext) !void {
12171221 case.addError(
12181222 \\pub fn main() void {
12191223 \\ var x = null;
1224 \\ _ = x;
12201225 \\}
12211226 , &[_][]const u8{
12221227 ":2:9: error: variable of type '@Type(.Null)' must be const or comptime",
......@@ -1456,14 +1461,14 @@ pub fn addCases(ctx: *TestContext) !void {
14561461 case.addCompareOutput(
14571462 \\pub fn main() void {
14581463 \\ const E = error{ A, B, D } || error { A, B, C };
1459 \\ const a = E.A;
1460 \\ const b = E.B;
1461 \\ const c = E.C;
1462 \\ const d = E.D;
1464 \\ E.A catch {};
1465 \\ E.B catch {};
1466 \\ E.C catch {};
1467 \\ E.D catch {};
14631468 \\ const E2 = error { X, Y } || @TypeOf(error.Z);
1464 \\ const x = E2.X;
1465 \\ const y = E2.Y;
1466 \\ const z = E2.Z;
1469 \\ E2.X catch {};
1470 \\ E2.Y catch {};
1471 \\ E2.Z catch {};
14671472 \\ assert(anyerror || error { Z } == anyerror);
14681473 \\}
14691474 \\fn assert(b: bool) void {
......@@ -1485,6 +1490,7 @@ pub fn addCases(ctx: *TestContext) !void {
14851490 \\ [arg1] "{rdi}" (code)
14861491 \\ : "rcx", "r11", "memory"
14871492 \\ );
1493 \\ _ = x;
14881494 \\}
14891495 , &[_][]const u8{":4:27: error: expected type, found comptime_int"});
14901496 }
test/stage2/wasm.zig+9
......@@ -76,6 +76,10 @@ pub fn addCases(ctx: *TestContext) !void {
7676 \\ var i: u32 = 5;
7777 \\ var y: f32 = 42.0;
7878 \\ var x: u32 = 10;
79 \\ if (false) {
80 \\ y;
81 \\ x;
82 \\ }
7983 \\ return i;
8084 \\}
8185 , "5\n");
......@@ -84,6 +88,7 @@ pub fn addCases(ctx: *TestContext) !void {
8488 \\pub export fn _start() u32 {
8589 \\ var i: u32 = 5;
8690 \\ var y: f32 = 42.0;
91 \\ _ = y;
8792 \\ var x: u32 = 10;
8893 \\ foo(i, x);
8994 \\ i = x;
......@@ -388,6 +393,10 @@ pub fn addCases(ctx: *TestContext) !void {
388393 \\pub export fn _start() i32 {
389394 \\ var number1 = Number.One;
390395 \\ var number2: Number = .Two;
396 \\ if (false) {
397 \\ number1;
398 \\ number2;
399 \\ }
391400 \\ const number3 = @intToEnum(Number, 2);
392401 \\
393402 \\ return @enumToInt(number3);