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 {...@@ -896,7 +896,6 @@ fn printLineFromFileAnyOs(out_stream: anytype, line_info: LineInfo) !void {
896 var buf: [mem.page_size]u8 = undefined;896 var buf: [mem.page_size]u8 = undefined;
897 var line: usize = 1;897 var line: usize = 1;
898 var column: usize = 1;898 var column: usize = 1;
899 var abs_index: usize = 0;
900 while (true) {899 while (true) {
901 const amt_read = try f.read(buf[0..]);900 const amt_read = try f.read(buf[0..]);
902 const slice = buf[0..amt_read];901 const slice = buf[0..amt_read];
lib/std/pdb.zig+4-2
...@@ -590,7 +590,8 @@ pub const Pdb = struct {...@@ -590,7 +590,8 @@ pub const Pdb = struct {
590590
591 var sect_cont_offset: usize = 0;591 var sect_cont_offset: usize = 0;
592 if (section_contrib_size != 0) {592 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) {
594 error.InvalidValue => return error.InvalidDebugInfo,595 error.InvalidValue => return error.InvalidDebugInfo,
595 else => |e| return e,596 else => |e| return e,
596 };597 };
...@@ -616,7 +617,8 @@ pub const Pdb = struct {...@@ -616,7 +617,8 @@ pub const Pdb = struct {
616617
617 // Parse the InfoStreamHeader.618 // Parse the InfoStreamHeader.
618 const version = try reader.readIntLittle(u32);619 const version = try reader.readIntLittle(u32);
619 const signature = try reader.readIntLittle(u32);620 // The signature
621 _ = try reader.readIntLittle(u32);
620 const age = try reader.readIntLittle(u32);622 const age = try reader.readIntLittle(u32);
621 const guid = try reader.readBytesNoEof(16);623 const guid = try reader.readBytesNoEof(16);
622624
lib/std/zig/parse.zig+2-2
...@@ -1005,7 +1005,7 @@ const Parser = struct {...@@ -1005,7 +1005,7 @@ const Parser = struct {
1005 },1005 },
1006 });1006 });
1007 };1007 };
1008 const else_payload = try p.parsePayload();1008 _ = try p.parsePayload();
1009 const else_expr = try p.expectStatement();1009 const else_expr = try p.expectStatement();
1010 return p.addNode(.{1010 return p.addNode(.{
1011 .tag = .@"if",1011 .tag = .@"if",
...@@ -1189,7 +1189,7 @@ const Parser = struct {...@@ -1189,7 +1189,7 @@ const Parser = struct {
1189 });1189 });
1190 }1190 }
1191 };1191 };
1192 const else_payload = try p.parsePayload();1192 _ = try p.parsePayload();
1193 const else_expr = try p.expectStatement();1193 const else_expr = try p.expectStatement();
1194 return p.addNode(.{1194 return p.addNode(.{
1195 .tag = .@"while",1195 .tag = .@"while",
test/stage2/cbe.zig+27-22
...@@ -93,16 +93,16 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -93,16 +93,16 @@ pub fn addCases(ctx: *TestContext) !void {
93 , "");93 , "");
94 case.addError(94 case.addError(
95 \\pub export fn main() c_int {95 \\pub export fn main() c_int {
96 \\ const c = @intToError(0);96 \\ _ = @intToError(0);
97 \\ return 0;97 \\ return 0;
98 \\}98 \\}
99 , &.{":2:27: error: integer value 0 represents no error"});99 , &.{":2:21: error: integer value 0 represents no error"});
100 case.addError(100 case.addError(
101 \\pub export fn main() c_int {101 \\pub export fn main() c_int {
102 \\ const c = @intToError(3);102 \\ _ = @intToError(3);
103 \\ return 0;103 \\ return 0;
104 \\}104 \\}
105 , &.{":2:27: error: integer value 3 represents no error"});105 , &.{":2:21: error: integer value 3 represents no error"});
106 }106 }
107107
108 {108 {
...@@ -383,6 +383,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -383,6 +383,7 @@ pub fn addCases(ctx: *TestContext) !void {
383 \\ true => 2,383 \\ true => 2,
384 \\ false => 3,384 \\ false => 3,
385 \\ };385 \\ };
386 \\ _ = b;
386 \\}387 \\}
387 , &.{388 , &.{
388 ":6:9: error: duplicate switch value",389 ":6:9: error: duplicate switch value",
...@@ -398,6 +399,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -398,6 +399,7 @@ pub fn addCases(ctx: *TestContext) !void {
398 \\ f64, i32 => 3,399 \\ f64, i32 => 3,
399 \\ else => 4,400 \\ else => 4,
400 \\ };401 \\ };
402 \\ _ = b;
401 \\}403 \\}
402 , &.{404 , &.{
403 ":6:14: error: duplicate switch value",405 ":6:14: error: duplicate switch value",
...@@ -414,6 +416,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -414,6 +416,7 @@ pub fn addCases(ctx: *TestContext) !void {
414 \\ f16...f64 => 3,416 \\ f16...f64 => 3,
415 \\ else => 4,417 \\ else => 4,
416 \\ };418 \\ };
419 \\ _ = b;
417 \\}420 \\}
418 , &.{421 , &.{
419 ":3:30: error: ranges not allowed when switching on type 'type'",422 ":3:30: error: ranges not allowed when switching on type 'type'",
...@@ -431,6 +434,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -431,6 +434,7 @@ pub fn addCases(ctx: *TestContext) !void {
431 \\ 3 => 40,434 \\ 3 => 40,
432 \\ else => 50,435 \\ else => 50,
433 \\ };436 \\ };
437 \\ _ = b;
434 \\}438 \\}
435 , &.{439 , &.{
436 ":8:14: error: unreachable else prong; all cases already handled",440 ":8:14: error: unreachable else prong; all cases already handled",
...@@ -556,10 +560,10 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -556,10 +560,10 @@ pub fn addCases(ctx: *TestContext) !void {
556 \\const E1 = packed enum { a, b, c };560 \\const E1 = packed enum { a, b, c };
557 \\const E2 = extern enum { a, b, c };561 \\const E2 = extern enum { a, b, c };
558 \\export fn foo() void {562 \\export fn foo() void {
559 \\ const x = E1.a;563 \\ _ = E1.a;
560 \\}564 \\}
561 \\export fn bar() void {565 \\export fn bar() void {
562 \\ const x = E2.a;566 \\ _ = E2.a;
563 \\}567 \\}
564 , &.{568 , &.{
565 ":1:12: error: enums do not support 'packed' or 'extern'; instead provide an explicit integer tag type",569 ":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 {...@@ -579,10 +583,10 @@ pub fn addCases(ctx: *TestContext) !void {
579 \\ c,583 \\ c,
580 \\};584 \\};
581 \\export fn foo() void {585 \\export fn foo() void {
582 \\ const x = E1.a;586 \\ _ = E1.a;
583 \\}587 \\}
584 \\export fn bar() void {588 \\export fn bar() void {
585 \\ const x = E2.a;589 \\ _ = E2.a;
586 \\}590 \\}
587 , &.{591 , &.{
588 ":3:5: error: enum fields cannot be marked comptime",592 ":3:5: error: enum fields cannot be marked comptime",
...@@ -621,7 +625,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -621,7 +625,7 @@ pub fn addCases(ctx: *TestContext) !void {
621 \\ c,625 \\ c,
622 \\};626 \\};
623 \\export fn foo() void {627 \\export fn foo() void {
624 \\ const x = E1.a;628 \\ _ = E1.a;
625 \\}629 \\}
626 , &.{630 , &.{
627 ":3:7: error: expected ',', found 'align'",631 ":3:7: error: expected ',', found 'align'",
...@@ -638,7 +642,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -638,7 +642,7 @@ pub fn addCases(ctx: *TestContext) !void {
638 \\ _,642 \\ _,
639 \\};643 \\};
640 \\export fn foo() void {644 \\export fn foo() void {
641 \\ const x = E1.a;645 \\ _ = E1.a;
642 \\}646 \\}
643 , &.{647 , &.{
644 ":6:5: error: redundant non-exhaustive enum mark",648 ":6:5: error: redundant non-exhaustive enum mark",
...@@ -653,7 +657,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -653,7 +657,7 @@ pub fn addCases(ctx: *TestContext) !void {
653 \\ _ = 10,657 \\ _ = 10,
654 \\};658 \\};
655 \\export fn foo() void {659 \\export fn foo() void {
656 \\ const x = E1.a;660 \\ _ = E1.a;
657 \\}661 \\}
658 , &.{662 , &.{
659 ":5:9: error: '_' is used to mark an enum as non-exhaustive and cannot be assigned a value",663 ":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 {...@@ -662,7 +666,7 @@ pub fn addCases(ctx: *TestContext) !void {
662 case.addError(666 case.addError(
663 \\const E1 = enum {};667 \\const E1 = enum {};
664 \\export fn foo() void {668 \\export fn foo() void {
665 \\ const x = E1.a;669 \\ _ = E1.a;
666 \\}670 \\}
667 , &.{671 , &.{
668 ":1:12: error: enum declarations must have at least one tag",672 ":1:12: error: enum declarations must have at least one tag",
...@@ -671,7 +675,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -671,7 +675,7 @@ pub fn addCases(ctx: *TestContext) !void {
671 case.addError(675 case.addError(
672 \\const E1 = enum { a, b, _ };676 \\const E1 = enum { a, b, _ };
673 \\export fn foo() void {677 \\export fn foo() void {
674 \\ const x = E1.a;678 \\ _ = E1.a;
675 \\}679 \\}
676 , &.{680 , &.{
677 ":1:12: error: non-exhaustive enum missing integer tag type",681 ":1:12: error: non-exhaustive enum missing integer tag type",
...@@ -681,7 +685,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -681,7 +685,7 @@ pub fn addCases(ctx: *TestContext) !void {
681 case.addError(685 case.addError(
682 \\const E1 = enum { a, b, c, b, d };686 \\const E1 = enum { a, b, c, b, d };
683 \\pub export fn main() c_int {687 \\pub export fn main() c_int {
684 \\ const x = E1.a;688 \\ _ = E1.a;
685 \\}689 \\}
686 , &.{690 , &.{
687 ":1:28: error: duplicate enum tag",691 ":1:28: error: duplicate enum tag",
...@@ -691,28 +695,28 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -691,28 +695,28 @@ pub fn addCases(ctx: *TestContext) !void {
691 case.addError(695 case.addError(
692 \\pub export fn main() c_int {696 \\pub export fn main() c_int {
693 \\ const a = true;697 \\ const a = true;
694 \\ const b = @enumToInt(a);698 \\ _ = @enumToInt(a);
695 \\}699 \\}
696 , &.{700 , &.{
697 ":3:26: error: expected enum or tagged union, found bool",701 ":3:20: error: expected enum or tagged union, found bool",
698 });702 });
699703
700 case.addError(704 case.addError(
701 \\pub export fn main() c_int {705 \\pub export fn main() c_int {
702 \\ const a = 1;706 \\ const a = 1;
703 \\ const b = @intToEnum(bool, a);707 \\ _ = @intToEnum(bool, a);
704 \\}708 \\}
705 , &.{709 , &.{
706 ":3:26: error: expected enum, found bool",710 ":3:20: error: expected enum, found bool",
707 });711 });
708712
709 case.addError(713 case.addError(
710 \\const E = enum { a, b, c };714 \\const E = enum { a, b, c };
711 \\pub export fn main() c_int {715 \\pub export fn main() c_int {
712 \\ const b = @intToEnum(E, 3);716 \\ _ = @intToEnum(E, 3);
713 \\}717 \\}
714 , &.{718 , &.{
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",
716 ":1:11: note: enum declared here",720 ":1:11: note: enum declared here",
717 });721 });
718722
...@@ -780,10 +784,10 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -780,10 +784,10 @@ pub fn addCases(ctx: *TestContext) !void {
780 case.addError(784 case.addError(
781 \\const E = enum { a, b, c };785 \\const E = enum { a, b, c };
782 \\pub export fn main() c_int {786 \\pub export fn main() c_int {
783 \\ var x = E.d;787 \\ _ = E.d;
784 \\}788 \\}
785 , &.{789 , &.{
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'",
787 ":1:11: note: enum declared here",791 ":1:11: note: enum declared here",
788 });792 });
789793
...@@ -791,6 +795,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -791,6 +795,7 @@ pub fn addCases(ctx: *TestContext) !void {
791 \\const E = enum { a, b, c };795 \\const E = enum { a, b, c };
792 \\pub export fn main() c_int {796 \\pub export fn main() c_int {
793 \\ var x: E = .d;797 \\ var x: E = .d;
798 \\ _ = x;
794 \\}799 \\}
795 , &.{800 , &.{
796 ":3:17: error: enum 'test_case.E' has no field named 'd'",801 ":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 {...@@ -259,6 +259,7 @@ pub fn addCases(ctx: *TestContext) !void {
259 case.addCompareOutput(259 case.addCompareOutput(
260 \\pub fn main() void {260 \\pub fn main() void {
261 \\ var x: usize = 0;261 \\ var x: usize = 0;
262 \\ _ = x;
262 \\ const z = @TypeOf(x, @as(u128, 5));263 \\ const z = @TypeOf(x, @as(u128, 5));
263 \\ assert(z == u128);264 \\ assert(z == u128);
264 \\}265 \\}
...@@ -283,9 +284,9 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -283,9 +284,9 @@ pub fn addCases(ctx: *TestContext) !void {
283 );284 );
284 case.addError(285 case.addError(
285 \\pub fn main() void {286 \\pub fn main() void {
286 \\ const z = @TypeOf(true, 1);287 \\ _ = @TypeOf(true, 1);
287 \\}288 \\}
288 , &[_][]const u8{":2:15: error: incompatible types: 'bool' and 'comptime_int'"});289 , &[_][]const u8{":2:9: error: incompatible types: 'bool' and 'comptime_int'"});
289 }290 }
290291
291 {292 {
...@@ -746,6 +747,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -746,6 +747,7 @@ pub fn addCases(ctx: *TestContext) !void {
746 \\ \\ cool thx747 \\ \\ cool thx
747 \\ \\748 \\ \\
748 \\ ;749 \\ ;
750 \\ _ = ignore;
749 \\ add('ぁ', '\x03');751 \\ add('ぁ', '\x03');
750 \\}752 \\}
751 \\753 \\
...@@ -987,6 +989,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -987,6 +989,7 @@ pub fn addCases(ctx: *TestContext) !void {
987 \\ return bar;989 \\ return bar;
988 \\ }990 \\ }
989 \\ };991 \\ };
992 \\ _ = S;
990 \\}993 \\}
991 , &.{994 , &.{
992 ":5:20: error: 'bar' not accessible from inner function",995 ":5:20: error: 'bar' not accessible from inner function",
...@@ -1072,6 +1075,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1072,6 +1075,7 @@ pub fn addCases(ctx: *TestContext) !void {
1072 \\ @compileLog(b, 20, f, x);1075 \\ @compileLog(b, 20, f, x);
1073 \\ @compileLog(1000);1076 \\ @compileLog(1000);
1074 \\ var bruh: usize = true;1077 \\ var bruh: usize = true;
1078 \\ _ = bruh;
1075 \\ unreachable;1079 \\ unreachable;
1076 \\}1080 \\}
1077 \\export fn other() void {1081 \\export fn other() void {
...@@ -1217,6 +1221,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1217,6 +1221,7 @@ pub fn addCases(ctx: *TestContext) !void {
1217 case.addError(1221 case.addError(
1218 \\pub fn main() void {1222 \\pub fn main() void {
1219 \\ var x = null;1223 \\ var x = null;
1224 \\ _ = x;
1220 \\}1225 \\}
1221 , &[_][]const u8{1226 , &[_][]const u8{
1222 ":2:9: error: variable of type '@Type(.Null)' must be const or comptime",1227 ":2:9: error: variable of type '@Type(.Null)' must be const or comptime",
...@@ -1456,14 +1461,14 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1456,14 +1461,14 @@ pub fn addCases(ctx: *TestContext) !void {
1456 case.addCompareOutput(1461 case.addCompareOutput(
1457 \\pub fn main() void {1462 \\pub fn main() void {
1458 \\ const E = error{ A, B, D } || error { A, B, C };1463 \\ const E = error{ A, B, D } || error { A, B, C };
1459 \\ const a = E.A;1464 \\ E.A catch {};
1460 \\ const b = E.B;1465 \\ E.B catch {};
1461 \\ const c = E.C;1466 \\ E.C catch {};
1462 \\ const d = E.D;1467 \\ E.D catch {};
1463 \\ const E2 = error { X, Y } || @TypeOf(error.Z);1468 \\ const E2 = error { X, Y } || @TypeOf(error.Z);
1464 \\ const x = E2.X;1469 \\ E2.X catch {};
1465 \\ const y = E2.Y;1470 \\ E2.Y catch {};
1466 \\ const z = E2.Z;1471 \\ E2.Z catch {};
1467 \\ assert(anyerror || error { Z } == anyerror);1472 \\ assert(anyerror || error { Z } == anyerror);
1468 \\}1473 \\}
1469 \\fn assert(b: bool) void {1474 \\fn assert(b: bool) void {
...@@ -1485,6 +1490,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1485,6 +1490,7 @@ pub fn addCases(ctx: *TestContext) !void {
1485 \\ [arg1] "{rdi}" (code)1490 \\ [arg1] "{rdi}" (code)
1486 \\ : "rcx", "r11", "memory"1491 \\ : "rcx", "r11", "memory"
1487 \\ );1492 \\ );
1493 \\ _ = x;
1488 \\}1494 \\}
1489 , &[_][]const u8{":4:27: error: expected type, found comptime_int"});1495 , &[_][]const u8{":4:27: error: expected type, found comptime_int"});
1490 }1496 }
test/stage2/wasm.zig+9
...@@ -76,6 +76,10 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -76,6 +76,10 @@ pub fn addCases(ctx: *TestContext) !void {
76 \\ var i: u32 = 5;76 \\ var i: u32 = 5;
77 \\ var y: f32 = 42.0;77 \\ var y: f32 = 42.0;
78 \\ var x: u32 = 10;78 \\ var x: u32 = 10;
79 \\ if (false) {
80 \\ y;
81 \\ x;
82 \\ }
79 \\ return i;83 \\ return i;
80 \\}84 \\}
81 , "5\n");85 , "5\n");
...@@ -84,6 +88,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -84,6 +88,7 @@ pub fn addCases(ctx: *TestContext) !void {
84 \\pub export fn _start() u32 {88 \\pub export fn _start() u32 {
85 \\ var i: u32 = 5;89 \\ var i: u32 = 5;
86 \\ var y: f32 = 42.0;90 \\ var y: f32 = 42.0;
91 \\ _ = y;
87 \\ var x: u32 = 10;92 \\ var x: u32 = 10;
88 \\ foo(i, x);93 \\ foo(i, x);
89 \\ i = x;94 \\ i = x;
...@@ -388,6 +393,10 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -388,6 +393,10 @@ pub fn addCases(ctx: *TestContext) !void {
388 \\pub export fn _start() i32 {393 \\pub export fn _start() i32 {
389 \\ var number1 = Number.One;394 \\ var number1 = Number.One;
390 \\ var number2: Number = .Two;395 \\ var number2: Number = .Two;
396 \\ if (false) {
397 \\ number1;
398 \\ number2;
399 \\ }
391 \\ const number3 = @intToEnum(Number, 2);400 \\ const number3 = @intToEnum(Number, 2);
392 \\401 \\
393 \\ return @enumToInt(number3);402 \\ return @enumToInt(number3);