authorgravatar for jacoblevgw@gmail.comJacob G-W <jacoblevgw@gmail.com> 2021-06-09 21:35:42-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-06-21 17:03:03-07:00
log641ecc260f43ffb2398acb80cbd141535dbbb03d
tree87455d3b460f517ad35bcda2b3a2e38599dd4aa1
parentd34a1ccb0ea75ba31f374b8b2d34e18326b147b1

std, src, doc, test: remove unused variables


112 files changed, 208 insertions(+), 294 deletions(-)

doc/docgen.zig-12
...@@ -1017,7 +1017,6 @@ fn tokenizeAndPrint(docgen_tokenizer: *Tokenizer, out: anytype, source_token: To...@@ -1017,7 +1017,6 @@ fn tokenizeAndPrint(docgen_tokenizer: *Tokenizer, out: anytype, source_token: To
1017}1017}
10181018
1019fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: anytype, zig_exe: []const u8, do_code_tests: bool) !void {1019fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: anytype, zig_exe: []const u8, do_code_tests: bool) !void {
1020 var code_progress_index: usize = 0;
1021 var progress = Progress{};1020 var progress = Progress{};
1022 const root_node = try progress.start("Generating docgen examples", toc.nodes.len);1021 const root_node = try progress.start("Generating docgen examples", toc.nodes.len);
1023 defer root_node.end();1022 defer root_node.end();
...@@ -1090,7 +1089,6 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any...@@ -1090,7 +1089,6 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
10901089
1091 switch (code.id) {1090 switch (code.id) {
1092 Code.Id.Exe => |expected_outcome| code_block: {1091 Code.Id.Exe => |expected_outcome| code_block: {
1093 const name_plus_bin_ext = try std.fmt.allocPrint(allocator, "{s}{s}", .{ code.name, exe_ext });
1094 var build_args = std.ArrayList([]const u8).init(allocator);1092 var build_args = std.ArrayList([]const u8).init(allocator);
1095 defer build_args.deinit();1093 defer build_args.deinit();
1096 try build_args.appendSlice(&[_][]const u8{1094 try build_args.appendSlice(&[_][]const u8{
...@@ -1361,19 +1359,9 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any...@@ -1361,19 +1359,9 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
1361 },1359 },
1362 Code.Id.Obj => |maybe_error_match| {1360 Code.Id.Obj => |maybe_error_match| {
1363 const name_plus_obj_ext = try std.fmt.allocPrint(allocator, "{s}{s}", .{ code.name, obj_ext });1361 const name_plus_obj_ext = try std.fmt.allocPrint(allocator, "{s}{s}", .{ code.name, obj_ext });
1364 const tmp_obj_file_name = try fs.path.join(
1365 allocator,
1366 &[_][]const u8{ tmp_dir_name, name_plus_obj_ext },
1367 );
1368 var build_args = std.ArrayList([]const u8).init(allocator);1362 var build_args = std.ArrayList([]const u8).init(allocator);
1369 defer build_args.deinit();1363 defer build_args.deinit();
13701364
1371 const name_plus_h_ext = try std.fmt.allocPrint(allocator, "{s}.h", .{code.name});
1372 const output_h_file_name = try fs.path.join(
1373 allocator,
1374 &[_][]const u8{ tmp_dir_name, name_plus_h_ext },
1375 );
1376
1377 try build_args.appendSlice(&[_][]const u8{1365 try build_args.appendSlice(&[_][]const u8{
1378 zig_exe,1366 zig_exe,
1379 "build-obj",1367 "build-obj",
lib/std/Thread.zig+2-2
...@@ -518,8 +518,8 @@ pub fn cpuCount() CpuCountError!usize {...@@ -518,8 +518,8 @@ pub fn cpuCount() CpuCountError!usize {
518 },518 },
519 .haiku => {519 .haiku => {
520 var count: u32 = undefined;520 var count: u32 = undefined;
521 var system_info: os.system_info = undefined;521 // var system_info: os.system_info = undefined;
522 const rc = os.system.get_system_info(&system_info);522 // const rc = os.system.get_system_info(&system_info);
523 count = system_info.cpu_count;523 count = system_info.cpu_count;
524 return @intCast(usize, count);524 return @intCast(usize, count);
525 },525 },
lib/std/base64.zig-5
...@@ -112,9 +112,6 @@ pub const Base64Encoder = struct {...@@ -112,9 +112,6 @@ pub const Base64Encoder = struct {
112 const out_len = encoder.calcSize(source.len);112 const out_len = encoder.calcSize(source.len);
113 assert(dest.len >= out_len);113 assert(dest.len >= out_len);
114114
115 const nibbles = source.len / 3;
116 const leftover = source.len - 3 * nibbles;
117
118 var acc: u12 = 0;115 var acc: u12 = 0;
119 var acc_len: u4 = 0;116 var acc_len: u4 = 0;
120 var out_idx: usize = 0;117 var out_idx: usize = 0;
...@@ -223,7 +220,6 @@ pub const Base64Decoder = struct {...@@ -223,7 +220,6 @@ pub const Base64Decoder = struct {
223 if (decoder.pad_char) |pad_char| {220 if (decoder.pad_char) |pad_char| {
224 const padding_len = acc_len / 2;221 const padding_len = acc_len / 2;
225 var padding_chars: usize = 0;222 var padding_chars: usize = 0;
226 var i: usize = 0;
227 for (leftover) |c| {223 for (leftover) |c| {
228 if (c != pad_char) {224 if (c != pad_char) {
229 return if (c == Base64Decoder.invalid_char) error.InvalidCharacter else error.InvalidPadding;225 return if (c == Base64Decoder.invalid_char) error.InvalidCharacter else error.InvalidPadding;
...@@ -302,7 +298,6 @@ pub const Base64DecoderWithIgnore = struct {...@@ -302,7 +298,6 @@ pub const Base64DecoderWithIgnore = struct {
302 var leftover = source[leftover_idx.?..];298 var leftover = source[leftover_idx.?..];
303 if (decoder.pad_char) |pad_char| {299 if (decoder.pad_char) |pad_char| {
304 var padding_chars: usize = 0;300 var padding_chars: usize = 0;
305 var i: usize = 0;
306 for (leftover) |c| {301 for (leftover) |c| {
307 if (decoder_with_ignore.char_is_ignored[c]) continue;302 if (decoder_with_ignore.char_is_ignored[c]) continue;
308 if (c != pad_char) {303 if (c != pad_char) {
lib/std/c/tokenizer.zig+6-7
...@@ -351,7 +351,6 @@ pub const Tokenizer = struct {...@@ -351,7 +351,6 @@ pub const Tokenizer = struct {
351 pp_directive: bool = false,351 pp_directive: bool = false,
352352
353 pub fn next(self: *Tokenizer) Token {353 pub fn next(self: *Tokenizer) Token {
354 const start_index = self.index;
355 var result = Token{354 var result = Token{
356 .id = .Eof,355 .id = .Eof,
357 .start = self.index,356 .start = self.index,
...@@ -1380,12 +1379,12 @@ test "operators" {...@@ -1380,12 +1379,12 @@ test "operators" {
13801379
1381test "keywords" {1380test "keywords" {
1382 try expectTokens(1381 try expectTokens(
1383 \\auto break case char const continue default do 1382 \\auto break case char const continue default do
1384 \\double else enum extern float for goto if int 1383 \\double else enum extern float for goto if int
1385 \\long register return short signed sizeof static 1384 \\long register return short signed sizeof static
1386 \\struct switch typedef union unsigned void volatile 1385 \\struct switch typedef union unsigned void volatile
1387 \\while _Bool _Complex _Imaginary inline restrict _Alignas 1386 \\while _Bool _Complex _Imaginary inline restrict _Alignas
1388 \\_Alignof _Atomic _Generic _Noreturn _Static_assert _Thread_local 1387 \\_Alignof _Atomic _Generic _Noreturn _Static_assert _Thread_local
1389 \\1388 \\
1390 , &[_]Token.Id{1389 , &[_]Token.Id{
1391 .Keyword_auto,1390 .Keyword_auto,
lib/std/compress/gzip.zig+2
...@@ -62,6 +62,8 @@ pub fn GzipStream(comptime ReaderType: type) type {...@@ -62,6 +62,8 @@ pub fn GzipStream(comptime ReaderType: type) type {
62 const XFL = header[8];62 const XFL = header[8];
63 // Operating system where the compression took place63 // Operating system where the compression took place
64 const OS = header[9];64 const OS = header[9];
65 _ = XFL;
66 _ = OS;
6567
66 if (FLG & FEXTRA != 0) {68 if (FLG & FEXTRA != 0) {
67 // Skip the extra data, we could read and expose it to the user69 // Skip the extra data, we could read and expose it to the user
lib/std/compress/zlib.zig+1
...@@ -35,6 +35,7 @@ pub fn ZlibStream(comptime ReaderType: type) type {...@@ -35,6 +35,7 @@ pub fn ZlibStream(comptime ReaderType: type) type {
35 const CM = @truncate(u4, header[0]);35 const CM = @truncate(u4, header[0]);
36 const CINFO = @truncate(u4, header[0] >> 4);36 const CINFO = @truncate(u4, header[0] >> 4);
37 const FCHECK = @truncate(u5, header[1]);37 const FCHECK = @truncate(u5, header[1]);
38 _ = FCHECK;
38 const FDICT = @truncate(u1, header[1] >> 5);39 const FDICT = @truncate(u1, header[1] >> 5);
3940
40 if ((@as(u16, header[0]) << 8 | header[1]) % 31 != 0)41 if ((@as(u16, header[0]) << 8 | header[1]) % 31 != 0)
lib/std/crypto/25519/scalar.zig-6
...@@ -330,13 +330,10 @@ pub const Scalar = struct {...@@ -330,13 +330,10 @@ pub const Scalar = struct {
330 const carry9 = z02 >> 56;330 const carry9 = z02 >> 56;
331 const c01 = carry9;331 const c01 = carry9;
332 const carry10 = (z12 + c01) >> 56;332 const carry10 = (z12 + c01) >> 56;
333 const t21 = @truncate(u64, z12 + c01) & 0xffffffffffffff;
334 const c11 = carry10;333 const c11 = carry10;
335 const carry11 = (z22 + c11) >> 56;334 const carry11 = (z22 + c11) >> 56;
336 const t22 = @truncate(u64, z22 + c11) & 0xffffffffffffff;
337 const c21 = carry11;335 const c21 = carry11;
338 const carry12 = (z32 + c21) >> 56;336 const carry12 = (z32 + c21) >> 56;
339 const t23 = @truncate(u64, z32 + c21) & 0xffffffffffffff;
340 const c31 = carry12;337 const c31 = carry12;
341 const carry13 = (z42 + c31) >> 56;338 const carry13 = (z42 + c31) >> 56;
342 const t24 = @truncate(u64, z42 + c31) & 0xffffffffffffff;339 const t24 = @truncate(u64, z42 + c31) & 0xffffffffffffff;
...@@ -605,13 +602,10 @@ const ScalarDouble = struct {...@@ -605,13 +602,10 @@ const ScalarDouble = struct {
605 const carry0 = z01 >> 56;602 const carry0 = z01 >> 56;
606 const c00 = carry0;603 const c00 = carry0;
607 const carry1 = (z11 + c00) >> 56;604 const carry1 = (z11 + c00) >> 56;
608 const t100 = @as(u64, @truncate(u64, z11 + c00)) & 0xffffffffffffff;
609 const c10 = carry1;605 const c10 = carry1;
610 const carry2 = (z21 + c10) >> 56;606 const carry2 = (z21 + c10) >> 56;
611 const t101 = @as(u64, @truncate(u64, z21 + c10)) & 0xffffffffffffff;
612 const c20 = carry2;607 const c20 = carry2;
613 const carry3 = (z31 + c20) >> 56;608 const carry3 = (z31 + c20) >> 56;
614 const t102 = @as(u64, @truncate(u64, z31 + c20)) & 0xffffffffffffff;
615 const c30 = carry3;609 const c30 = carry3;
616 const carry4 = (z41 + c30) >> 56;610 const carry4 = (z41 + c30) >> 56;
617 const t103 = @as(u64, @truncate(u64, z41 + c30)) & 0xffffffffffffff;611 const t103 = @as(u64, @truncate(u64, z41 + c30)) & 0xffffffffffffff;
lib/std/crypto/aes/soft.zig-8
...@@ -49,8 +49,6 @@ pub const Block = struct {...@@ -49,8 +49,6 @@ pub const Block = struct {
4949
50 /// Encrypt a block with a round key.50 /// Encrypt a block with a round key.
51 pub inline fn encrypt(block: Block, round_key: Block) Block {51 pub inline fn encrypt(block: Block, round_key: Block) Block {
52 const src = &block.repr;
53
54 const s0 = block.repr[0];52 const s0 = block.repr[0];
55 const s1 = block.repr[1];53 const s1 = block.repr[1];
56 const s2 = block.repr[2];54 const s2 = block.repr[2];
...@@ -66,8 +64,6 @@ pub const Block = struct {...@@ -66,8 +64,6 @@ pub const Block = struct {
6664
67 /// Encrypt a block with the last round key.65 /// Encrypt a block with the last round key.
68 pub inline fn encryptLast(block: Block, round_key: Block) Block {66 pub inline fn encryptLast(block: Block, round_key: Block) Block {
69 const src = &block.repr;
70
71 const t0 = block.repr[0];67 const t0 = block.repr[0];
72 const t1 = block.repr[1];68 const t1 = block.repr[1];
73 const t2 = block.repr[2];69 const t2 = block.repr[2];
...@@ -88,8 +84,6 @@ pub const Block = struct {...@@ -88,8 +84,6 @@ pub const Block = struct {
8884
89 /// Decrypt a block with a round key.85 /// Decrypt a block with a round key.
90 pub inline fn decrypt(block: Block, round_key: Block) Block {86 pub inline fn decrypt(block: Block, round_key: Block) Block {
91 const src = &block.repr;
92
93 const s0 = block.repr[0];87 const s0 = block.repr[0];
94 const s1 = block.repr[1];88 const s1 = block.repr[1];
95 const s2 = block.repr[2];89 const s2 = block.repr[2];
...@@ -105,8 +99,6 @@ pub const Block = struct {...@@ -105,8 +99,6 @@ pub const Block = struct {
10599
106 /// Decrypt a block with the last round key.100 /// Decrypt a block with the last round key.
107 pub inline fn decryptLast(block: Block, round_key: Block) Block {101 pub inline fn decryptLast(block: Block, round_key: Block) Block {
108 const src = &block.repr;
109
110 const t0 = block.repr[0];102 const t0 = block.repr[0];
111 const t1 = block.repr[1];103 const t1 = block.repr[1];
112 const t2 = block.repr[2];104 const t2 = block.repr[2];
lib/std/crypto/aes_gcm.zig-1
...@@ -114,7 +114,6 @@ test "Aes256Gcm - Empty message and no associated data" {...@@ -114,7 +114,6 @@ test "Aes256Gcm - Empty message and no associated data" {
114 const ad = "";114 const ad = "";
115 const m = "";115 const m = "";
116 var c: [m.len]u8 = undefined;116 var c: [m.len]u8 = undefined;
117 var m2: [m.len]u8 = undefined;
118 var tag: [Aes256Gcm.tag_length]u8 = undefined;117 var tag: [Aes256Gcm.tag_length]u8 = undefined;
119118
120 Aes256Gcm.encrypt(&c, &tag, m, ad, nonce, key);119 Aes256Gcm.encrypt(&c, &tag, m, ad, nonce, key);
lib/std/crypto/aes_ocb.zig-1
...@@ -271,7 +271,6 @@ test "AesOcb test vector 1" {...@@ -271,7 +271,6 @@ test "AesOcb test vector 1" {
271 var c: [0]u8 = undefined;271 var c: [0]u8 = undefined;
272 Aes128Ocb.encrypt(&c, &tag, "", "", nonce, k);272 Aes128Ocb.encrypt(&c, &tag, "", "", nonce, k);
273273
274 var expected_c: [c.len]u8 = undefined;
275 var expected_tag: [tag.len]u8 = undefined;274 var expected_tag: [tag.len]u8 = undefined;
276 _ = try hexToBytes(&expected_tag, "785407BFFFC8AD9EDCC5520AC9111EE6");275 _ = try hexToBytes(&expected_tag, "785407BFFFC8AD9EDCC5520AC9111EE6");
277276
lib/std/crypto/bcrypt.zig-2
...@@ -48,7 +48,6 @@ const State = struct {...@@ -48,7 +48,6 @@ const State = struct {
48 fn expand0(state: *State, key: []const u8) void {48 fn expand0(state: *State, key: []const u8) void {
49 var i: usize = 0;49 var i: usize = 0;
50 var j: usize = 0;50 var j: usize = 0;
51 var t: u32 = undefined;
52 while (i < state.subkeys.len) : (i += 1) {51 while (i < state.subkeys.len) : (i += 1) {
53 state.subkeys[i] ^= toWord(key, &j);52 state.subkeys[i] ^= toWord(key, &j);
54 }53 }
...@@ -75,7 +74,6 @@ const State = struct {...@@ -75,7 +74,6 @@ const State = struct {
75 fn expand(state: *State, data: []const u8, key: []const u8) void {74 fn expand(state: *State, data: []const u8, key: []const u8) void {
76 var i: usize = 0;75 var i: usize = 0;
77 var j: usize = 0;76 var j: usize = 0;
78 var t: u32 = undefined;
79 while (i < state.subkeys.len) : (i += 1) {77 while (i < state.subkeys.len) : (i += 1) {
80 state.subkeys[i] ^= toWord(key, &j);78 state.subkeys[i] ^= toWord(key, &j);
81 }79 }
lib/std/crypto/chacha20.zig-1
...@@ -444,7 +444,6 @@ fn ChaChaWith64BitNonce(comptime rounds_nb: usize) type {...@@ -444,7 +444,6 @@ fn ChaChaWith64BitNonce(comptime rounds_nb: usize) type {
444 if (comptime @sizeOf(usize) > 4) {444 if (comptime @sizeOf(usize) > 4) {
445 // A big block is giant: 256 GiB, but we can avoid this limitation445 // A big block is giant: 256 GiB, but we can avoid this limitation
446 var remaining_blocks: u32 = @intCast(u32, (in.len / big_block));446 var remaining_blocks: u32 = @intCast(u32, (in.len / big_block));
447 var i: u32 = 0;
448 while (remaining_blocks > 0) : (remaining_blocks -= 1) {447 while (remaining_blocks > 0) : (remaining_blocks -= 1) {
449 ChaChaImpl(rounds_nb).chacha20Xor(out[cursor .. cursor + big_block], in[cursor .. cursor + big_block], k, c);448 ChaChaImpl(rounds_nb).chacha20Xor(out[cursor .. cursor + big_block], in[cursor .. cursor + big_block], k, c);
450 c[1] += 1; // upper 32-bit of counter, generic chacha20Xor() doesn't know about this.449 c[1] += 1; // upper 32-bit of counter, generic chacha20Xor() doesn't know about this.
lib/std/dynamic_library.zig+1-1
...@@ -407,7 +407,7 @@ test "dynamic_library" {...@@ -407,7 +407,7 @@ test "dynamic_library" {
407 else => return error.SkipZigTest,407 else => return error.SkipZigTest,
408 };408 };
409409
410 const dynlib = DynLib.open(libname) catch |err| {410 _ = DynLib.open(libname) catch |err| {
411 try testing.expect(err == error.FileNotFound);411 try testing.expect(err == error.FileNotFound);
412 return;412 return;
413 };413 };
lib/std/event/channel.zig-1
...@@ -308,7 +308,6 @@ test "std.event.Channel wraparound" {...@@ -308,7 +308,6 @@ test "std.event.Channel wraparound" {
308308
309 // add items to channel and pull them out until309 // add items to channel and pull them out until
310 // the buffer wraps around, make sure it doesn't crash.310 // the buffer wraps around, make sure it doesn't crash.
311 var result: i32 = undefined;
312 channel.put(5);311 channel.put(5);
313 try testing.expectEqual(@as(i32, 5), channel.get());312 try testing.expectEqual(@as(i32, 5), channel.get());
314 channel.put(6);313 channel.put(6);
lib/std/event/group.zig+1-1
...@@ -130,7 +130,7 @@ test "std.event.Group" {...@@ -130,7 +130,7 @@ test "std.event.Group" {
130 // TODO this file has bit-rotted. repair it130 // TODO this file has bit-rotted. repair it
131 if (true) return error.SkipZigTest;131 if (true) return error.SkipZigTest;
132132
133 const handle = async testGroup(std.heap.page_allocator);133 _ = async testGroup(std.heap.page_allocator);
134}134}
135fn testGroup(allocator: *Allocator) callconv(.Async) void {135fn testGroup(allocator: *Allocator) callconv(.Async) void {
136 var count: usize = 0;136 var count: usize = 0;
lib/std/event/loop.zig+1-1
...@@ -680,7 +680,7 @@ pub const Loop = struct {...@@ -680,7 +680,7 @@ pub const Loop = struct {
680 fn run(func_args: Args, loop: *Loop, allocator: *mem.Allocator) void {680 fn run(func_args: Args, loop: *Loop, allocator: *mem.Allocator) void {
681 loop.beginOneEvent();681 loop.beginOneEvent();
682 loop.yield();682 loop.yield();
683 const result = @call(.{}, func, func_args);683 @call(.{}, func, func_args); // compile error when called with non-void ret type
684 suspend {684 suspend {
685 loop.finishOneEvent();685 loop.finishOneEvent();
686 allocator.destroy(@frame());686 allocator.destroy(@frame());
lib/std/event/rwlock.zig+1-1
...@@ -225,7 +225,7 @@ test "std.event.RwLock" {...@@ -225,7 +225,7 @@ test "std.event.RwLock" {
225 var lock = RwLock.init();225 var lock = RwLock.init();
226 defer lock.deinit();226 defer lock.deinit();
227227
228 const handle = testLock(std.heap.page_allocator, &lock);228 _ = testLock(std.heap.page_allocator, &lock);
229229
230 const expected_result = [1]i32{shared_it_count * @intCast(i32, shared_test_data.len)} ** shared_test_data.len;230 const expected_result = [1]i32{shared_it_count * @intCast(i32, shared_test_data.len)} ** shared_test_data.len;
231 try testing.expectEqualSlices(i32, expected_result, shared_test_data);231 try testing.expectEqualSlices(i32, expected_result, shared_test_data);
lib/std/fmt.zig+2-3
...@@ -1140,7 +1140,7 @@ pub fn formatFloatHexadecimal(...@@ -1140,7 +1140,7 @@ pub fn formatFloatHexadecimal(
11401140
1141 // +1 for the decimal part.1141 // +1 for the decimal part.
1142 var buf: [1 + mantissa_digits]u8 = undefined;1142 var buf: [1 + mantissa_digits]u8 = undefined;
1143 const N = formatIntBuf(&buf, mantissa, 16, .lower, .{ .fill = '0', .width = 1 + mantissa_digits });1143 _ = formatIntBuf(&buf, mantissa, 16, .lower, .{ .fill = '0', .width = 1 + mantissa_digits });
11441144
1145 try writer.writeAll("0x");1145 try writer.writeAll("0x");
1146 try writer.writeByte(buf[0]);1146 try writer.writeByte(buf[0]);
...@@ -2162,7 +2162,6 @@ test "custom" {...@@ -2162,7 +2162,6 @@ test "custom" {
2162 }2162 }
2163 };2163 };
21642164
2165 var buf1: [32]u8 = undefined;
2166 var value = Vec2{2165 var value = Vec2{
2167 .x = 10.2,2166 .x = 10.2,
2168 .y = 2.22,2167 .y = 2.22,
...@@ -2220,7 +2219,7 @@ test "union" {...@@ -2220,7 +2219,7 @@ test "union" {
2220 try std.testing.expect(mem.eql(u8, uu_result[0..3], "UU@"));2219 try std.testing.expect(mem.eql(u8, uu_result[0..3], "UU@"));
22212220
2222 const eu_result = try bufPrint(buf[0..], "{}", .{eu_inst});2221 const eu_result = try bufPrint(buf[0..], "{}", .{eu_inst});
2223 try std.testing.expect(mem.eql(u8, uu_result[0..3], "EU@"));2222 try std.testing.expect(mem.eql(u8, eu_result[0..3], "EU@"));
2224}2223}
22252224
2226test "enum" {2225test "enum" {
lib/std/fmt/parse_float.zig-1
...@@ -200,7 +200,6 @@ const ParseResult = enum {...@@ -200,7 +200,6 @@ const ParseResult = enum {
200200
201fn parseRepr(s: []const u8, n: *FloatRepr) !ParseResult {201fn parseRepr(s: []const u8, n: *FloatRepr) !ParseResult {
202 var digit_index: usize = 0;202 var digit_index: usize = 0;
203 var negative = false;
204 var negative_exp = false;203 var negative_exp = false;
205 var exponent: i32 = 0;204 var exponent: i32 = 0;
206205
lib/std/fs.zig+2-2
...@@ -477,7 +477,7 @@ pub const Dir = struct {...@@ -477,7 +477,7 @@ pub const Dir = struct {
477 }477 }
478478
479 var stat_info: os.libc_stat = undefined;479 var stat_info: os.libc_stat = undefined;
480 const rc2 = os.system._kern_read_stat(480 _ = os.system._kern_read_stat(
481 self.dir.fd,481 self.dir.fd,
482 &haiku_entry.d_name,482 &haiku_entry.d_name,
483 false,483 false,
...@@ -2438,7 +2438,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {...@@ -2438,7 +2438,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {
2438 }) catch continue;2438 }) catch continue;
24392439
2440 var real_path_buf: [MAX_PATH_BYTES]u8 = undefined;2440 var real_path_buf: [MAX_PATH_BYTES]u8 = undefined;
2441 if (os.realpathZ(&resolved_path_buf, &real_path_buf)) |real_path| {2441 if (os.realpathZ(resolved_path, &real_path_buf)) |real_path| {
2442 // found a file, and hope it is the right file2442 // found a file, and hope it is the right file
2443 if (real_path.len > out_buffer.len)2443 if (real_path.len > out_buffer.len)
2444 return error.NameTooLong;2444 return error.NameTooLong;
lib/std/hash/cityhash.zig-1
...@@ -353,7 +353,6 @@ fn SMHasherTest(comptime hash_fn: anytype) u32 {...@@ -353,7 +353,6 @@ fn SMHasherTest(comptime hash_fn: anytype) u32 {
353353
354 var key: [256]u8 = undefined;354 var key: [256]u8 = undefined;
355 var hashes_bytes: [256 * @sizeOf(HashResult)]u8 = undefined;355 var hashes_bytes: [256 * @sizeOf(HashResult)]u8 = undefined;
356 var final: HashResult = 0;
357356
358 std.mem.set(u8, &key, 0);357 std.mem.set(u8, &key, 0);
359 std.mem.set(u8, &hashes_bytes, 0);358 std.mem.set(u8, &hashes_bytes, 0);
lib/std/hash/wyhash.zig-2
...@@ -166,8 +166,6 @@ pub const Wyhash = struct {...@@ -166,8 +166,6 @@ pub const Wyhash = struct {
166 }166 }
167167
168 pub fn final(self: *Wyhash) u64 {168 pub fn final(self: *Wyhash) u64 {
169 const seed = self.state.seed;
170 const rem_len = @intCast(u5, self.buf_len);
171 const rem_key = self.buf[0..self.buf_len];169 const rem_key = self.buf[0..self.buf_len];
172170
173 return self.state.final(rem_key);171 return self.state.final(rem_key);
lib/std/hash_map.zig+1-1
...@@ -1809,7 +1809,7 @@ test "std.hash_map getOrPut" {...@@ -1809,7 +1809,7 @@ test "std.hash_map getOrPut" {
18091809
1810 i = 0;1810 i = 0;
1811 while (i < 20) : (i += 1) {1811 while (i < 20) : (i += 1) {
1812 var n = try map.getOrPutValue(i, 1);1812 _ = try map.getOrPutValue(i, 1);
1813 }1813 }
18141814
1815 i = 0;1815 i = 0;
lib/std/leb128.zig+2-3
...@@ -198,7 +198,7 @@ fn test_read_ileb128_seq(comptime T: type, comptime N: usize, encoded: []const u...@@ -198,7 +198,7 @@ fn test_read_ileb128_seq(comptime T: type, comptime N: usize, encoded: []const u
198 var reader = std.io.fixedBufferStream(encoded);198 var reader = std.io.fixedBufferStream(encoded);
199 var i: usize = 0;199 var i: usize = 0;
200 while (i < N) : (i += 1) {200 while (i < N) : (i += 1) {
201 const v1 = try readILEB128(T, reader.reader());201 _ = try readILEB128(T, reader.reader());
202 }202 }
203}203}
204204
...@@ -206,7 +206,7 @@ fn test_read_uleb128_seq(comptime T: type, comptime N: usize, encoded: []const u...@@ -206,7 +206,7 @@ fn test_read_uleb128_seq(comptime T: type, comptime N: usize, encoded: []const u
206 var reader = std.io.fixedBufferStream(encoded);206 var reader = std.io.fixedBufferStream(encoded);
207 var i: usize = 0;207 var i: usize = 0;
208 while (i < N) : (i += 1) {208 while (i < N) : (i += 1) {
209 const v1 = try readULEB128(T, reader.reader());209 _ = try readULEB128(T, reader.reader());
210 }210 }
211}211}
212212
...@@ -309,7 +309,6 @@ fn test_write_leb128(value: anytype) !void {...@@ -309,7 +309,6 @@ fn test_write_leb128(value: anytype) !void {
309 const B = std.meta.Int(signedness, larger_type_bits);309 const B = std.meta.Int(signedness, larger_type_bits);
310310
311 const bytes_needed = bn: {311 const bytes_needed = bn: {
312 const S = std.meta.Int(signedness, @sizeOf(T) * 8);
313 if (@typeInfo(T).Int.bits <= 7) break :bn @as(u16, 1);312 if (@typeInfo(T).Int.bits <= 7) break :bn @as(u16, 1);
314313
315 const unused_bits = if (value < 0) @clz(T, ~value) else @clz(T, value);314 const unused_bits = if (value < 0) @clz(T, ~value) else @clz(T, value);
lib/std/linked_list.zig+2-2
...@@ -359,8 +359,8 @@ test "basic TailQueue test" {...@@ -359,8 +359,8 @@ test "basic TailQueue test" {
359 }359 }
360 }360 }
361361
362 var first = list.popFirst(); // {2, 3, 4, 5}362 _ = list.popFirst(); // {2, 3, 4, 5}
363 var last = list.pop(); // {2, 3, 4}363 _ = list.pop(); // {2, 3, 4}
364 list.remove(&three); // {2, 4}364 list.remove(&three); // {2, 4}
365365
366 try testing.expect(list.first.?.data == 2);366 try testing.expect(list.first.?.data == 2);
lib/std/math/big/int.zig-2
...@@ -2000,8 +2000,6 @@ fn llmulacc_karatsuba(allocator: *Allocator, r: []Limb, x: []const Limb, y: []co...@@ -2000,8 +2000,6 @@ fn llmulacc_karatsuba(allocator: *Allocator, r: []Limb, x: []const Limb, y: []co
2000 } else {2000 } else {
2001 llsub(j1, y0[0..y0_len], y1[0..y1_len]);2001 llsub(j1, y0[0..y0_len], y1[0..y1_len]);
2002 }2002 }
2003 const j0_len = llnormalize(j0);
2004 const j1_len = llnormalize(j1);
2005 if (x_cmp == y_cmp) {2003 if (x_cmp == y_cmp) {
2006 mem.set(Limb, tmp[0..length], 0);2004 mem.set(Limb, tmp[0..length], 0);
2007 llmulacc(allocator, tmp, j0, j1);2005 llmulacc(allocator, tmp, j0, j1);
lib/std/math/big/rational.zig-1
...@@ -204,7 +204,6 @@ pub const Rational = struct {...@@ -204,7 +204,6 @@ pub const Rational = struct {
204 const esize = math.floatExponentBits(T);204 const esize = math.floatExponentBits(T);
205 const ebias = (1 << (esize - 1)) - 1;205 const ebias = (1 << (esize - 1)) - 1;
206 const emin = 1 - ebias;206 const emin = 1 - ebias;
207 const emax = ebias;
208207
209 if (self.p.eqZero()) {208 if (self.p.eqZero()) {
210 return 0;209 return 0;
lib/std/math/complex/ldexp.zig+1-1
...@@ -12,8 +12,8 @@...@@ -12,8 +12,8 @@
12const std = @import("../../std.zig");12const std = @import("../../std.zig");
13const debug = std.debug;13const debug = std.debug;
14const math = std.math;14const math = std.math;
15const cmath = math.complex;
16const testing = std.testing;15const testing = std.testing;
16const cmath = math.complex;
17const Complex = cmath.Complex;17const Complex = cmath.Complex;
1818
19/// Returns exp(z) scaled to avoid overflow.19/// Returns exp(z) scaled to avoid overflow.
lib/std/math/expm1.zig-4
...@@ -316,16 +316,12 @@ test "math.expm1_64" {...@@ -316,16 +316,12 @@ test "math.expm1_64" {
316}316}
317317
318test "math.expm1_32.special" {318test "math.expm1_32.special" {
319 const epsilon = 0.000001;
320
321 try expect(math.isPositiveInf(expm1_32(math.inf(f32))));319 try expect(math.isPositiveInf(expm1_32(math.inf(f32))));
322 try expect(expm1_32(-math.inf(f32)) == -1.0);320 try expect(expm1_32(-math.inf(f32)) == -1.0);
323 try expect(math.isNan(expm1_32(math.nan(f32))));321 try expect(math.isNan(expm1_32(math.nan(f32))));
324}322}
325323
326test "math.expm1_64.special" {324test "math.expm1_64.special" {
327 const epsilon = 0.000001;
328
329 try expect(math.isPositiveInf(expm1_64(math.inf(f64))));325 try expect(math.isPositiveInf(expm1_64(math.inf(f64))));
330 try expect(expm1_64(-math.inf(f64)) == -1.0);326 try expect(expm1_64(-math.inf(f64)) == -1.0);
331 try expect(math.isNan(expm1_64(math.nan(f64))));327 try expect(math.isNan(expm1_64(math.nan(f64))));
lib/std/math/modf.zig+2-5
...@@ -12,6 +12,7 @@...@@ -12,6 +12,7 @@
12const std = @import("../std.zig");12const std = @import("../std.zig");
13const math = std.math;13const math = std.math;
14const expect = std.testing.expect;14const expect = std.testing.expect;
15const expectEqual = std.testing.expectEqual;
15const maxInt = std.math.maxInt;16const maxInt = std.math.maxInt;
1617
17fn modf_result(comptime T: type) type {18fn modf_result(comptime T: type) type {
...@@ -131,11 +132,7 @@ test "math.modf" {...@@ -131,11 +132,7 @@ test "math.modf" {
131 const a = modf(@as(f32, 1.0));132 const a = modf(@as(f32, 1.0));
132 const b = modf32(1.0);133 const b = modf32(1.0);
133 // NOTE: No struct comparison on generic return type function? non-named, makes sense, but still.134 // NOTE: No struct comparison on generic return type function? non-named, makes sense, but still.
134 try expect(a.ipart == b.ipart and a.fpart == b.fpart);135 try expectEqual(a, b);
135
136 const c = modf(@as(f64, 1.0));
137 const d = modf64(1.0);
138 try expect(a.ipart == b.ipart and a.fpart == b.fpart);
139}136}
140137
141test "math.modf32" {138test "math.modf32" {
lib/std/meta.zig-7
...@@ -654,7 +654,6 @@ pub fn TagPayload(comptime U: type, tag: Tag(U)) type {...@@ -654,7 +654,6 @@ pub fn TagPayload(comptime U: type, tag: Tag(U)) type {
654 try testing.expect(trait.is(.Union)(U));654 try testing.expect(trait.is(.Union)(U));
655655
656 const info = @typeInfo(U).Union;656 const info = @typeInfo(U).Union;
657 const tag_info = @typeInfo(Tag(U)).Enum;
658657
659 inline for (info.fields) |field_info| {658 inline for (info.fields) |field_info| {
660 if (comptime mem.eql(u8, field_info.name, @tagName(tag)))659 if (comptime mem.eql(u8, field_info.name, @tagName(tag)))
...@@ -757,12 +756,6 @@ test "std.meta.eql" {...@@ -757,12 +756,6 @@ test "std.meta.eql" {
757 .c = "12345".*,756 .c = "12345".*,
758 };757 };
759758
760 const s_2 = S{
761 .a = 1,
762 .b = 123.3,
763 .c = "54321".*,
764 };
765
766 var s_3 = S{759 var s_3 = S{
767 .a = 134,760 .a = 134,
768 .b = 123.3,761 .b = 123.3,
lib/std/os.zig+3-3
...@@ -5341,7 +5341,7 @@ pub fn sendfile(...@@ -5341,7 +5341,7 @@ pub fn sendfile(
5341 ENXIO => return error.Unseekable,5341 ENXIO => return error.Unseekable,
5342 ESPIPE => return error.Unseekable,5342 ESPIPE => return error.Unseekable,
5343 else => |err| {5343 else => |err| {
5344 const discard = unexpectedErrno(err);5344 unexpectedErrno(err) catch {};
5345 break :sf;5345 break :sf;
5346 },5346 },
5347 }5347 }
...@@ -5422,7 +5422,7 @@ pub fn sendfile(...@@ -5422,7 +5422,7 @@ pub fn sendfile(
5422 EPIPE => return error.BrokenPipe,5422 EPIPE => return error.BrokenPipe,
54235423
5424 else => {5424 else => {
5425 const discard = unexpectedErrno(err);5425 unexpectedErrno(err) catch {};
5426 if (amt != 0) {5426 if (amt != 0) {
5427 return amt;5427 return amt;
5428 } else {5428 } else {
...@@ -5484,7 +5484,7 @@ pub fn sendfile(...@@ -5484,7 +5484,7 @@ pub fn sendfile(
5484 EPIPE => return error.BrokenPipe,5484 EPIPE => return error.BrokenPipe,
54855485
5486 else => {5486 else => {
5487 const discard = unexpectedErrno(err);5487 unexpectedErrno(err) catch {};
5488 if (amt != 0) {5488 if (amt != 0) {
5489 return amt;5489 return amt;
5490 } else {5490 } else {
lib/std/os/linux/io_uring.zig+3-3
...@@ -1272,12 +1272,12 @@ test "accept/connect/send/recv" {...@@ -1272,12 +1272,12 @@ test "accept/connect/send/recv" {
12721272
1273 var accept_addr: os.sockaddr = undefined;1273 var accept_addr: os.sockaddr = undefined;
1274 var accept_addr_len: os.socklen_t = @sizeOf(@TypeOf(accept_addr));1274 var accept_addr_len: os.socklen_t = @sizeOf(@TypeOf(accept_addr));
1275 const accept = try ring.accept(0xaaaaaaaa, server, &accept_addr, &accept_addr_len, 0);1275 _ = try ring.accept(0xaaaaaaaa, server, &accept_addr, &accept_addr_len, 0);
1276 try testing.expectEqual(@as(u32, 1), try ring.submit());1276 try testing.expectEqual(@as(u32, 1), try ring.submit());
12771277
1278 const client = try os.socket(address.any.family, os.SOCK_STREAM | os.SOCK_CLOEXEC, 0);1278 const client = try os.socket(address.any.family, os.SOCK_STREAM | os.SOCK_CLOEXEC, 0);
1279 defer os.close(client);1279 defer os.close(client);
1280 const connect = try ring.connect(0xcccccccc, client, &address.any, address.getOsSockLen());1280 _ = try ring.connect(0xcccccccc, client, &address.any, address.getOsSockLen());
1281 try testing.expectEqual(@as(u32, 1), try ring.submit());1281 try testing.expectEqual(@as(u32, 1), try ring.submit());
12821282
1283 var cqe_accept = try ring.copy_cqe();1283 var cqe_accept = try ring.copy_cqe();
...@@ -1305,7 +1305,7 @@ test "accept/connect/send/recv" {...@@ -1305,7 +1305,7 @@ test "accept/connect/send/recv" {
13051305
1306 const send = try ring.send(0xeeeeeeee, client, buffer_send[0..], 0);1306 const send = try ring.send(0xeeeeeeee, client, buffer_send[0..], 0);
1307 send.flags |= linux.IOSQE_IO_LINK;1307 send.flags |= linux.IOSQE_IO_LINK;
1308 const recv = try ring.recv(0xffffffff, cqe_accept.res, buffer_recv[0..], 0);1308 _ = try ring.recv(0xffffffff, cqe_accept.res, buffer_recv[0..], 0);
1309 try testing.expectEqual(@as(u32, 2), try ring.submit());1309 try testing.expectEqual(@as(u32, 2), try ring.submit());
13101310
1311 const cqe_send = try ring.copy_cqe();1311 const cqe_send = try ring.copy_cqe();
lib/std/os/linux/vdso.zig-1
...@@ -15,7 +15,6 @@ pub fn lookup(vername: []const u8, name: []const u8) usize {...@@ -15,7 +15,6 @@ pub fn lookup(vername: []const u8, name: []const u8) usize {
1515
16 const eh = @intToPtr(*elf.Ehdr, vdso_addr);16 const eh = @intToPtr(*elf.Ehdr, vdso_addr);
17 var ph_addr: usize = vdso_addr + eh.e_phoff;17 var ph_addr: usize = vdso_addr + eh.e_phoff;
18 const ph = @intToPtr(*elf.Phdr, ph_addr);
1918
20 var maybe_dynv: ?[*]usize = null;19 var maybe_dynv: ?[*]usize = null;
21 var base: usize = maxInt(usize);20 var base: usize = maxInt(usize);
lib/std/os/windows.zig-1
...@@ -1156,7 +1156,6 @@ pub fn GetFinalPathNameByHandle(...@@ -1156,7 +1156,6 @@ pub fn GetFinalPathNameByHandle(
1156 &mount_points_struct.MountPoints[0],1156 &mount_points_struct.MountPoints[0],
1157 )[0..mount_points_struct.NumberOfMountPoints];1157 )[0..mount_points_struct.NumberOfMountPoints];
11581158
1159 var found: bool = false;
1160 for (mount_points) |mount_point| {1159 for (mount_points) |mount_point| {
1161 const symlink = @ptrCast(1160 const symlink = @ptrCast(
1162 [*]const u16,1161 [*]const u16,
lib/std/pdb.zig+4-4
...@@ -590,11 +590,11 @@ pub const Pdb = struct {...@@ -590,11 +590,11 @@ 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 // the version593 const version = reader.readEnum(SectionContrSubstreamVersion, .Little) catch |err| switch (err) {
594 _ = reader.readEnum(SectionContrSubstreamVersion, .Little) catch |err| switch (err) {
595 error.InvalidValue => return error.InvalidDebugInfo,594 error.InvalidValue => return error.InvalidDebugInfo,
596 else => |e| return e,595 else => |e| return e,
597 };596 };
597 _ = version;
598 sect_cont_offset += @sizeOf(u32);598 sect_cont_offset += @sizeOf(u32);
599 }599 }
600 while (sect_cont_offset != section_contrib_size) {600 while (sect_cont_offset != section_contrib_size) {
...@@ -617,8 +617,8 @@ pub const Pdb = struct {...@@ -617,8 +617,8 @@ pub const Pdb = struct {
617617
618 // Parse the InfoStreamHeader.618 // Parse the InfoStreamHeader.
619 const version = try reader.readIntLittle(u32);619 const version = try reader.readIntLittle(u32);
620 // The signature620 const signature = try reader.readIntLittle(u32);
621 _ = try reader.readIntLittle(u32);621 _ = signature;
622 const age = try reader.readIntLittle(u32);622 const age = try reader.readIntLittle(u32);
623 const guid = try reader.readBytesNoEof(16);623 const guid = try reader.readBytesNoEof(16);
624624
lib/std/rand/ziggurat.zig+1-1
...@@ -175,5 +175,5 @@ test "exp dist sanity" {...@@ -175,5 +175,5 @@ test "exp dist sanity" {
175test "table gen" {175test "table gen" {
176 if (please_windows_dont_oom) return error.SkipZigTest;176 if (please_windows_dont_oom) return error.SkipZigTest;
177177
178 const table = NormDist;178 _ = NormDist;
179}179}
lib/std/special/compiler_rt/addXf3.zig-5
...@@ -83,7 +83,6 @@ fn addXf3(comptime T: type, a: T, b: T) T {...@@ -83,7 +83,6 @@ fn addXf3(comptime T: type, a: T, b: T) T {
8383
84 const signBit = (@as(Z, 1) << (significandBits + exponentBits));84 const signBit = (@as(Z, 1) << (significandBits + exponentBits));
85 const maxExponent = ((1 << exponentBits) - 1);85 const maxExponent = ((1 << exponentBits) - 1);
86 const exponentBias = (maxExponent >> 1);
8786
88 const implicitBit = (@as(Z, 1) << significandBits);87 const implicitBit = (@as(Z, 1) << significandBits);
89 const quietBit = implicitBit >> 1;88 const quietBit = implicitBit >> 1;
...@@ -98,10 +97,6 @@ fn addXf3(comptime T: type, a: T, b: T) T {...@@ -98,10 +97,6 @@ fn addXf3(comptime T: type, a: T, b: T) T {
98 const aAbs = aRep & absMask;97 const aAbs = aRep & absMask;
99 const bAbs = bRep & absMask;98 const bAbs = bRep & absMask;
10099
101 const negative = (aRep & signBit) != 0;
102 const exponent = @intCast(i32, aAbs >> significandBits) - exponentBias;
103 const significand = (aAbs & significandMask) | implicitBit;
104
105 const infRep = @bitCast(Z, std.math.inf(T));100 const infRep = @bitCast(Z, std.math.inf(T));
106101
107 // Detect if a or b is zero, infinity, or NaN.102 // Detect if a or b is zero, infinity, or NaN.
lib/std/special/compiler_rt/divtf3.zig-1
...@@ -12,7 +12,6 @@ const wideMultiply = @import("divdf3.zig").wideMultiply;...@@ -12,7 +12,6 @@ const wideMultiply = @import("divdf3.zig").wideMultiply;
12pub fn __divtf3(a: f128, b: f128) callconv(.C) f128 {12pub fn __divtf3(a: f128, b: f128) callconv(.C) f128 {
13 @setRuntimeSafety(builtin.is_test);13 @setRuntimeSafety(builtin.is_test);
14 const Z = std.meta.Int(.unsigned, 128);14 const Z = std.meta.Int(.unsigned, 128);
15 const SignedZ = std.meta.Int(.signed, 128);
1615
17 const significandBits = std.math.floatMantissaBits(f128);16 const significandBits = std.math.floatMantissaBits(f128);
18 const exponentBits = std.math.floatExponentBits(f128);17 const exponentBits = std.math.floatExponentBits(f128);
lib/std/special/compiler_rt/extendXfYf2.zig-1
...@@ -46,7 +46,6 @@ fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: std.meta.Int(.unsi...@@ -46,7 +46,6 @@ fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: std.meta.Int(.unsi
46 const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).Float.bits);46 const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).Float.bits);
47 const srcSigBits = std.math.floatMantissaBits(src_t);47 const srcSigBits = std.math.floatMantissaBits(src_t);
48 const dstSigBits = std.math.floatMantissaBits(dst_t);48 const dstSigBits = std.math.floatMantissaBits(dst_t);
49 const SrcShift = std.math.Log2Int(src_rep_t);
50 const DstShift = std.math.Log2Int(dst_rep_t);49 const DstShift = std.math.Log2Int(dst_rep_t);
5150
52 // Various constants whose values follow from the type parameters.51 // Various constants whose values follow from the type parameters.
lib/std/special/compiler_rt/fixuint.zig-1
...@@ -16,7 +16,6 @@ pub fn fixuint(comptime fp_t: type, comptime fixuint_t: type, a: fp_t) fixuint_t...@@ -16,7 +16,6 @@ pub fn fixuint(comptime fp_t: type, comptime fixuint_t: type, a: fp_t) fixuint_t
16 else => unreachable,16 else => unreachable,
17 };17 };
18 const typeWidth = @typeInfo(rep_t).Int.bits;18 const typeWidth = @typeInfo(rep_t).Int.bits;
19 const srep_t = @import("std").meta.Int(.signed, typeWidth);
20 const significandBits = switch (fp_t) {19 const significandBits = switch (fp_t) {
21 f32 => 23,20 f32 => 23,
22 f64 => 52,21 f64 => 52,
lib/std/special/compiler_rt/truncXfYf2.zig-1
...@@ -50,7 +50,6 @@ fn truncXfYf2(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t {...@@ -50,7 +50,6 @@ fn truncXfYf2(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t {
50 const srcSigBits = std.math.floatMantissaBits(src_t);50 const srcSigBits = std.math.floatMantissaBits(src_t);
51 const dstSigBits = std.math.floatMantissaBits(dst_t);51 const dstSigBits = std.math.floatMantissaBits(dst_t);
52 const SrcShift = std.math.Log2Int(src_rep_t);52 const SrcShift = std.math.Log2Int(src_rep_t);
53 const DstShift = std.math.Log2Int(dst_rep_t);
5453
55 // Various constants whose values follow from the type parameters.54 // Various constants whose values follow from the type parameters.
56 // Any reasonable optimizer will fold and propagate all of these.55 // Any reasonable optimizer will fold and propagate all of these.
lib/std/testing.zig-1
...@@ -191,7 +191,6 @@ test "expectEqual.union(enum)" {...@@ -191,7 +191,6 @@ test "expectEqual.union(enum)" {
191 };191 };
192192
193 const a10 = T{ .a = 10 };193 const a10 = T{ .a = 10 };
194 const a20 = T{ .a = 20 };
195194
196 try expectEqual(a10, a10);195 try expectEqual(a10, a10);
197}196}
lib/std/unicode/throughput_test.zig-2
...@@ -47,8 +47,6 @@ fn benchmarkCodepointCount(buf: []const u8) !ResultCount {...@@ -47,8 +47,6 @@ fn benchmarkCodepointCount(buf: []const u8) !ResultCount {
47pub fn main() !void {47pub fn main() !void {
48 const stdout = std.io.getStdOut().writer();48 const stdout = std.io.getStdOut().writer();
4949
50 const args = try std.process.argsAlloc(std.heap.page_allocator);
51
52 try stdout.print("short ASCII strings\n", .{});50 try stdout.print("short ASCII strings\n", .{});
53 {51 {
54 const result = try benchmarkCodepointCount("abc");52 const result = try benchmarkCodepointCount("abc");
lib/std/x/os/io.zig-1
...@@ -122,7 +122,6 @@ test "reactor/linux: drive async tcp client/listener pair" {...@@ -122,7 +122,6 @@ test "reactor/linux: drive async tcp client/listener pair" {
122122
123 const IPv4 = std.x.os.IPv4;123 const IPv4 = std.x.os.IPv4;
124 const IPv6 = std.x.os.IPv6;124 const IPv6 = std.x.os.IPv6;
125 const Socket = std.x.os.Socket;
126125
127 const reactor = try Reactor.init(.{ .close_on_exec = true });126 const reactor = try Reactor.init(.{ .close_on_exec = true });
128 defer reactor.deinit();127 defer reactor.deinit();
lib/std/zig/ast.zig-1
...@@ -1866,7 +1866,6 @@ pub const Tree = struct {...@@ -1866,7 +1866,6 @@ pub const Tree = struct {
1866 }1866 }
18671867
1868 fn fullStructInit(tree: Tree, info: full.StructInit.Ast) full.StructInit {1868 fn fullStructInit(tree: Tree, info: full.StructInit.Ast) full.StructInit {
1869 const token_tags = tree.tokens.items(.tag);
1870 var result: full.StructInit = .{1869 var result: full.StructInit = .{
1871 .ast = info,1870 .ast = info,
1872 };1871 };
lib/std/zig/parse.zig+23-23
...@@ -586,7 +586,7 @@ const Parser = struct {...@@ -586,7 +586,7 @@ const Parser = struct {
586 const thread_local_token = p.eatToken(.keyword_threadlocal);586 const thread_local_token = p.eatToken(.keyword_threadlocal);
587 const var_decl = try p.parseVarDecl();587 const var_decl = try p.parseVarDecl();
588 if (var_decl != 0) {588 if (var_decl != 0) {
589 const semicolon_token = try p.expectToken(.semicolon);589 _ = try p.expectToken(.semicolon);
590 return var_decl;590 return var_decl;
591 }591 }
592 if (thread_local_token != null) {592 if (thread_local_token != null) {
...@@ -614,7 +614,7 @@ const Parser = struct {...@@ -614,7 +614,7 @@ const Parser = struct {
614 fn expectUsingNamespace(p: *Parser) !Node.Index {614 fn expectUsingNamespace(p: *Parser) !Node.Index {
615 const usingnamespace_token = p.assertToken(.keyword_usingnamespace);615 const usingnamespace_token = p.assertToken(.keyword_usingnamespace);
616 const expr = try p.expectExpr();616 const expr = try p.expectExpr();
617 const semicolon_token = try p.expectToken(.semicolon);617 _ = try p.expectToken(.semicolon);
618 return p.addNode(.{618 return p.addNode(.{
619 .tag = .@"usingnamespace",619 .tag = .@"usingnamespace",
620 .main_token = usingnamespace_token,620 .main_token = usingnamespace_token,
...@@ -647,7 +647,7 @@ const Parser = struct {...@@ -647,7 +647,7 @@ const Parser = struct {
647 const align_expr = try p.parseByteAlign();647 const align_expr = try p.parseByteAlign();
648 const section_expr = try p.parseLinkSection();648 const section_expr = try p.parseLinkSection();
649 const callconv_expr = try p.parseCallconv();649 const callconv_expr = try p.parseCallconv();
650 const bang_token = p.eatToken(.bang);650 _ = p.eatToken(.bang);
651651
652 const return_type_expr = try p.parseTypeExpr();652 const return_type_expr = try p.parseTypeExpr();
653 if (return_type_expr == 0) {653 if (return_type_expr == 0) {
...@@ -775,7 +775,7 @@ const Parser = struct {...@@ -775,7 +775,7 @@ const Parser = struct {
775775
776 /// ContainerField <- KEYWORD_comptime? IDENTIFIER (COLON (KEYWORD_anytype / TypeExpr) ByteAlign?)? (EQUAL Expr)?776 /// ContainerField <- KEYWORD_comptime? IDENTIFIER (COLON (KEYWORD_anytype / TypeExpr) ByteAlign?)? (EQUAL Expr)?
777 fn expectContainerField(p: *Parser) !Node.Index {777 fn expectContainerField(p: *Parser) !Node.Index {
778 const comptime_token = p.eatToken(.keyword_comptime);778 _ = p.eatToken(.keyword_comptime);
779 const name_token = p.assertToken(.identifier);779 const name_token = p.assertToken(.identifier);
780780
781 var align_expr: Node.Index = 0;781 var align_expr: Node.Index = 0;
...@@ -967,7 +967,7 @@ const Parser = struct {...@@ -967,7 +967,7 @@ const Parser = struct {
967 _ = try p.expectToken(.l_paren);967 _ = try p.expectToken(.l_paren);
968 const condition = try p.expectExpr();968 const condition = try p.expectExpr();
969 _ = try p.expectToken(.r_paren);969 _ = try p.expectToken(.r_paren);
970 const then_payload = try p.parsePtrPayload();970 _ = try p.parsePtrPayload();
971971
972 // TODO propose to change the syntax so that semicolons are always required972 // TODO propose to change the syntax so that semicolons are always required
973 // inside if statements, even if there is an `else`.973 // inside if statements, even if there is an `else`.
...@@ -992,7 +992,7 @@ const Parser = struct {...@@ -992,7 +992,7 @@ const Parser = struct {
992 else_required = true;992 else_required = true;
993 break :blk assign_expr;993 break :blk assign_expr;
994 };994 };
995 const else_token = p.eatToken(.keyword_else) orelse {995 _ = p.eatToken(.keyword_else) orelse {
996 if (else_required) {996 if (else_required) {
997 try p.warn(.expected_semi_or_else);997 try p.warn(.expected_semi_or_else);
998 }998 }
...@@ -1087,7 +1087,7 @@ const Parser = struct {...@@ -1087,7 +1087,7 @@ const Parser = struct {
1087 else_required = true;1087 else_required = true;
1088 break :blk assign_expr;1088 break :blk assign_expr;
1089 };1089 };
1090 const else_token = p.eatToken(.keyword_else) orelse {1090 _ = p.eatToken(.keyword_else) orelse {
1091 if (else_required) {1091 if (else_required) {
1092 try p.warn(.expected_semi_or_else);1092 try p.warn(.expected_semi_or_else);
1093 }1093 }
...@@ -1122,7 +1122,7 @@ const Parser = struct {...@@ -1122,7 +1122,7 @@ const Parser = struct {
1122 _ = try p.expectToken(.l_paren);1122 _ = try p.expectToken(.l_paren);
1123 const condition = try p.expectExpr();1123 const condition = try p.expectExpr();
1124 _ = try p.expectToken(.r_paren);1124 _ = try p.expectToken(.r_paren);
1125 const then_payload = try p.parsePtrPayload();1125 _ = try p.parsePtrPayload();
1126 const cont_expr = try p.parseWhileContinueExpr();1126 const cont_expr = try p.parseWhileContinueExpr();
11271127
1128 // TODO propose to change the syntax so that semicolons are always required1128 // TODO propose to change the syntax so that semicolons are always required
...@@ -1162,7 +1162,7 @@ const Parser = struct {...@@ -1162,7 +1162,7 @@ const Parser = struct {
1162 else_required = true;1162 else_required = true;
1163 break :blk assign_expr;1163 break :blk assign_expr;
1164 };1164 };
1165 const else_token = p.eatToken(.keyword_else) orelse {1165 _ = p.eatToken(.keyword_else) orelse {
1166 if (else_required) {1166 if (else_required) {
1167 try p.warn(.expected_semi_or_else);1167 try p.warn(.expected_semi_or_else);
1168 }1168 }
...@@ -1550,7 +1550,7 @@ const Parser = struct {...@@ -1550,7 +1550,7 @@ const Parser = struct {
1550 },1550 },
1551 .l_bracket => switch (p.token_tags[p.tok_i + 1]) {1551 .l_bracket => switch (p.token_tags[p.tok_i + 1]) {
1552 .asterisk => {1552 .asterisk => {
1553 const lbracket = p.nextToken();1553 _ = p.nextToken();
1554 const asterisk = p.nextToken();1554 const asterisk = p.nextToken();
1555 var sentinel: Node.Index = 0;1555 var sentinel: Node.Index = 0;
1556 prefix: {1556 prefix: {
...@@ -1907,7 +1907,7 @@ const Parser = struct {...@@ -1907,7 +1907,7 @@ const Parser = struct {
1907 if (found_payload == 0) try p.warn(.expected_loop_payload);1907 if (found_payload == 0) try p.warn(.expected_loop_payload);
19081908
1909 const then_expr = try p.expectExpr();1909 const then_expr = try p.expectExpr();
1910 const else_token = p.eatToken(.keyword_else) orelse {1910 _ = p.eatToken(.keyword_else) orelse {
1911 return p.addNode(.{1911 return p.addNode(.{
1912 .tag = .for_simple,1912 .tag = .for_simple,
1913 .main_token = for_token,1913 .main_token = for_token,
...@@ -1938,11 +1938,11 @@ const Parser = struct {...@@ -1938,11 +1938,11 @@ const Parser = struct {
1938 _ = try p.expectToken(.l_paren);1938 _ = try p.expectToken(.l_paren);
1939 const condition = try p.expectExpr();1939 const condition = try p.expectExpr();
1940 _ = try p.expectToken(.r_paren);1940 _ = try p.expectToken(.r_paren);
1941 const then_payload = try p.parsePtrPayload();1941 _ = try p.parsePtrPayload();
1942 const cont_expr = try p.parseWhileContinueExpr();1942 const cont_expr = try p.parseWhileContinueExpr();
19431943
1944 const then_expr = try p.expectExpr();1944 const then_expr = try p.expectExpr();
1945 const else_token = p.eatToken(.keyword_else) orelse {1945 _ = p.eatToken(.keyword_else) orelse {
1946 if (cont_expr == 0) {1946 if (cont_expr == 0) {
1947 return p.addNode(.{1947 return p.addNode(.{
1948 .tag = .while_simple,1948 .tag = .while_simple,
...@@ -1966,7 +1966,7 @@ const Parser = struct {...@@ -1966,7 +1966,7 @@ const Parser = struct {
1966 });1966 });
1967 }1967 }
1968 };1968 };
1969 const else_payload = try p.parsePayload();1969 _ = try p.parsePayload();
1970 const else_expr = try p.expectExpr();1970 const else_expr = try p.expectExpr();
1971 return p.addNode(.{1971 return p.addNode(.{
1972 .tag = .@"while",1972 .tag = .@"while",
...@@ -2565,8 +2565,8 @@ const Parser = struct {...@@ -2565,8 +2565,8 @@ const Parser = struct {
2565 p.tok_i += 2;2565 p.tok_i += 2;
2566 while (true) {2566 while (true) {
2567 if (p.eatToken(.r_brace)) |_| break;2567 if (p.eatToken(.r_brace)) |_| break;
2568 const doc_comment = try p.eatDocComments();2568 _ = try p.eatDocComments();
2569 const identifier = try p.expectToken(.identifier);2569 _ = try p.expectToken(.identifier);
2570 switch (p.token_tags[p.tok_i]) {2570 switch (p.token_tags[p.tok_i]) {
2571 .comma => p.tok_i += 1,2571 .comma => p.tok_i += 1,
2572 .r_brace => {2572 .r_brace => {
...@@ -2634,7 +2634,7 @@ const Parser = struct {...@@ -2634,7 +2634,7 @@ const Parser = struct {
2634 if (found_payload == 0) try p.warn(.expected_loop_payload);2634 if (found_payload == 0) try p.warn(.expected_loop_payload);
26352635
2636 const then_expr = try p.expectTypeExpr();2636 const then_expr = try p.expectTypeExpr();
2637 const else_token = p.eatToken(.keyword_else) orelse {2637 _ = p.eatToken(.keyword_else) orelse {
2638 return p.addNode(.{2638 return p.addNode(.{
2639 .tag = .for_simple,2639 .tag = .for_simple,
2640 .main_token = for_token,2640 .main_token = for_token,
...@@ -2665,11 +2665,11 @@ const Parser = struct {...@@ -2665,11 +2665,11 @@ const Parser = struct {
2665 _ = try p.expectToken(.l_paren);2665 _ = try p.expectToken(.l_paren);
2666 const condition = try p.expectExpr();2666 const condition = try p.expectExpr();
2667 _ = try p.expectToken(.r_paren);2667 _ = try p.expectToken(.r_paren);
2668 const then_payload = try p.parsePtrPayload();2668 _ = try p.parsePtrPayload();
2669 const cont_expr = try p.parseWhileContinueExpr();2669 const cont_expr = try p.parseWhileContinueExpr();
26702670
2671 const then_expr = try p.expectTypeExpr();2671 const then_expr = try p.expectTypeExpr();
2672 const else_token = p.eatToken(.keyword_else) orelse {2672 _ = p.eatToken(.keyword_else) orelse {
2673 if (cont_expr == 0) {2673 if (cont_expr == 0) {
2674 return p.addNode(.{2674 return p.addNode(.{
2675 .tag = .while_simple,2675 .tag = .while_simple,
...@@ -2693,7 +2693,7 @@ const Parser = struct {...@@ -2693,7 +2693,7 @@ const Parser = struct {
2693 });2693 });
2694 }2694 }
2695 };2695 };
2696 const else_payload = try p.parsePayload();2696 _ = try p.parsePayload();
2697 const else_expr = try p.expectTypeExpr();2697 const else_expr = try p.expectTypeExpr();
2698 return p.addNode(.{2698 return p.addNode(.{
2699 .tag = .@"while",2699 .tag = .@"while",
...@@ -3570,12 +3570,12 @@ const Parser = struct {...@@ -3570,12 +3570,12 @@ const Parser = struct {
3570 _ = try p.expectToken(.l_paren);3570 _ = try p.expectToken(.l_paren);
3571 const condition = try p.expectExpr();3571 const condition = try p.expectExpr();
3572 _ = try p.expectToken(.r_paren);3572 _ = try p.expectToken(.r_paren);
3573 const then_payload = try p.parsePtrPayload();3573 _ = try p.parsePtrPayload();
35743574
3575 const then_expr = try bodyParseFn(p);3575 const then_expr = try bodyParseFn(p);
3576 if (then_expr == 0) return p.fail(.invalid_token);3576 if (then_expr == 0) return p.fail(.invalid_token);
35773577
3578 const else_token = p.eatToken(.keyword_else) orelse return p.addNode(.{3578 _ = p.eatToken(.keyword_else) orelse return p.addNode(.{
3579 .tag = .if_simple,3579 .tag = .if_simple,
3580 .main_token = if_token,3580 .main_token = if_token,
3581 .data = .{3581 .data = .{
...@@ -3583,7 +3583,7 @@ const Parser = struct {...@@ -3583,7 +3583,7 @@ const Parser = struct {
3583 .rhs = then_expr,3583 .rhs = then_expr,
3584 },3584 },
3585 });3585 });
3586 const else_payload = try p.parsePayload();3586 _ = try p.parsePayload();
3587 const else_expr = try bodyParseFn(p);3587 const else_expr = try bodyParseFn(p);
3588 if (else_expr == 0) return p.fail(.invalid_token);3588 if (else_expr == 0) return p.fail(.invalid_token);
35893589
lib/std/zig/parser_test.zig-1
...@@ -5201,7 +5201,6 @@ fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *b...@@ -5201,7 +5201,6 @@ fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *b
5201 defer tree.deinit(allocator);5201 defer tree.deinit(allocator);
52025202
5203 for (tree.errors) |parse_error| {5203 for (tree.errors) |parse_error| {
5204 const token_start = tree.tokens.items(.start)[parse_error.token];
5205 const loc = tree.tokenLocation(0, parse_error.token);5204 const loc = tree.tokenLocation(0, parse_error.token);
5206 try stderr.print("(memory buffer):{d}:{d}: error: ", .{ loc.line + 1, loc.column + 1 });5205 try stderr.print("(memory buffer):{d}:{d}: error: ", .{ loc.line + 1, loc.column + 1 });
5207 try tree.renderError(parse_error, stderr);5206 try tree.renderError(parse_error, stderr);
lib/std/zig/render.zig-6
...@@ -1086,8 +1086,6 @@ fn renderWhile(gpa: *Allocator, ais: *Ais, tree: ast.Tree, while_node: ast.full....@@ -1086,8 +1086,6 @@ fn renderWhile(gpa: *Allocator, ais: *Ais, tree: ast.Tree, while_node: ast.full.
1086 }1086 }
10871087
1088 if (while_node.ast.else_expr != 0) {1088 if (while_node.ast.else_expr != 0) {
1089 const first_else_expr_tok = tree.firstToken(while_node.ast.else_expr);
1090
1091 if (indent_then_expr) {1089 if (indent_then_expr) {
1092 ais.pushIndent();1090 ais.pushIndent();
1093 try renderExpression(gpa, ais, tree, while_node.ast.then_expr, .newline);1091 try renderExpression(gpa, ais, tree, while_node.ast.then_expr, .newline);
...@@ -1133,7 +1131,6 @@ fn renderContainerField(...@@ -1133,7 +1131,6 @@ fn renderContainerField(
1133 field: ast.full.ContainerField,1131 field: ast.full.ContainerField,
1134 space: Space,1132 space: Space,
1135) Error!void {1133) Error!void {
1136 const main_tokens = tree.nodes.items(.main_token);
1137 if (field.comptime_token) |t| {1134 if (field.comptime_token) |t| {
1138 try renderToken(ais, tree, t, .space); // comptime1135 try renderToken(ais, tree, t, .space); // comptime
1139 }1136 }
...@@ -1519,7 +1516,6 @@ fn renderBlock(...@@ -1519,7 +1516,6 @@ fn renderBlock(
1519) Error!void {1516) Error!void {
1520 const token_tags = tree.tokens.items(.tag);1517 const token_tags = tree.tokens.items(.tag);
1521 const node_tags = tree.nodes.items(.tag);1518 const node_tags = tree.nodes.items(.tag);
1522 const nodes_data = tree.nodes.items(.data);
1523 const lbrace = tree.nodes.items(.main_token)[block_node];1519 const lbrace = tree.nodes.items(.main_token)[block_node];
15241520
1525 if (token_tags[lbrace - 1] == .colon and1521 if (token_tags[lbrace - 1] == .colon and
...@@ -1617,7 +1613,6 @@ fn renderArrayInit(...@@ -1617,7 +1613,6 @@ fn renderArrayInit(
1617 space: Space,1613 space: Space,
1618) Error!void {1614) Error!void {
1619 const token_tags = tree.tokens.items(.tag);1615 const token_tags = tree.tokens.items(.tag);
1620 const token_starts = tree.tokens.items(.start);
16211616
1622 if (array_init.ast.type_expr == 0) {1617 if (array_init.ast.type_expr == 0) {
1623 try renderToken(ais, tree, array_init.ast.lbrace - 1, .none); // .1618 try renderToken(ais, tree, array_init.ast.lbrace - 1, .none); // .
...@@ -2046,7 +2041,6 @@ fn renderCall(...@@ -2046,7 +2041,6 @@ fn renderCall(
2046 space: Space,2041 space: Space,
2047) Error!void {2042) Error!void {
2048 const token_tags = tree.tokens.items(.tag);2043 const token_tags = tree.tokens.items(.tag);
2049 const main_tokens = tree.nodes.items(.main_token);
20502044
2051 if (call.async_token) |async_token| {2045 if (call.async_token) |async_token| {
2052 try renderToken(ais, tree, async_token, .space);2046 try renderToken(ais, tree, async_token, .space);
lib/std/zig/system.zig+1-8
...@@ -478,13 +478,6 @@ pub const NativeTargetInfo = struct {...@@ -478,13 +478,6 @@ pub const NativeTargetInfo = struct {
478 }478 }
479 const ld_info_list = ld_info_list_buffer[0..ld_info_list_len];479 const ld_info_list = ld_info_list_buffer[0..ld_info_list_len];
480480
481 if (cross_target.dynamic_linker.get()) |explicit_ld| {
482 const explicit_ld_basename = fs.path.basename(explicit_ld);
483 for (ld_info_list) |ld_info| {
484 const standard_ld_basename = fs.path.basename(ld_info.ld.get().?);
485 }
486 }
487
488 // Best case scenario: the executable is dynamically linked, and we can iterate481 // Best case scenario: the executable is dynamically linked, and we can iterate
489 // over our own shared objects and find a dynamic linker.482 // over our own shared objects and find a dynamic linker.
490 self_exe: {483 self_exe: {
...@@ -838,7 +831,7 @@ pub const NativeTargetInfo = struct {...@@ -838,7 +831,7 @@ pub const NativeTargetInfo = struct {
838831
839 if (dynstr) |ds| {832 if (dynstr) |ds| {
840 const strtab_len = std.math.min(ds.size, strtab_buf.len);833 const strtab_len = std.math.min(ds.size, strtab_buf.len);
841 const strtab_read_len = try preadMin(file, &strtab_buf, ds.offset, shstrtab_len);834 const strtab_read_len = try preadMin(file, &strtab_buf, ds.offset, strtab_len);
842 const strtab = strtab_buf[0..strtab_read_len];835 const strtab = strtab_buf[0..strtab_read_len];
843 // TODO this pointer cast should not be necessary836 // TODO this pointer cast should not be necessary
844 const rpoff_usize = std.math.cast(usize, rpoff) catch |err| switch (err) {837 const rpoff_usize = std.math.cast(usize, rpoff) catch |err| switch (err) {
lib/std/zig/tokenizer.zig-1
...@@ -416,7 +416,6 @@ pub const Tokenizer = struct {...@@ -416,7 +416,6 @@ pub const Tokenizer = struct {
416 self.pending_invalid_token = null;416 self.pending_invalid_token = null;
417 return token;417 return token;
418 }418 }
419 const start_index = self.index;
420 var state: State = .start;419 var state: State = .start;
421 var result = Token{420 var result = Token{
422 .tag = .eof,421 .tag = .eof,
src/AstGen.zig+9-38
...@@ -206,7 +206,6 @@ pub const ResultLoc = union(enum) {...@@ -206,7 +206,6 @@ pub const ResultLoc = union(enum) {
206 };206 };
207207
208 fn strategy(rl: ResultLoc, block_scope: *GenZir) Strategy {208 fn strategy(rl: ResultLoc, block_scope: *GenZir) Strategy {
209 var elide_store_to_block_ptr_instructions = false;
210 switch (rl) {209 switch (rl) {
211 // In this branch there will not be any store_to_block_ptr instructions.210 // In this branch there will not be any store_to_block_ptr instructions.
212 .discard, .none, .none_or_ref, .ty, .ref => return .{211 .discard, .none, .none_or_ref, .ty, .ref => return .{
...@@ -905,7 +904,6 @@ fn nosuspendExpr(...@@ -905,7 +904,6 @@ fn nosuspendExpr(
905 node: ast.Node.Index,904 node: ast.Node.Index,
906) InnerError!Zir.Inst.Ref {905) InnerError!Zir.Inst.Ref {
907 const astgen = gz.astgen;906 const astgen = gz.astgen;
908 const gpa = astgen.gpa;
909 const tree = astgen.tree;907 const tree = astgen.tree;
910 const node_datas = tree.nodes.items(.data);908 const node_datas = tree.nodes.items(.data);
911 const body_node = node_datas[node].lhs;909 const body_node = node_datas[node].lhs;
...@@ -1113,7 +1111,6 @@ fn arrayInitExpr(...@@ -1113,7 +1111,6 @@ fn arrayInitExpr(
1113) InnerError!Zir.Inst.Ref {1111) InnerError!Zir.Inst.Ref {
1114 const astgen = gz.astgen;1112 const astgen = gz.astgen;
1115 const tree = astgen.tree;1113 const tree = astgen.tree;
1116 const gpa = astgen.gpa;
1117 const node_tags = tree.nodes.items(.tag);1114 const node_tags = tree.nodes.items(.tag);
1118 const main_tokens = tree.nodes.items(.main_token);1115 const main_tokens = tree.nodes.items(.main_token);
11191116
...@@ -1293,7 +1290,6 @@ fn structInitExpr(...@@ -1293,7 +1290,6 @@ fn structInitExpr(
1293) InnerError!Zir.Inst.Ref {1290) InnerError!Zir.Inst.Ref {
1294 const astgen = gz.astgen;1291 const astgen = gz.astgen;
1295 const tree = astgen.tree;1292 const tree = astgen.tree;
1296 const gpa = astgen.gpa;
12971293
1298 if (struct_init.ast.fields.len == 0) {1294 if (struct_init.ast.fields.len == 0) {
1299 if (struct_init.ast.type_expr == 0) {1295 if (struct_init.ast.type_expr == 0) {
...@@ -1675,9 +1671,6 @@ fn checkLabelRedefinition(astgen: *AstGen, parent_scope: *Scope, label: ast.Toke...@@ -1675,9 +1671,6 @@ fn checkLabelRedefinition(astgen: *AstGen, parent_scope: *Scope, label: ast.Toke
1675 const gen_zir = scope.cast(GenZir).?;1671 const gen_zir = scope.cast(GenZir).?;
1676 if (gen_zir.label) |prev_label| {1672 if (gen_zir.label) |prev_label| {
1677 if (try astgen.tokenIdentEql(label, prev_label.token)) {1673 if (try astgen.tokenIdentEql(label, prev_label.token)) {
1678 const tree = astgen.tree;
1679 const main_tokens = tree.nodes.items(.main_token);
1680
1681 const label_name = try astgen.identifierTokenString(label);1674 const label_name = try astgen.identifierTokenString(label);
1682 return astgen.failTokNotes(label, "redefinition of label '{s}'", .{1675 return astgen.failTokNotes(label, "redefinition of label '{s}'", .{
1683 label_name,1676 label_name,
...@@ -1790,7 +1783,6 @@ fn blockExprStmts(...@@ -1790,7 +1783,6 @@ fn blockExprStmts(
1790) !void {1783) !void {
1791 const astgen = gz.astgen;1784 const astgen = gz.astgen;
1792 const tree = astgen.tree;1785 const tree = astgen.tree;
1793 const main_tokens = tree.nodes.items(.main_token);
1794 const node_tags = tree.nodes.items(.tag);1786 const node_tags = tree.nodes.items(.tag);
17951787
1796 var block_arena = std.heap.ArenaAllocator.init(gz.astgen.gpa);1788 var block_arena = std.heap.ArenaAllocator.init(gz.astgen.gpa);
...@@ -2147,7 +2139,10 @@ fn genDefers(...@@ -2147,7 +2139,10 @@ fn genDefers(
2147 .defer_error => {2139 .defer_error => {
2148 const defer_scope = scope.cast(Scope.Defer).?;2140 const defer_scope = scope.cast(Scope.Defer).?;
2149 scope = defer_scope.parent;2141 scope = defer_scope.parent;
2150 if (err_code == .none) continue;2142 // TODO add this back when we have more errdefer support
2143 // right now it is making stuff not get evaluated which causes
2144 // unused vars.
2145 // if (err_code == .none) continue;
2151 const expr_node = node_datas[defer_scope.defer_node].rhs;2146 const expr_node = node_datas[defer_scope.defer_node].rhs;
2152 const prev_in_defer = gz.in_defer;2147 const prev_in_defer = gz.in_defer;
2153 gz.in_defer = true;2148 gz.in_defer = true;
...@@ -2166,8 +2161,6 @@ fn checkUsed(...@@ -2166,8 +2161,6 @@ fn checkUsed(
2166 inner_scope: *Scope,2161 inner_scope: *Scope,
2167) InnerError!void {2162) InnerError!void {
2168 const astgen = gz.astgen;2163 const astgen = gz.astgen;
2169 const tree = astgen.tree;
2170 const node_datas = tree.nodes.items(.data);
21712164
2172 var scope = inner_scope;2165 var scope = inner_scope;
2173 while (scope != outer_scope) {2166 while (scope != outer_scope) {
...@@ -2450,7 +2443,7 @@ fn varDecl(...@@ -2450,7 +2443,7 @@ fn varDecl(
2450 resolve_inferred_alloc = alloc;2443 resolve_inferred_alloc = alloc;
2451 break :a .{ .alloc = alloc, .result_loc = .{ .inferred_ptr = alloc } };2444 break :a .{ .alloc = alloc, .result_loc = .{ .inferred_ptr = alloc } };
2452 };2445 };
2453 const init_inst = try expr(gz, scope, var_data.result_loc, var_decl.ast.init_node);2446 _ = try expr(gz, scope, var_data.result_loc, var_decl.ast.init_node);
2454 if (resolve_inferred_alloc != .none) {2447 if (resolve_inferred_alloc != .none) {
2455 _ = try gz.addUnNode(.resolve_inferred_alloc, resolve_inferred_alloc, node);2448 _ = try gz.addUnNode(.resolve_inferred_alloc, resolve_inferred_alloc, node);
2456 }2449 }
...@@ -2477,7 +2470,6 @@ fn emitDbgNode(gz: *GenZir, node: ast.Node.Index) !void {...@@ -2477,7 +2470,6 @@ fn emitDbgNode(gz: *GenZir, node: ast.Node.Index) !void {
24772470
2478 const astgen = gz.astgen;2471 const astgen = gz.astgen;
2479 const tree = astgen.tree;2472 const tree = astgen.tree;
2480 const node_tags = tree.nodes.items(.tag);
2481 const token_starts = tree.tokens.items(.start);2473 const token_starts = tree.tokens.items(.start);
2482 const decl_start = token_starts[tree.firstToken(gz.decl_node_index)];2474 const decl_start = token_starts[tree.firstToken(gz.decl_node_index)];
2483 const node_start = token_starts[tree.firstToken(node)];2475 const node_start = token_starts[tree.firstToken(node)];
...@@ -2602,9 +2594,6 @@ fn ptrType(...@@ -2602,9 +2594,6 @@ fn ptrType(
2602 node: ast.Node.Index,2594 node: ast.Node.Index,
2603 ptr_info: ast.full.PtrType,2595 ptr_info: ast.full.PtrType,
2604) InnerError!Zir.Inst.Ref {2596) InnerError!Zir.Inst.Ref {
2605 const astgen = gz.astgen;
2606 const tree = astgen.tree;
2607
2608 const elem_type = try typeExpr(gz, scope, ptr_info.ast.child_type);2597 const elem_type = try typeExpr(gz, scope, ptr_info.ast.child_type);
26092598
2610 const simple = ptr_info.ast.align_node == 0 and2599 const simple = ptr_info.ast.align_node == 0 and
...@@ -4305,10 +4294,8 @@ fn containerDecl(...@@ -4305,10 +4294,8 @@ fn containerDecl(
4305 defer wip_decls.deinit(gpa);4294 defer wip_decls.deinit(gpa);
43064295
4307 for (container_decl.ast.members) |member_node| {4296 for (container_decl.ast.members) |member_node| {
4308 const member = switch (node_tags[member_node]) {4297 switch (node_tags[member_node]) {
4309 .container_field_init => tree.containerFieldInit(member_node),4298 .container_field_init, .container_field_align, .container_field => {},
4310 .container_field_align => tree.containerFieldAlign(member_node),
4311 .container_field => tree.containerField(member_node),
43124299
4313 .fn_decl => {4300 .fn_decl => {
4314 const fn_proto = node_datas[member_node].lhs;4301 const fn_proto = node_datas[member_node].lhs;
...@@ -4429,7 +4416,7 @@ fn containerDecl(...@@ -4429,7 +4416,7 @@ fn containerDecl(
4429 continue;4416 continue;
4430 },4417 },
4431 else => unreachable,4418 else => unreachable,
4432 };4419 }
4433 }4420 }
4434 {4421 {
4435 const empty_slot_count = WipDecls.fields_per_u32 - (wip_decls.decl_index % WipDecls.fields_per_u32);4422 const empty_slot_count = WipDecls.fields_per_u32 - (wip_decls.decl_index % WipDecls.fields_per_u32);
...@@ -4497,11 +4484,6 @@ fn errorSetDecl(...@@ -4497,11 +4484,6 @@ fn errorSetDecl(
4497 }4484 }
4498 }4485 }
44994486
4500 const tag: Zir.Inst.Tag = switch (gz.anon_name_strategy) {
4501 .parent => .error_set_decl,
4502 .anon => .error_set_decl_anon,
4503 .func => .error_set_decl_func,
4504 };
4505 const result = try gz.addPlNode(.error_set_decl, node, Zir.Inst.ErrorSetDecl{4487 const result = try gz.addPlNode(.error_set_decl, node, Zir.Inst.ErrorSetDecl{
4506 .fields_len = @intCast(u32, field_names.items.len),4488 .fields_len = @intCast(u32, field_names.items.len),
4507 });4489 });
...@@ -4517,7 +4499,6 @@ fn tryExpr(...@@ -4517,7 +4499,6 @@ fn tryExpr(
4517 operand_node: ast.Node.Index,4499 operand_node: ast.Node.Index,
4518) InnerError!Zir.Inst.Ref {4500) InnerError!Zir.Inst.Ref {
4519 const astgen = parent_gz.astgen;4501 const astgen = parent_gz.astgen;
4520 const tree = astgen.tree;
45214502
4522 const fn_block = astgen.fn_block orelse {4503 const fn_block = astgen.fn_block orelse {
4523 return astgen.failNode(node, "invalid 'try' outside function scope", .{});4504 return astgen.failNode(node, "invalid 'try' outside function scope", .{});
...@@ -4702,7 +4683,6 @@ fn finishThenElseBlock(...@@ -4702,7 +4683,6 @@ fn finishThenElseBlock(
4702 // We now have enough information to decide whether the result instruction should4683 // We now have enough information to decide whether the result instruction should
4703 // be communicated via result location pointer or break instructions.4684 // be communicated via result location pointer or break instructions.
4704 const strat = rl.strategy(block_scope);4685 const strat = rl.strategy(block_scope);
4705 const astgen = block_scope.astgen;
4706 switch (strat.tag) {4686 switch (strat.tag) {
4707 .break_void => {4687 .break_void => {
4708 if (!parent_gz.refIsNoReturn(then_result)) {4688 if (!parent_gz.refIsNoReturn(then_result)) {
...@@ -4786,7 +4766,6 @@ fn arrayAccess(...@@ -4786,7 +4766,6 @@ fn arrayAccess(
4786) InnerError!Zir.Inst.Ref {4766) InnerError!Zir.Inst.Ref {
4787 const astgen = gz.astgen;4767 const astgen = gz.astgen;
4788 const tree = astgen.tree;4768 const tree = astgen.tree;
4789 const main_tokens = tree.nodes.items(.main_token);
4790 const node_datas = tree.nodes.items(.data);4769 const node_datas = tree.nodes.items(.data);
4791 switch (rl) {4770 switch (rl) {
4792 .ref => return gz.addBin(4771 .ref => return gz.addBin(
...@@ -6054,7 +6033,6 @@ fn ret(gz: *GenZir, scope: *Scope, node: ast.Node.Index) InnerError!Zir.Inst.Ref...@@ -6054,7 +6033,6 @@ fn ret(gz: *GenZir, scope: *Scope, node: ast.Node.Index) InnerError!Zir.Inst.Ref
6054 const astgen = gz.astgen;6033 const astgen = gz.astgen;
6055 const tree = astgen.tree;6034 const tree = astgen.tree;
6056 const node_datas = tree.nodes.items(.data);6035 const node_datas = tree.nodes.items(.data);
6057 const main_tokens = tree.nodes.items(.main_token);
60586036
6059 if (gz.in_defer) return astgen.failNode(node, "cannot return from defer expression", .{});6037 if (gz.in_defer) return astgen.failNode(node, "cannot return from defer expression", .{});
60606038
...@@ -6271,7 +6249,6 @@ fn multilineStringLiteral(...@@ -6271,7 +6249,6 @@ fn multilineStringLiteral(
6271 const astgen = gz.astgen;6249 const astgen = gz.astgen;
6272 const tree = astgen.tree;6250 const tree = astgen.tree;
6273 const node_datas = tree.nodes.items(.data);6251 const node_datas = tree.nodes.items(.data);
6274 const main_tokens = tree.nodes.items(.main_token);
62756252
6276 const start = node_datas[node].lhs;6253 const start = node_datas[node].lhs;
6277 const end = node_datas[node].rhs;6254 const end = node_datas[node].rhs;
...@@ -6387,7 +6364,6 @@ fn floatLiteral(...@@ -6387,7 +6364,6 @@ fn floatLiteral(
6387 node: ast.Node.Index,6364 node: ast.Node.Index,
6388) InnerError!Zir.Inst.Ref {6365) InnerError!Zir.Inst.Ref {
6389 const astgen = gz.astgen;6366 const astgen = gz.astgen;
6390 const arena = astgen.arena;
6391 const tree = astgen.tree;6367 const tree = astgen.tree;
6392 const main_tokens = tree.nodes.items(.main_token);6368 const main_tokens = tree.nodes.items(.main_token);
63936369
...@@ -6430,7 +6406,6 @@ fn asmExpr(...@@ -6430,7 +6406,6 @@ fn asmExpr(
6430 full: ast.full.Asm,6406 full: ast.full.Asm,
6431) InnerError!Zir.Inst.Ref {6407) InnerError!Zir.Inst.Ref {
6432 const astgen = gz.astgen;6408 const astgen = gz.astgen;
6433 const arena = astgen.arena;
6434 const tree = astgen.tree;6409 const tree = astgen.tree;
6435 const main_tokens = tree.nodes.items(.main_token);6410 const main_tokens = tree.nodes.items(.main_token);
6436 const node_datas = tree.nodes.items(.data);6411 const node_datas = tree.nodes.items(.data);
...@@ -6519,7 +6494,6 @@ fn asmExpr(...@@ -6519,7 +6494,6 @@ fn asmExpr(
6519 const name = try astgen.identAsString(symbolic_name);6494 const name = try astgen.identAsString(symbolic_name);
6520 const constraint_token = symbolic_name + 2;6495 const constraint_token = symbolic_name + 2;
6521 const constraint = (try astgen.strLitAsString(constraint_token)).index;6496 const constraint = (try astgen.strLitAsString(constraint_token)).index;
6522 const has_arrow = token_tags[symbolic_name + 4] == .arrow;
6523 const operand = try expr(gz, scope, .{ .ty = .usize_type }, node_datas[input_node].lhs);6497 const operand = try expr(gz, scope, .{ .ty = .usize_type }, node_datas[input_node].lhs);
6524 inputs[i] = .{6498 inputs[i] = .{
6525 .name = name,6499 .name = name,
...@@ -6601,7 +6575,7 @@ fn unionInit(...@@ -6601,7 +6575,7 @@ fn unionInit(
6601 const field_name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, params[1]);6575 const field_name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, params[1]);
6602 switch (rl) {6576 switch (rl) {
6603 .none, .none_or_ref, .discard, .ref, .ty, .inferred_ptr => {6577 .none, .none_or_ref, .discard, .ref, .ty, .inferred_ptr => {
6604 const field_type = try gz.addPlNode(.field_type_ref, params[1], Zir.Inst.FieldTypeRef{6578 _ = try gz.addPlNode(.field_type_ref, params[1], Zir.Inst.FieldTypeRef{
6605 .container_type = union_type,6579 .container_type = union_type,
6606 .field_name = field_name,6580 .field_name = field_name,
6607 });6581 });
...@@ -6783,7 +6757,6 @@ fn builtinCall(...@@ -6783,7 +6757,6 @@ fn builtinCall(
6783 switch (info.tag) {6757 switch (info.tag) {
6784 .import => {6758 .import => {
6785 const node_tags = tree.nodes.items(.tag);6759 const node_tags = tree.nodes.items(.tag);
6786 const node_datas = tree.nodes.items(.data);
6787 const operand_node = params[0];6760 const operand_node = params[0];
67886761
6789 if (node_tags[operand_node] != .string_literal) {6762 if (node_tags[operand_node] != .string_literal) {
...@@ -8119,7 +8092,6 @@ fn parseStrLit(...@@ -8119,7 +8092,6 @@ fn parseStrLit(
8119 bytes: []const u8,8092 bytes: []const u8,
8120 offset: u32,8093 offset: u32,
8121) InnerError!void {8094) InnerError!void {
8122 const tree = astgen.tree;
8123 const raw_string = bytes[offset..];8095 const raw_string = bytes[offset..];
8124 var buf_managed = buf.toManaged(astgen.gpa);8096 var buf_managed = buf.toManaged(astgen.gpa);
8125 const result = std.zig.string_literal.parseAppend(&buf_managed, raw_string);8097 const result = std.zig.string_literal.parseAppend(&buf_managed, raw_string);
...@@ -8567,7 +8539,6 @@ const GenZir = struct {...@@ -8567,7 +8539,6 @@ const GenZir = struct {
8567 fn calcLine(gz: GenZir, node: ast.Node.Index) u32 {8539 fn calcLine(gz: GenZir, node: ast.Node.Index) u32 {
8568 const astgen = gz.astgen;8540 const astgen = gz.astgen;
8569 const tree = astgen.tree;8541 const tree = astgen.tree;
8570 const node_tags = tree.nodes.items(.tag);
8571 const token_starts = tree.tokens.items(.start);8542 const token_starts = tree.tokens.items(.start);
8572 const decl_start = token_starts[tree.firstToken(gz.decl_node_index)];8543 const decl_start = token_starts[tree.firstToken(gz.decl_node_index)];
8573 const node_start = token_starts[tree.firstToken(node)];8544 const node_start = token_starts[tree.firstToken(node)];
src/Compilation.zig+1-2
...@@ -325,7 +325,6 @@ pub const AllErrors = struct {...@@ -325,7 +325,6 @@ pub const AllErrors = struct {
325 },325 },
326326
327 pub fn renderToStdErr(msg: Message, ttyconf: std.debug.TTY.Config) void {327 pub fn renderToStdErr(msg: Message, ttyconf: std.debug.TTY.Config) void {
328 const stderr_mutex = std.debug.getStderrMutex();
329 const held = std.debug.getStderrMutex().acquire();328 const held = std.debug.getStderrMutex().acquire();
330 defer held.release();329 defer held.release();
331 const stderr = std.io.getStdErr();330 const stderr = std.io.getStdErr();
...@@ -2373,7 +2372,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult {...@@ -2373,7 +2372,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult {
2373 // We need to "unhit" in this case, to keep the digests matching.2372 // We need to "unhit" in this case, to keep the digests matching.
2374 const prev_hash_state = man.hash.peekBin();2373 const prev_hash_state = man.hash.peekBin();
2375 const actual_hit = hit: {2374 const actual_hit = hit: {
2376 const is_hit = try man.hit();2375 _ = try man.hit();
2377 if (man.files.items.len == 0) {2376 if (man.files.items.len == 0) {
2378 man.unhit(prev_hash_state, 0);2377 man.unhit(prev_hash_state, 0);
2379 break :hit false;2378 break :hit false;
src/DepTokenizer.zig+2-3
...@@ -944,7 +944,7 @@ fn printLabel(out: anytype, label: []const u8, bytes: []const u8) !void {...@@ -944,7 +944,7 @@ fn printLabel(out: anytype, label: []const u8, bytes: []const u8) !void {
944 try out.writeAll(text);944 try out.writeAll(text);
945 var i: usize = text.len;945 var i: usize = text.len;
946 const end = 79;946 const end = 79;
947 while (i < 79) : (i += 1) {947 while (i < end) : (i += 1) {
948 try out.writeAll(&[_]u8{label[0]});948 try out.writeAll(&[_]u8{label[0]});
949 }949 }
950 try out.writeAll("\n");950 try out.writeAll("\n");
...@@ -953,7 +953,7 @@ fn printLabel(out: anytype, label: []const u8, bytes: []const u8) !void {...@@ -953,7 +953,7 @@ fn printLabel(out: anytype, label: []const u8, bytes: []const u8) !void {
953fn printRuler(out: anytype) !void {953fn printRuler(out: anytype) !void {
954 var i: usize = 0;954 var i: usize = 0;
955 const end = 79;955 const end = 79;
956 while (i < 79) : (i += 1) {956 while (i < end) : (i += 1) {
957 try out.writeAll("-");957 try out.writeAll("-");
958 }958 }
959 try out.writeAll("\n");959 try out.writeAll("\n");
...@@ -1057,4 +1057,3 @@ const printable_char_tab: [256]u8 = (...@@ -1057,4 +1057,3 @@ const printable_char_tab: [256]u8 = (
1057 "................................................................" ++1057 "................................................................" ++
1058 "................................................................"1058 "................................................................"
1059).*;1059).*;
1060
src/Module.zig+5-19
...@@ -1561,7 +1561,6 @@ pub const SrcLoc = struct {...@@ -1561,7 +1561,6 @@ pub const SrcLoc = struct {
1561 .node_offset_array_access_index => |node_off| {1561 .node_offset_array_access_index => |node_off| {
1562 const tree = try src_loc.file_scope.getTree(gpa);1562 const tree = try src_loc.file_scope.getTree(gpa);
1563 const node_datas = tree.nodes.items(.data);1563 const node_datas = tree.nodes.items(.data);
1564 const node_tags = tree.nodes.items(.tag);
1565 const node = src_loc.declRelativeToNodeIndex(node_off);1564 const node = src_loc.declRelativeToNodeIndex(node_off);
1566 const main_tokens = tree.nodes.items(.main_token);1565 const main_tokens = tree.nodes.items(.main_token);
1567 const tok_index = main_tokens[node_datas[node].rhs];1566 const tok_index = main_tokens[node_datas[node].rhs];
...@@ -1570,7 +1569,6 @@ pub const SrcLoc = struct {...@@ -1570,7 +1569,6 @@ pub const SrcLoc = struct {
1570 },1569 },
1571 .node_offset_slice_sentinel => |node_off| {1570 .node_offset_slice_sentinel => |node_off| {
1572 const tree = try src_loc.file_scope.getTree(gpa);1571 const tree = try src_loc.file_scope.getTree(gpa);
1573 const node_datas = tree.nodes.items(.data);
1574 const node_tags = tree.nodes.items(.tag);1572 const node_tags = tree.nodes.items(.tag);
1575 const node = src_loc.declRelativeToNodeIndex(node_off);1573 const node = src_loc.declRelativeToNodeIndex(node_off);
1576 const full = switch (node_tags[node]) {1574 const full = switch (node_tags[node]) {
...@@ -1586,7 +1584,6 @@ pub const SrcLoc = struct {...@@ -1586,7 +1584,6 @@ pub const SrcLoc = struct {
1586 },1584 },
1587 .node_offset_call_func => |node_off| {1585 .node_offset_call_func => |node_off| {
1588 const tree = try src_loc.file_scope.getTree(gpa);1586 const tree = try src_loc.file_scope.getTree(gpa);
1589 const node_datas = tree.nodes.items(.data);
1590 const node_tags = tree.nodes.items(.tag);1587 const node_tags = tree.nodes.items(.tag);
1591 const node = src_loc.declRelativeToNodeIndex(node_off);1588 const node = src_loc.declRelativeToNodeIndex(node_off);
1592 var params: [1]ast.Node.Index = undefined;1589 var params: [1]ast.Node.Index = undefined;
...@@ -1625,7 +1622,6 @@ pub const SrcLoc = struct {...@@ -1625,7 +1622,6 @@ pub const SrcLoc = struct {
1625 .node_offset_deref_ptr => |node_off| {1622 .node_offset_deref_ptr => |node_off| {
1626 const tree = try src_loc.file_scope.getTree(gpa);1623 const tree = try src_loc.file_scope.getTree(gpa);
1627 const node_datas = tree.nodes.items(.data);1624 const node_datas = tree.nodes.items(.data);
1628 const node_tags = tree.nodes.items(.tag);
1629 const node = src_loc.declRelativeToNodeIndex(node_off);1625 const node = src_loc.declRelativeToNodeIndex(node_off);
1630 const tok_index = node_datas[node].lhs;1626 const tok_index = node_datas[node].lhs;
1631 const token_starts = tree.tokens.items(.start);1627 const token_starts = tree.tokens.items(.start);
...@@ -1633,7 +1629,6 @@ pub const SrcLoc = struct {...@@ -1633,7 +1629,6 @@ pub const SrcLoc = struct {
1633 },1629 },
1634 .node_offset_asm_source => |node_off| {1630 .node_offset_asm_source => |node_off| {
1635 const tree = try src_loc.file_scope.getTree(gpa);1631 const tree = try src_loc.file_scope.getTree(gpa);
1636 const node_datas = tree.nodes.items(.data);
1637 const node_tags = tree.nodes.items(.tag);1632 const node_tags = tree.nodes.items(.tag);
1638 const node = src_loc.declRelativeToNodeIndex(node_off);1633 const node = src_loc.declRelativeToNodeIndex(node_off);
1639 const full = switch (node_tags[node]) {1634 const full = switch (node_tags[node]) {
...@@ -1648,7 +1643,6 @@ pub const SrcLoc = struct {...@@ -1648,7 +1643,6 @@ pub const SrcLoc = struct {
1648 },1643 },
1649 .node_offset_asm_ret_ty => |node_off| {1644 .node_offset_asm_ret_ty => |node_off| {
1650 const tree = try src_loc.file_scope.getTree(gpa);1645 const tree = try src_loc.file_scope.getTree(gpa);
1651 const node_datas = tree.nodes.items(.data);
1652 const node_tags = tree.nodes.items(.tag);1646 const node_tags = tree.nodes.items(.tag);
1653 const node = src_loc.declRelativeToNodeIndex(node_off);1647 const node = src_loc.declRelativeToNodeIndex(node_off);
1654 const full = switch (node_tags[node]) {1648 const full = switch (node_tags[node]) {
...@@ -1771,7 +1765,6 @@ pub const SrcLoc = struct {...@@ -1771,7 +1765,6 @@ pub const SrcLoc = struct {
17711765
1772 .node_offset_fn_type_cc => |node_off| {1766 .node_offset_fn_type_cc => |node_off| {
1773 const tree = try src_loc.file_scope.getTree(gpa);1767 const tree = try src_loc.file_scope.getTree(gpa);
1774 const node_datas = tree.nodes.items(.data);
1775 const node_tags = tree.nodes.items(.tag);1768 const node_tags = tree.nodes.items(.tag);
1776 const node = src_loc.declRelativeToNodeIndex(node_off);1769 const node = src_loc.declRelativeToNodeIndex(node_off);
1777 var params: [1]ast.Node.Index = undefined;1770 var params: [1]ast.Node.Index = undefined;
...@@ -1790,7 +1783,6 @@ pub const SrcLoc = struct {...@@ -1790,7 +1783,6 @@ pub const SrcLoc = struct {
17901783
1791 .node_offset_fn_type_ret_ty => |node_off| {1784 .node_offset_fn_type_ret_ty => |node_off| {
1792 const tree = try src_loc.file_scope.getTree(gpa);1785 const tree = try src_loc.file_scope.getTree(gpa);
1793 const node_datas = tree.nodes.items(.data);
1794 const node_tags = tree.nodes.items(.tag);1786 const node_tags = tree.nodes.items(.tag);
1795 const node = src_loc.declRelativeToNodeIndex(node_off);1787 const node = src_loc.declRelativeToNodeIndex(node_off);
1796 var params: [1]ast.Node.Index = undefined;1788 var params: [1]ast.Node.Index = undefined;
...@@ -1810,7 +1802,6 @@ pub const SrcLoc = struct {...@@ -1810,7 +1802,6 @@ pub const SrcLoc = struct {
1810 .node_offset_anyframe_type => |node_off| {1802 .node_offset_anyframe_type => |node_off| {
1811 const tree = try src_loc.file_scope.getTree(gpa);1803 const tree = try src_loc.file_scope.getTree(gpa);
1812 const node_datas = tree.nodes.items(.data);1804 const node_datas = tree.nodes.items(.data);
1813 const node_tags = tree.nodes.items(.tag);
1814 const parent_node = src_loc.declRelativeToNodeIndex(node_off);1805 const parent_node = src_loc.declRelativeToNodeIndex(node_off);
1815 const node = node_datas[parent_node].rhs;1806 const node = node_datas[parent_node].rhs;
1816 const main_tokens = tree.nodes.items(.main_token);1807 const main_tokens = tree.nodes.items(.main_token);
...@@ -2502,7 +2493,6 @@ pub fn astGenFile(mod: *Module, file: *Scope.File, prog_node: *std.Progress.Node...@@ -2502,7 +2493,6 @@ pub fn astGenFile(mod: *Module, file: *Scope.File, prog_node: *std.Progress.Node
2502 @ptrCast([*]const u8, file.zir.instructions.items(.data).ptr);2493 @ptrCast([*]const u8, file.zir.instructions.items(.data).ptr);
2503 if (data_has_safety_tag) {2494 if (data_has_safety_tag) {
2504 // The `Data` union has a safety tag but in the file format we store it without.2495 // The `Data` union has a safety tag but in the file format we store it without.
2505 const tags = file.zir.instructions.items(.tag);
2506 for (file.zir.instructions.items(.data)) |*data, i| {2496 for (file.zir.instructions.items(.data)) |*data, i| {
2507 const as_struct = @ptrCast(*const Stage1DataLayout, data);2497 const as_struct = @ptrCast(*const Stage1DataLayout, data);
2508 safety_buffer[i] = as_struct.data;2498 safety_buffer[i] = as_struct.data;
...@@ -3386,7 +3376,6 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) InnerError!vo...@@ -3386,7 +3376,6 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) InnerError!vo
3386 log.debug("scan existing {*} ({s}) of {*}", .{ decl, decl.name, namespace });3376 log.debug("scan existing {*} ({s}) of {*}", .{ decl, decl.name, namespace });
3387 // Update the AST node of the decl; even if its contents are unchanged, it may3377 // Update the AST node of the decl; even if its contents are unchanged, it may
3388 // have been re-ordered.3378 // have been re-ordered.
3389 const prev_src_node = decl.src_node;
3390 decl.src_node = decl_node;3379 decl.src_node = decl_node;
3391 decl.src_line = line;3380 decl.src_line = line;
33923381
...@@ -4692,11 +4681,9 @@ pub fn analyzeUnionFields(mod: *Module, union_obj: *Union) InnerError!void {...@@ -4692,11 +4681,9 @@ pub fn analyzeUnionFields(mod: *Module, union_obj: *Union) InnerError!void {
4692 const src: LazySrcLoc = .{ .node_offset = union_obj.node_offset };4681 const src: LazySrcLoc = .{ .node_offset = union_obj.node_offset };
4693 extra_index += @boolToInt(small.has_src_node);4682 extra_index += @boolToInt(small.has_src_node);
46944683
4695 const tag_type_ref = if (small.has_tag_type) blk: {4684 if (small.has_tag_type) {
4696 const tag_type_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]);
4697 extra_index += 1;4685 extra_index += 1;
4698 break :blk tag_type_ref;4686 }
4699 } else .none;
47004687
4701 const body_len = if (small.has_body_len) blk: {4688 const body_len = if (small.has_body_len) blk: {
4702 const body_len = zir.extra[extra_index];4689 const body_len = zir.extra[extra_index];
...@@ -4784,6 +4771,7 @@ pub fn analyzeUnionFields(mod: *Module, union_obj: *Union) InnerError!void {...@@ -4784,6 +4771,7 @@ pub fn analyzeUnionFields(mod: *Module, union_obj: *Union) InnerError!void {
4784 cur_bit_bag >>= 1;4771 cur_bit_bag >>= 1;
4785 const unused = @truncate(u1, cur_bit_bag) != 0;4772 const unused = @truncate(u1, cur_bit_bag) != 0;
4786 cur_bit_bag >>= 1;4773 cur_bit_bag >>= 1;
4774 _ = unused;
47874775
4788 const field_name_zir = zir.nullTerminatedString(zir.extra[extra_index]);4776 const field_name_zir = zir.nullTerminatedString(zir.extra[extra_index]);
4789 extra_index += 1;4777 extra_index += 1;
...@@ -4800,11 +4788,9 @@ pub fn analyzeUnionFields(mod: *Module, union_obj: *Union) InnerError!void {...@@ -4800,11 +4788,9 @@ pub fn analyzeUnionFields(mod: *Module, union_obj: *Union) InnerError!void {
4800 break :blk align_ref;4788 break :blk align_ref;
4801 } else .none;4789 } else .none;
48024790
4803 const tag_ref: Zir.Inst.Ref = if (has_tag) blk: {4791 if (has_tag) {
4804 const tag_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]);
4805 extra_index += 1;4792 extra_index += 1;
4806 break :blk tag_ref;4793 }
4807 } else .none;
48084794
4809 // This string needs to outlive the ZIR code.4795 // This string needs to outlive the ZIR code.
4810 const field_name = try decl_arena.allocator.dupe(u8, field_name_zir);4796 const field_name = try decl_arena.allocator.dupe(u8, field_name_zir);
src/Sema.zig+7-9
...@@ -1073,6 +1073,11 @@ fn zirOpaqueDecl(...@@ -1073,6 +1073,11 @@ fn zirOpaqueDecl(
1073 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;1073 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
1074 const src = inst_data.src();1074 const src = inst_data.src();
1075 const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index);1075 const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index);
1076 if (false) {
1077 inst_data;
1078 src;
1079 extra;
1080 }
10761081
1077 return sema.mod.fail(&block.base, sema.src, "TODO implement zirOpaqueDecl", .{});1082 return sema.mod.fail(&block.base, sema.src, "TODO implement zirOpaqueDecl", .{});
1078}1083}
...@@ -1230,7 +1235,6 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In...@@ -1230,7 +1235,6 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In
12301235
1231fn zirArg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {1236fn zirArg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
1232 const inst_data = sema.code.instructions.items(.data)[inst].str_tok;1237 const inst_data = sema.code.instructions.items(.data)[inst].str_tok;
1233 const src = inst_data.src();
1234 const arg_name = inst_data.get(sema.code);1238 const arg_name = inst_data.get(sema.code);
1235 const arg_index = sema.next_arg_index;1239 const arg_index = sema.next_arg_index;
1236 sema.next_arg_index += 1;1240 sema.next_arg_index += 1;
...@@ -3005,7 +3009,6 @@ fn zirFunc(...@@ -3005,7 +3009,6 @@ fn zirFunc(
3005 defer tracy.end();3009 defer tracy.end();
30063010
3007 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;3011 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
3008 const src = inst_data.src();
3009 const extra = sema.code.extraData(Zir.Inst.Func, inst_data.payload_index);3012 const extra = sema.code.extraData(Zir.Inst.Func, inst_data.payload_index);
3010 const param_types = sema.code.refSlice(extra.end, extra.data.param_types_len);3013 const param_types = sema.code.refSlice(extra.end, extra.data.param_types_len);
30113014
...@@ -3332,9 +3335,7 @@ fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError...@@ -3332,9 +3335,7 @@ fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError
3332 defer tracy.end();3335 defer tracy.end();
33333336
3334 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;3337 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
3335 const src = inst_data.src();
3336 const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };3338 const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
3337 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
3338 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;3339 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
33393340
3340 const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs);3341 const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs);
...@@ -3653,7 +3654,6 @@ fn analyzeSwitch(...@@ -3653,7 +3654,6 @@ fn analyzeSwitch(
3653 extra_index += 1;3654 extra_index += 1;
3654 const body_len = sema.code.extra[extra_index];3655 const body_len = sema.code.extra[extra_index];
3655 extra_index += 1;3656 extra_index += 1;
3656 const body = sema.code.extra[extra_index..][0..body_len];
3657 extra_index += body_len;3657 extra_index += body_len;
36583658
3659 try sema.validateSwitchItemEnum(3659 try sema.validateSwitchItemEnum(
...@@ -3763,7 +3763,6 @@ fn analyzeSwitch(...@@ -3763,7 +3763,6 @@ fn analyzeSwitch(
3763 extra_index += 1;3763 extra_index += 1;
3764 const body_len = sema.code.extra[extra_index];3764 const body_len = sema.code.extra[extra_index];
3765 extra_index += 1;3765 extra_index += 1;
3766 const body = sema.code.extra[extra_index..][0..body_len];
3767 extra_index += body_len;3766 extra_index += body_len;
37683767
3769 try sema.validateSwitchItem(3768 try sema.validateSwitchItem(
...@@ -3859,7 +3858,6 @@ fn analyzeSwitch(...@@ -3859,7 +3858,6 @@ fn analyzeSwitch(
3859 extra_index += 1;3858 extra_index += 1;
3860 const body_len = sema.code.extra[extra_index];3859 const body_len = sema.code.extra[extra_index];
3861 extra_index += 1;3860 extra_index += 1;
3862 const body = sema.code.extra[extra_index..][0..body_len];
3863 extra_index += body_len;3861 extra_index += body_len;
38643862
3865 try sema.validateSwitchItemBool(3863 try sema.validateSwitchItemBool(
...@@ -3942,7 +3940,6 @@ fn analyzeSwitch(...@@ -3942,7 +3940,6 @@ fn analyzeSwitch(
3942 extra_index += 1;3940 extra_index += 1;
3943 const body_len = sema.code.extra[extra_index];3941 const body_len = sema.code.extra[extra_index];
3944 extra_index += 1;3942 extra_index += 1;
3945 const body = sema.code.extra[extra_index..][0..body_len];
3946 extra_index += body_len;3943 extra_index += body_len;
39473944
3948 try sema.validateSwitchItemSparse(3945 try sema.validateSwitchItemSparse(
...@@ -4457,6 +4454,7 @@ fn validateSwitchNoRange(...@@ -4457,6 +4454,7 @@ fn validateSwitchNoRange(
4457fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {4454fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
4458 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;4455 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
4459 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;4456 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
4457 _ = extra;
4460 const src = inst_data.src();4458 const src = inst_data.src();
44614459
4462 return sema.mod.fail(&block.base, src, "TODO implement zirHasField", .{});4460 return sema.mod.fail(&block.base, src, "TODO implement zirHasField", .{});
...@@ -6035,7 +6033,6 @@ fn zirVarExtended(...@@ -6035,7 +6033,6 @@ fn zirVarExtended(
6035) InnerError!*Inst {6033) InnerError!*Inst {
6036 const extra = sema.code.extraData(Zir.Inst.ExtendedVar, extended.operand);6034 const extra = sema.code.extraData(Zir.Inst.ExtendedVar, extended.operand);
6037 const src = sema.src;6035 const src = sema.src;
6038 const align_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at align
6039 const ty_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at type6036 const ty_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at type
6040 const mut_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at mut token6037 const mut_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at mut token
6041 const init_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at init expr6038 const init_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at init expr
...@@ -7131,6 +7128,7 @@ fn analyzeSlice(...@@ -7131,6 +7128,7 @@ fn analyzeSlice(
7131 ptr_child.isVolatilePtr(),7128 ptr_child.isVolatilePtr(),
7132 return_ptr_size,7129 return_ptr_size,
7133 );7130 );
7131 _ = return_type;
71347132
7135 return sema.mod.fail(&block.base, src, "TODO implement analysis of slice", .{});7133 return sema.mod.fail(&block.base, src, "TODO implement analysis of slice", .{});
7136}7134}
src/ThreadPool.zig+2-2
...@@ -101,7 +101,7 @@ pub fn deinit(self: *ThreadPool) void {...@@ -101,7 +101,7 @@ pub fn deinit(self: *ThreadPool) void {
101101
102pub fn spawn(self: *ThreadPool, comptime func: anytype, args: anytype) !void {102pub fn spawn(self: *ThreadPool, comptime func: anytype, args: anytype) !void {
103 if (std.builtin.single_threaded) {103 if (std.builtin.single_threaded) {
104 const result = @call(.{}, func, args);104 @call(.{}, func, args);
105 return;105 return;
106 }106 }
107107
...@@ -114,7 +114,7 @@ pub fn spawn(self: *ThreadPool, comptime func: anytype, args: anytype) !void {...@@ -114,7 +114,7 @@ pub fn spawn(self: *ThreadPool, comptime func: anytype, args: anytype) !void {
114 fn runFn(runnable: *Runnable) void {114 fn runFn(runnable: *Runnable) void {
115 const run_node = @fieldParentPtr(RunQueue.Node, "data", runnable);115 const run_node = @fieldParentPtr(RunQueue.Node, "data", runnable);
116 const closure = @fieldParentPtr(@This(), "run_node", run_node);116 const closure = @fieldParentPtr(@This(), "run_node", run_node);
117 const result = @call(.{}, func, closure.arguments);117 @call(.{}, func, closure.arguments);
118118
119 const held = closure.pool.lock.acquire();119 const held = closure.pool.lock.acquire();
120 defer held.release();120 defer held.release();
src/Zir.zig+3-4
...@@ -3176,6 +3176,7 @@ const Writer = struct {...@@ -3176,6 +3176,7 @@ const Writer = struct {
3176 inst: Inst.Index,3176 inst: Inst.Index,
3177 ) (@TypeOf(stream).Error || error{OutOfMemory})!void {3177 ) (@TypeOf(stream).Error || error{OutOfMemory})!void {
3178 const inst_data = self.code.instructions.items(.data)[inst].array_type_sentinel;3178 const inst_data = self.code.instructions.items(.data)[inst].array_type_sentinel;
3179 _ = inst_data;
3179 try stream.writeAll("TODO)");3180 try stream.writeAll("TODO)");
3180 }3181 }
31813182
...@@ -3213,6 +3214,7 @@ const Writer = struct {...@@ -3213,6 +3214,7 @@ const Writer = struct {
3213 inst: Inst.Index,3214 inst: Inst.Index,
3214 ) (@TypeOf(stream).Error || error{OutOfMemory})!void {3215 ) (@TypeOf(stream).Error || error{OutOfMemory})!void {
3215 const inst_data = self.code.instructions.items(.data)[inst].ptr_type;3216 const inst_data = self.code.instructions.items(.data)[inst].ptr_type;
3217 _ = inst_data;
3216 try stream.writeAll("TODO)");3218 try stream.writeAll("TODO)");
3217 }3219 }
32183220
...@@ -4739,7 +4741,6 @@ fn findDeclsSwitch(...@@ -4739,7 +4741,6 @@ fn findDeclsSwitch(
4739 var extra_index: usize = special.end;4741 var extra_index: usize = special.end;
4740 var scalar_i: usize = 0;4742 var scalar_i: usize = 0;
4741 while (scalar_i < extra.data.cases_len) : (scalar_i += 1) {4743 while (scalar_i < extra.data.cases_len) : (scalar_i += 1) {
4742 const item_ref = @intToEnum(Inst.Ref, zir.extra[extra_index]);
4743 extra_index += 1;4744 extra_index += 1;
4744 const body_len = zir.extra[extra_index];4745 const body_len = zir.extra[extra_index];
4745 extra_index += 1;4746 extra_index += 1;
...@@ -4779,7 +4780,6 @@ fn findDeclsSwitchMulti(...@@ -4779,7 +4780,6 @@ fn findDeclsSwitchMulti(
4779 {4780 {
4780 var scalar_i: usize = 0;4781 var scalar_i: usize = 0;
4781 while (scalar_i < extra.data.scalar_cases_len) : (scalar_i += 1) {4782 while (scalar_i < extra.data.scalar_cases_len) : (scalar_i += 1) {
4782 const item_ref = @intToEnum(Inst.Ref, zir.extra[extra_index]);
4783 extra_index += 1;4783 extra_index += 1;
4784 const body_len = zir.extra[extra_index];4784 const body_len = zir.extra[extra_index];
4785 extra_index += 1;4785 extra_index += 1;
...@@ -4800,12 +4800,11 @@ fn findDeclsSwitchMulti(...@@ -4800,12 +4800,11 @@ fn findDeclsSwitchMulti(
4800 extra_index += 1;4800 extra_index += 1;
4801 const items = zir.refSlice(extra_index, items_len);4801 const items = zir.refSlice(extra_index, items_len);
4802 extra_index += items_len;4802 extra_index += items_len;
4803 _ = items;
48034804
4804 var range_i: usize = 0;4805 var range_i: usize = 0;
4805 while (range_i < ranges_len) : (range_i += 1) {4806 while (range_i < ranges_len) : (range_i += 1) {
4806 const item_first = @intToEnum(Inst.Ref, zir.extra[extra_index]);
4807 extra_index += 1;4807 extra_index += 1;
4808 const item_last = @intToEnum(Inst.Ref, zir.extra[extra_index]);
4809 extra_index += 1;4808 extra_index += 1;
4810 }4809 }
48114810
src/codegen.zig-1
...@@ -118,7 +118,6 @@ pub fn generateSymbol(...@@ -118,7 +118,6 @@ pub fn generateSymbol(
118 if (typed_value.ty.sentinel()) |sentinel| {118 if (typed_value.ty.sentinel()) |sentinel| {
119 try code.ensureCapacity(code.items.len + payload.data.len + 1);119 try code.ensureCapacity(code.items.len + payload.data.len + 1);
120 code.appendSliceAssumeCapacity(payload.data);120 code.appendSliceAssumeCapacity(payload.data);
121 const prev_len = code.items.len;
122 switch (try generateSymbol(bin_file, src_loc, .{121 switch (try generateSymbol(bin_file, src_loc, .{
123 .ty = typed_value.ty.elemType(),122 .ty = typed_value.ty.elemType(),
124 .val = sentinel,123 .val = sentinel,
src/codegen/c.zig-1
...@@ -1107,7 +1107,6 @@ fn genAsm(o: *Object, as: *Inst.Assembly) !CValue {...@@ -1107,7 +1107,6 @@ fn genAsm(o: *Object, as: *Inst.Assembly) !CValue {
1107 for (as.inputs) |i, index| {1107 for (as.inputs) |i, index| {
1108 if (i[0] == '{' and i[i.len - 1] == '}') {1108 if (i[0] == '{' and i[i.len - 1] == '}') {
1109 const reg = i[1 .. i.len - 1];1109 const reg = i[1 .. i.len - 1];
1110 const arg = as.args[index];
1111 if (index > 0) {1110 if (index > 0) {
1112 try writer.writeAll(", ");1111 try writer.writeAll(", ");
1113 }1112 }
src/codegen/spirv.zig+1-3
...@@ -714,7 +714,6 @@ pub const DeclGen = struct {...@@ -714,7 +714,6 @@ pub const DeclGen = struct {
714 return self.fail(inst.base.src, "TODO: SPIR-V backend: binary operations for strange integers", .{});714 return self.fail(inst.base.src, "TODO: SPIR-V backend: binary operations for strange integers", .{});
715 }715 }
716716
717 const is_bool = info.class == .bool;
718 const is_float = info.class == .float;717 const is_float = info.class == .float;
719 const is_signed = info.signedness == .signed;718 const is_signed = info.signedness == .signed;
720 // **Note**: All these operations must be valid for vectors as well!719 // **Note**: All these operations must be valid for vectors as well!
...@@ -802,8 +801,6 @@ pub const DeclGen = struct {...@@ -802,8 +801,6 @@ pub const DeclGen = struct {
802 const result_id = self.spv.allocResultId();801 const result_id = self.spv.allocResultId();
803 const result_type_id = try self.genType(inst.base.src, inst.base.ty);802 const result_type_id = try self.genType(inst.base.src, inst.base.ty);
804803
805 const info = try self.arithmeticTypeInfo(inst.operand.ty);
806
807 const opcode = switch (inst.base.tag) {804 const opcode = switch (inst.base.tag) {
808 // Bool -> bool805 // Bool -> bool
809 .not => Opcode.OpLogicalNot,806 .not => Opcode.OpLogicalNot,
...@@ -867,6 +864,7 @@ pub const DeclGen = struct {...@@ -867,6 +864,7 @@ pub const DeclGen = struct {
867 // are not allowed to be created from a phi node, and throw an error for those. For now, genType already throws864 // are not allowed to be created from a phi node, and throw an error for those. For now, genType already throws
868 // an error for pointers.865 // an error for pointers.
869 const result_type_id = try self.genType(inst.base.src, inst.base.ty);866 const result_type_id = try self.genType(inst.base.src, inst.base.ty);
867 _ = result_type_id;
870868
871 try writeOpcode(&self.code, .OpPhi, 2 + @intCast(u16, incoming_blocks.items.len * 2)); // result type + result + variable/parent...869 try writeOpcode(&self.code, .OpPhi, 2 + @intCast(u16, incoming_blocks.items.len * 2)); // result type + result + variable/parent...
872870
src/codegen/wasm.zig-3
...@@ -849,7 +849,6 @@ pub const Context = struct {...@@ -849,7 +849,6 @@ pub const Context = struct {
849 }849 }
850850
851 fn genCall(self: *Context, inst: *Inst.Call) InnerError!WValue {851 fn genCall(self: *Context, inst: *Inst.Call) InnerError!WValue {
852 const func_inst = inst.func.castTag(.constant).?;
853 const func_val = inst.func.value().?;852 const func_val = inst.func.value().?;
854853
855 const target: *Decl = blk: {854 const target: *Decl = blk: {
...@@ -1146,8 +1145,6 @@ pub const Context = struct {...@@ -1146,8 +1145,6 @@ pub const Context = struct {
1146 }1145 }
11471146
1148 fn genCmp(self: *Context, inst: *Inst.BinOp, op: std.math.CompareOperator) InnerError!WValue {1147 fn genCmp(self: *Context, inst: *Inst.BinOp, op: std.math.CompareOperator) InnerError!WValue {
1149 const ty = inst.lhs.ty.tag();
1150
1151 // save offset, so potential conditions can insert blocks in front of1148 // save offset, so potential conditions can insert blocks in front of
1152 // the comparison that we can later jump back to1149 // the comparison that we can later jump back to
1153 const offset = self.code.items.len;1150 const offset = self.code.items.len;
src/glibc.zig-1
...@@ -497,7 +497,6 @@ fn add_include_dirs(comp: *Compilation, arena: *Allocator, args: *std.ArrayList(...@@ -497,7 +497,6 @@ fn add_include_dirs(comp: *Compilation, arena: *Allocator, args: *std.ArrayList(
497 const target = comp.getTarget();497 const target = comp.getTarget();
498 const arch = target.cpu.arch;498 const arch = target.cpu.arch;
499 const opt_nptl: ?[]const u8 = if (target.os.tag == .linux) "nptl" else "htl";499 const opt_nptl: ?[]const u8 = if (target.os.tag == .linux) "nptl" else "htl";
500 const glibc = try lib_path(comp, arena, lib_libc ++ "glibc");
501500
502 const s = path.sep_str;501 const s = path.sep_str;
503502
src/link/MachO.zig-3
...@@ -2918,7 +2918,6 @@ fn relocateSymbolTable(self: *MachO) !void {...@@ -2918,7 +2918,6 @@ fn relocateSymbolTable(self: *MachO) !void {
2918 const nsyms = nlocals + nglobals + nundefs;2918 const nsyms = nlocals + nglobals + nundefs;
29192919
2920 if (symtab.nsyms < nsyms) {2920 if (symtab.nsyms < nsyms) {
2921 const linkedit_segment = self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
2922 const needed_size = nsyms * @sizeOf(macho.nlist_64);2921 const needed_size = nsyms * @sizeOf(macho.nlist_64);
2923 if (needed_size > self.allocatedSizeLinkedit(symtab.symoff)) {2922 if (needed_size > self.allocatedSizeLinkedit(symtab.symoff)) {
2924 // Move the entire symbol table to a new location2923 // Move the entire symbol table to a new location
...@@ -3150,7 +3149,6 @@ fn writeExportTrie(self: *MachO) !void {...@@ -3150,7 +3149,6 @@ fn writeExportTrie(self: *MachO) !void {
3150 const nwritten = try trie.write(stream.writer());3149 const nwritten = try trie.write(stream.writer());
3151 assert(nwritten == trie.size);3150 assert(nwritten == trie.size);
31523151
3153 const linkedit_segment = self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
3154 const dyld_info = &self.load_commands.items[self.dyld_info_cmd_index.?].DyldInfoOnly;3152 const dyld_info = &self.load_commands.items[self.dyld_info_cmd_index.?].DyldInfoOnly;
3155 const allocated_size = self.allocatedSizeLinkedit(dyld_info.export_off);3153 const allocated_size = self.allocatedSizeLinkedit(dyld_info.export_off);
3156 const needed_size = mem.alignForwardGeneric(u64, buffer.len, @alignOf(u64));3154 const needed_size = mem.alignForwardGeneric(u64, buffer.len, @alignOf(u64));
...@@ -3357,7 +3355,6 @@ fn populateLazyBindOffsetsInStubHelper(self: *MachO, buffer: []const u8) !void {...@@ -3357,7 +3355,6 @@ fn populateLazyBindOffsetsInStubHelper(self: *MachO, buffer: []const u8) !void {
3357 error.EndOfStream => break,3355 error.EndOfStream => break,
3358 else => return err,3356 else => return err,
3359 };3357 };
3360 const imm: u8 = inst & macho.BIND_IMMEDIATE_MASK;
3361 const opcode: u8 = inst & macho.BIND_OPCODE_MASK;3358 const opcode: u8 = inst & macho.BIND_OPCODE_MASK;
33623359
3363 switch (opcode) {3360 switch (opcode) {
src/link/MachO/DebugSymbols.zig-7
...@@ -500,7 +500,6 @@ pub fn flushModule(self: *DebugSymbols, allocator: *Allocator, options: link.Opt...@@ -500,7 +500,6 @@ pub fn flushModule(self: *DebugSymbols, allocator: *Allocator, options: link.Opt
500 if (self.debug_aranges_section_dirty) {500 if (self.debug_aranges_section_dirty) {
501 const dwarf_segment = &self.load_commands.items[self.dwarf_segment_cmd_index.?].Segment;501 const dwarf_segment = &self.load_commands.items[self.dwarf_segment_cmd_index.?].Segment;
502 const debug_aranges_sect = &dwarf_segment.sections.items[self.debug_aranges_section_index.?];502 const debug_aranges_sect = &dwarf_segment.sections.items[self.debug_aranges_section_index.?];
503 const debug_info_sect = dwarf_segment.sections.items[self.debug_info_section_index.?];
504503
505 var di_buf = std.ArrayList(u8).init(allocator);504 var di_buf = std.ArrayList(u8).init(allocator);
506 defer di_buf.deinit();505 defer di_buf.deinit();
...@@ -844,7 +843,6 @@ fn relocateSymbolTable(self: *DebugSymbols) !void {...@@ -844,7 +843,6 @@ fn relocateSymbolTable(self: *DebugSymbols) !void {
844 const nsyms = nlocals + nglobals;843 const nsyms = nlocals + nglobals;
845844
846 if (symtab.nsyms < nsyms) {845 if (symtab.nsyms < nsyms) {
847 const linkedit_segment = self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
848 const needed_size = nsyms * @sizeOf(macho.nlist_64);846 const needed_size = nsyms * @sizeOf(macho.nlist_64);
849 if (needed_size > self.allocatedSizeLinkedit(symtab.symoff)) {847 if (needed_size > self.allocatedSizeLinkedit(symtab.symoff)) {
850 // Move the entire symbol table to a new location848 // Move the entire symbol table to a new location
...@@ -904,11 +902,6 @@ pub fn updateDeclLineNumber(self: *DebugSymbols, module: *Module, decl: *const M...@@ -904,11 +902,6 @@ pub fn updateDeclLineNumber(self: *DebugSymbols, module: *Module, decl: *const M
904 const tracy = trace(@src());902 const tracy = trace(@src());
905 defer tracy.end();903 defer tracy.end();
906904
907 const tree = decl.namespace.file_scope.tree;
908 const node_tags = tree.nodes.items(.tag);
909 const node_datas = tree.nodes.items(.data);
910 const token_starts = tree.tokens.items(.start);
911
912 const func = decl.val.castTag(.function).?.data;905 const func = decl.val.castTag(.function).?.data;
913 const line_off = @intCast(u28, decl.src_line + func.lbrace_line);906 const line_off = @intCast(u28, decl.src_line + func.lbrace_line);
914907
src/link/MachO/Object.zig-1
...@@ -478,7 +478,6 @@ pub fn parseDebugInfo(self: *Object) !void {...@@ -478,7 +478,6 @@ pub fn parseDebugInfo(self: *Object) !void {
478478
479 self.tu_path = try std.fs.path.join(self.allocator, &[_][]const u8{ comp_dir, name });479 self.tu_path = try std.fs.path.join(self.allocator, &[_][]const u8{ comp_dir, name });
480 self.tu_mtime = mtime: {480 self.tu_mtime = mtime: {
481 var buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined;
482 const stat = try self.file.?.stat();481 const stat = try self.file.?.stat();
483 break :mtime @intCast(u64, @divFloor(stat.mtime, 1_000_000_000));482 break :mtime @intCast(u64, @divFloor(stat.mtime, 1_000_000_000));
484 };483 };
src/link/MachO/Zld.zig+1-5
...@@ -432,7 +432,6 @@ fn mapAndUpdateSections(...@@ -432,7 +432,6 @@ fn mapAndUpdateSections(
432432
433fn updateMetadata(self: *Zld) !void {433fn updateMetadata(self: *Zld) !void {
434 for (self.objects.items) |object| {434 for (self.objects.items) |object| {
435 const object_seg = object.load_commands.items[object.segment_cmd_index.?].Segment;
436 const text_seg = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;435 const text_seg = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;
437 const data_const_seg = &self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;436 const data_const_seg = &self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;
438 const data_seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;437 const data_seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
...@@ -1294,7 +1293,6 @@ fn allocateLinkeditSegment(self: *Zld) void {...@@ -1294,7 +1293,6 @@ fn allocateLinkeditSegment(self: *Zld) void {
1294}1293}
12951294
1296fn allocateSegment(self: *Zld, index: u16, offset: u64) !void {1295fn allocateSegment(self: *Zld, index: u16, offset: u64) !void {
1297 const base_vmaddr = self.load_commands.items[self.pagezero_segment_cmd_index.?].Segment.inner.vmsize;
1298 const seg = &self.load_commands.items[index].Segment;1296 const seg = &self.load_commands.items[index].Segment;
12991297
1300 // Allocate the sections according to their alignment at the beginning of the segment.1298 // Allocate the sections according to their alignment at the beginning of the segment.
...@@ -1427,7 +1425,6 @@ fn writeStubHelperCommon(self: *Zld) !void {...@@ -1427,7 +1425,6 @@ fn writeStubHelperCommon(self: *Zld) !void {
1427 const got = &data_const_segment.sections.items[self.got_section_index.?];1425 const got = &data_const_segment.sections.items[self.got_section_index.?];
1428 const data_segment = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;1426 const data_segment = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
1429 const data = &data_segment.sections.items[self.data_section_index.?];1427 const data = &data_segment.sections.items[self.data_section_index.?];
1430 const la_symbol_ptr = data_segment.sections.items[self.la_symbol_ptr_section_index.?];
14311428
1432 self.stub_helper_stubs_start_off = blk: {1429 self.stub_helper_stubs_start_off = blk: {
1433 switch (self.arch.?) {1430 switch (self.arch.?) {
...@@ -2654,7 +2651,6 @@ fn setEntryPoint(self: *Zld) !void {...@@ -2654,7 +2651,6 @@ fn setEntryPoint(self: *Zld) !void {
2654 // TODO we should respect the -entry flag passed in by the user to set a custom2651 // TODO we should respect the -entry flag passed in by the user to set a custom
2655 // entrypoint. For now, assume default of `_main`.2652 // entrypoint. For now, assume default of `_main`.
2656 const seg = self.load_commands.items[self.text_segment_cmd_index.?].Segment;2653 const seg = self.load_commands.items[self.text_segment_cmd_index.?].Segment;
2657 const text = seg.sections.items[self.text_section_index.?];
2658 const sym = self.globals.get("_main") orelse return error.MissingMainEntrypoint;2654 const sym = self.globals.get("_main") orelse return error.MissingMainEntrypoint;
2659 const entry_sym = sym.cast(Symbol.Regular) orelse unreachable;2655 const entry_sym = sym.cast(Symbol.Regular) orelse unreachable;
2660 const ec = &self.load_commands.items[self.main_cmd_index.?].Main;2656 const ec = &self.load_commands.items[self.main_cmd_index.?].Main;
...@@ -2862,7 +2858,6 @@ fn populateLazyBindOffsetsInStubHelper(self: *Zld, buffer: []const u8) !void {...@@ -2862,7 +2858,6 @@ fn populateLazyBindOffsetsInStubHelper(self: *Zld, buffer: []const u8) !void {
2862 error.EndOfStream => break,2858 error.EndOfStream => break,
2863 else => return err,2859 else => return err,
2864 };2860 };
2865 const imm: u8 = inst & macho.BIND_IMMEDIATE_MASK;
2866 const opcode: u8 = inst & macho.BIND_OPCODE_MASK;2861 const opcode: u8 = inst & macho.BIND_OPCODE_MASK;
28672862
2868 switch (opcode) {2863 switch (opcode) {
...@@ -2959,6 +2954,7 @@ fn writeDebugInfo(self: *Zld) !void {...@@ -2959,6 +2954,7 @@ fn writeDebugInfo(self: *Zld) !void {
2959 for (self.objects.items) |object| {2954 for (self.objects.items) |object| {
2960 const tu_path = object.tu_path orelse continue;2955 const tu_path = object.tu_path orelse continue;
2961 const tu_mtime = object.tu_mtime orelse continue;2956 const tu_mtime = object.tu_mtime orelse continue;
2957 _ = tu_mtime;
2962 const dirname = std.fs.path.dirname(tu_path) orelse "./";2958 const dirname = std.fs.path.dirname(tu_path) orelse "./";
2963 // Current dir2959 // Current dir
2964 try stabs.append(.{2960 try stabs.append(.{
src/link/MachO/reloc/x86_64.zig-1
...@@ -175,7 +175,6 @@ pub const Parser = struct {...@@ -175,7 +175,6 @@ pub const Parser = struct {
175175
176 const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type);176 const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type);
177 const target = Relocation.Target.from_reloc(rel, parser.symbols);177 const target = Relocation.Target.from_reloc(rel, parser.symbols);
178 const is_extern = rel.r_extern == 1;
179178
180 const offset = @intCast(u32, rel.r_address);179 const offset = @intCast(u32, rel.r_address);
181 const inst = parser.code[offset..][0..4];180 const inst = parser.code[offset..][0..4];
src/link/Wasm.zig-1
...@@ -496,7 +496,6 @@ pub fn flushModule(self: *Wasm, comp: *Compilation) !void {...@@ -496,7 +496,6 @@ pub fn flushModule(self: *Wasm, comp: *Compilation) !void {
496 if (data_size != 0) {496 if (data_size != 0) {
497 const header_offset = try reserveVecSectionHeader(file);497 const header_offset = try reserveVecSectionHeader(file);
498 const writer = file.writer();498 const writer = file.writer();
499 var len: u32 = 0;
500 // index to memory section (currently, there can only be 1 memory section in wasm)499 // index to memory section (currently, there can only be 1 memory section in wasm)
501 try leb.writeULEB128(writer, @as(u32, 0));500 try leb.writeULEB128(writer, @as(u32, 0));
502501
src/main.zig-1
...@@ -3749,7 +3749,6 @@ pub fn cmdAstCheck(...@@ -3749,7 +3749,6 @@ pub fn cmdAstCheck(
37493749
3750 var color: Color = .auto;3750 var color: Color = .auto;
3751 var want_output_text = false;3751 var want_output_text = false;
3752 var have_zig_source_file = false;
3753 var zig_source_file: ?[]const u8 = null;3752 var zig_source_file: ?[]const u8 = null;
37543753
3755 var i: usize = 0;3754 var i: usize = 0;
src/mingw.zig-2
...@@ -372,11 +372,9 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {...@@ -372,11 +372,9 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {
372372
373 try child.spawn();373 try child.spawn();
374374
375 const stdout_reader = child.stdout.?.reader();
376 const stderr_reader = child.stderr.?.reader();375 const stderr_reader = child.stderr.?.reader();
377376
378 // TODO https://github.com/ziglang/zig/issues/6343377 // TODO https://github.com/ziglang/zig/issues/6343
379 const stdout = try stdout_reader.readAllAlloc(arena, std.math.maxInt(u32));
380 const stderr = try stderr_reader.readAllAlloc(arena, 10 * 1024 * 1024);378 const stderr = try stderr_reader.readAllAlloc(arena, 10 * 1024 * 1024);
381379
382 const term = child.wait() catch |err| {380 const term = child.wait() catch |err| {
src/musl.zig-1
...@@ -143,7 +143,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -143,7 +143,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
143 const dirname = path.dirname(src_file).?;143 const dirname = path.dirname(src_file).?;
144 const basename = path.basename(src_file);144 const basename = path.basename(src_file);
145 const noextbasename = basename[0 .. basename.len - std.fs.path.extension(basename).len];145 const noextbasename = basename[0 .. basename.len - std.fs.path.extension(basename).len];
146 const before_arch_dir = path.dirname(dirname).?;
147 const dirbasename = path.basename(dirname);146 const dirbasename = path.basename(dirname);
148147
149 var is_arch_specific = false;148 var is_arch_specific = false;
src/register_manager.zig-12
...@@ -281,12 +281,6 @@ test "default state" {...@@ -281,12 +281,6 @@ test "default state" {
281 };281 };
282 defer function.deinit();282 defer function.deinit();
283283
284 var mock_instruction = ir.Inst{
285 .tag = .breakpoint,
286 .ty = Type.initTag(.void),
287 .src = .unneeded,
288 };
289
290 try expect(!function.register_manager.isRegAllocated(.r2));284 try expect(!function.register_manager.isRegAllocated(.r2));
291 try expect(!function.register_manager.isRegAllocated(.r3));285 try expect(!function.register_manager.isRegAllocated(.r3));
292 try expect(function.register_manager.isRegFree(.r2));286 try expect(function.register_manager.isRegFree(.r2));
...@@ -365,12 +359,6 @@ test "tryAllocRegs" {...@@ -365,12 +359,6 @@ test "tryAllocRegs" {
365 };359 };
366 defer function.deinit();360 defer function.deinit();
367361
368 var mock_instruction = ir.Inst{
369 .tag = .breakpoint,
370 .ty = Type.initTag(.void),
371 .src = .unneeded,
372 };
373
374 try expectEqual([_]MockRegister2{ .r0, .r1, .r2 }, function.register_manager.tryAllocRegs(3, .{ null, null, null }, &.{}).?);362 try expectEqual([_]MockRegister2{ .r0, .r1, .r2 }, function.register_manager.tryAllocRegs(3, .{ null, null, null }, &.{}).?);
375363
376 // Exceptions364 // Exceptions
src/translate_c.zig-4
...@@ -1321,7 +1321,6 @@ fn transConvertVectorExpr(...@@ -1321,7 +1321,6 @@ fn transConvertVectorExpr(
1321 const src_type = qualTypeCanon(src_expr.getType());1321 const src_type = qualTypeCanon(src_expr.getType());
1322 const src_vector_ty = @ptrCast(*const clang.VectorType, src_type);1322 const src_vector_ty = @ptrCast(*const clang.VectorType, src_type);
1323 const src_element_qt = src_vector_ty.getElementType();1323 const src_element_qt = src_vector_ty.getElementType();
1324 const src_element_type_node = try transQualType(c, &block_scope.base, src_element_qt, base_stmt.getBeginLoc());
13251324
1326 const src_expr_node = try transExpr(c, &block_scope.base, src_expr, .used);1325 const src_expr_node = try transExpr(c, &block_scope.base, src_expr, .used);
13271326
...@@ -3802,7 +3801,6 @@ fn transBinaryConditionalOperator(c: *Context, scope: *Scope, stmt: *const clang...@@ -3802,7 +3801,6 @@ fn transBinaryConditionalOperator(c: *Context, scope: *Scope, stmt: *const clang
3802 const res_is_bool = qualTypeIsBoolean(qt);3801 const res_is_bool = qualTypeIsBoolean(qt);
3803 const casted_stmt = @ptrCast(*const clang.AbstractConditionalOperator, stmt);3802 const casted_stmt = @ptrCast(*const clang.AbstractConditionalOperator, stmt);
3804 const cond_expr = casted_stmt.getCond();3803 const cond_expr = casted_stmt.getCond();
3805 const true_expr = casted_stmt.getTrueExpr();
3806 const false_expr = casted_stmt.getFalseExpr();3804 const false_expr = casted_stmt.getFalseExpr();
38073805
3808 // c: (cond_expr)?:(false_expr)3806 // c: (cond_expr)?:(false_expr)
...@@ -4336,8 +4334,6 @@ fn transCreateNodeNumber(c: *Context, num: anytype, num_kind: enum { int, float...@@ -4336,8 +4334,6 @@ fn transCreateNodeNumber(c: *Context, num: anytype, num_kind: enum { int, float
4336}4334}
43374335
4338fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: Node, proto_alias: *ast.Payload.Func) !Node {4336fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: Node, proto_alias: *ast.Payload.Func) !Node {
4339 const scope = &c.global_scope.base;
4340
4341 var fn_params = std.ArrayList(ast.Payload.Param).init(c.gpa);4337 var fn_params = std.ArrayList(ast.Payload.Param).init(c.gpa);
4342 defer fn_params.deinit();4338 defer fn_params.deinit();
43434339
src/type.zig+1-2
...@@ -3013,7 +3013,7 @@ pub const Type = extern union {...@@ -3013,7 +3013,7 @@ pub const Type = extern union {
3013 .base = .{ .tag = t },3013 .base = .{ .tag = t },
3014 .data = data,3014 .data = data,
3015 };3015 };
3016 return Type{ .ptr_otherwise = &ptr.base };3016 return file_struct.Type{ .ptr_otherwise = &ptr.base };
3017 }3017 }
30183018
3019 pub fn Data(comptime t: Tag) type {3019 pub fn Data(comptime t: Tag) type {
...@@ -3163,7 +3163,6 @@ pub const CType = enum {...@@ -3163,7 +3163,6 @@ pub const CType = enum {
3163 longdouble,3163 longdouble,
31643164
3165 pub fn sizeInBits(self: CType, target: Target) u16 {3165 pub fn sizeInBits(self: CType, target: Target) u16 {
3166 const arch = target.cpu.arch;
3167 switch (target.os.tag) {3166 switch (target.os.tag) {
3168 .freestanding, .other => switch (target.cpu.arch) {3167 .freestanding, .other => switch (target.cpu.arch) {
3169 .msp430 => switch (self) {3168 .msp430 => switch (self) {
test/behavior/async_fn.zig+16
...@@ -13,6 +13,7 @@ test "simple coroutine suspend and resume" {...@@ -13,6 +13,7 @@ test "simple coroutine suspend and resume" {
13 resume frame;13 resume frame;
14 try expect(global_x == 3);14 try expect(global_x == 3);
15 const af: anyframe->void = &frame;15 const af: anyframe->void = &frame;
16 _ = af;
16 resume frame;17 resume frame;
17 try expect(global_x == 4);18 try expect(global_x == 4);
18}19}
...@@ -45,6 +46,7 @@ test "suspend at end of function" {...@@ -45,6 +46,7 @@ test "suspend at end of function" {
45 fn doTheTest() !void {46 fn doTheTest() !void {
46 try expect(x == 1);47 try expect(x == 1);
47 const p = async suspendAtEnd();48 const p = async suspendAtEnd();
49 _ = p;
48 try expect(x == 2);50 try expect(x == 2);
49 }51 }
5052
...@@ -132,6 +134,7 @@ test "@frameSize" {...@@ -132,6 +134,7 @@ test "@frameSize" {
132 }134 }
133 fn other(param: i32) void {135 fn other(param: i32) void {
134 var local: i32 = undefined;136 var local: i32 = undefined;
137 _ = local;
135 suspend {}138 suspend {}
136 }139 }
137 };140 };
...@@ -181,6 +184,7 @@ test "coroutine suspend, resume" {...@@ -181,6 +184,7 @@ test "coroutine suspend, resume" {
181184
182test "coroutine suspend with block" {185test "coroutine suspend with block" {
183 const p = async testSuspendBlock();186 const p = async testSuspendBlock();
187 _ = p;
184 try expect(!global_result);188 try expect(!global_result);
185 resume a_promise;189 resume a_promise;
186 try expect(global_result);190 try expect(global_result);
...@@ -207,6 +211,7 @@ var await_final_result: i32 = 0;...@@ -207,6 +211,7 @@ var await_final_result: i32 = 0;
207test "coroutine await" {211test "coroutine await" {
208 await_seq('a');212 await_seq('a');
209 var p = async await_amain();213 var p = async await_amain();
214 _ = p;
210 await_seq('f');215 await_seq('f');
211 resume await_a_promise;216 resume await_a_promise;
212 await_seq('i');217 await_seq('i');
...@@ -243,6 +248,7 @@ var early_final_result: i32 = 0;...@@ -243,6 +248,7 @@ var early_final_result: i32 = 0;
243test "coroutine await early return" {248test "coroutine await early return" {
244 early_seq('a');249 early_seq('a');
245 var p = async early_amain();250 var p = async early_amain();
251 _ = p;
246 early_seq('f');252 early_seq('f');
247 try expect(early_final_result == 1234);253 try expect(early_final_result == 1234);
248 try expect(std.mem.eql(u8, &early_points, "abcdef"));254 try expect(std.mem.eql(u8, &early_points, "abcdef"));
...@@ -276,6 +282,7 @@ test "async function with dot syntax" {...@@ -276,6 +282,7 @@ test "async function with dot syntax" {
276 }282 }
277 };283 };
278 const p = async S.foo();284 const p = async S.foo();
285 _ = p;
279 try expect(S.y == 2);286 try expect(S.y == 2);
280}287}
281288
...@@ -362,11 +369,13 @@ test "error return trace across suspend points - early return" {...@@ -362,11 +369,13 @@ test "error return trace across suspend points - early return" {
362 const p = nonFailing();369 const p = nonFailing();
363 resume p;370 resume p;
364 const p2 = async printTrace(p);371 const p2 = async printTrace(p);
372 _ = p2;
365}373}
366374
367test "error return trace across suspend points - async return" {375test "error return trace across suspend points - async return" {
368 const p = nonFailing();376 const p = nonFailing();
369 const p2 = async printTrace(p);377 const p2 = async printTrace(p);
378 _ = p2;
370 resume p;379 resume p;
371}380}
372381
...@@ -396,6 +405,7 @@ fn printTrace(p: anyframe->(anyerror!void)) callconv(.Async) void {...@@ -396,6 +405,7 @@ fn printTrace(p: anyframe->(anyerror!void)) callconv(.Async) void {
396test "break from suspend" {405test "break from suspend" {
397 var my_result: i32 = 1;406 var my_result: i32 = 1;
398 const p = async testBreakFromSuspend(&my_result);407 const p = async testBreakFromSuspend(&my_result);
408 _ = p;
399 try std.testing.expect(my_result == 2);409 try std.testing.expect(my_result == 2);
400}410}
401fn testBreakFromSuspend(my_result: *i32) callconv(.Async) void {411fn testBreakFromSuspend(my_result: *i32) callconv(.Async) void {
...@@ -619,6 +629,7 @@ test "returning a const error from async function" {...@@ -619,6 +629,7 @@ test "returning a const error from async function" {
619 fn amain() !void {629 fn amain() !void {
620 var download_frame = async fetchUrl(10, "a string");630 var download_frame = async fetchUrl(10, "a string");
621 const download_text = try await download_frame;631 const download_text = try await download_frame;
632 _ = download_text;
622633
623 @panic("should not get here");634 @panic("should not get here");
624 }635 }
...@@ -730,6 +741,7 @@ test "alignment of local variables in async functions" {...@@ -730,6 +741,7 @@ test "alignment of local variables in async functions" {
730 const S = struct {741 const S = struct {
731 fn doTheTest() !void {742 fn doTheTest() !void {
732 var y: u8 = 123;743 var y: u8 = 123;
744 _ = y;
733 var x: u8 align(128) = 1;745 var x: u8 align(128) = 1;
734 try expect(@ptrToInt(&x) % 128 == 0);746 try expect(@ptrToInt(&x) % 128 == 0);
735 }747 }
...@@ -742,6 +754,7 @@ test "no reason to resolve frame still works" {...@@ -742,6 +754,7 @@ test "no reason to resolve frame still works" {
742}754}
743fn simpleNothing() void {755fn simpleNothing() void {
744 var x: i32 = 1234;756 var x: i32 = 1234;
757 _ = x;
745}758}
746759
747test "async call a generic function" {760test "async call a generic function" {
...@@ -802,6 +815,7 @@ test "struct parameter to async function is copied to the frame" {...@@ -802,6 +815,7 @@ test "struct parameter to async function is copied to the frame" {
802 if (x == 0) return;815 if (x == 0) return;
803 clobberStack(x - 1);816 clobberStack(x - 1);
804 var y: i32 = x;817 var y: i32 = x;
818 _ = y;
805 }819 }
806820
807 fn bar(f: *@Frame(foo)) void {821 fn bar(f: *@Frame(foo)) void {
...@@ -1654,6 +1668,7 @@ test "@asyncCall with pass-by-value arguments" {...@@ -1654,6 +1668,7 @@ test "@asyncCall with pass-by-value arguments" {
1654 [_]u8{ 1, 2, 3, 4, 5 },1668 [_]u8{ 1, 2, 3, 4, 5 },
1655 F2,1669 F2,
1656 });1670 });
1671 _ = frame_ptr;
1657}1672}
16581673
1659test "@asyncCall with arguments having non-standard alignment" {1674test "@asyncCall with arguments having non-standard alignment" {
...@@ -1673,4 +1688,5 @@ test "@asyncCall with arguments having non-standard alignment" {...@@ -1673,4 +1688,5 @@ test "@asyncCall with arguments having non-standard alignment" {
1673 // The function pointer must not be comptime-known.1688 // The function pointer must not be comptime-known.
1674 var t = S.f;1689 var t = S.f;
1675 var frame_ptr = @asyncCall(&buffer, {}, t, .{ F0, undefined, F1 });1690 var frame_ptr = @asyncCall(&buffer, {}, t, .{ F0, undefined, F1 });
1691 _ = frame_ptr;
1676}1692}
test/behavior/atomics.zig-2
...@@ -97,7 +97,6 @@ test "cmpxchg with ptr" {...@@ -97,7 +97,6 @@ test "cmpxchg with ptr" {
9797
98test "cmpxchg with ignored result" {98test "cmpxchg with ignored result" {
99 var x: i32 = 1234;99 var x: i32 = 1234;
100 var ptr = &x;
101100
102 _ = @cmpxchgStrong(i32, &x, 1234, 5678, .Monotonic, .Monotonic);101 _ = @cmpxchgStrong(i32, &x, 1234, 5678, .Monotonic, .Monotonic);
103102
...@@ -195,7 +194,6 @@ fn testAtomicRmwInt() !void {...@@ -195,7 +194,6 @@ fn testAtomicRmwInt() !void {
195test "atomics with different types" {194test "atomics with different types" {
196 try testAtomicsWithType(bool, true, false);195 try testAtomicsWithType(bool, true, false);
197 inline for (.{ u1, i4, u5, i15, u24 }) |T| {196 inline for (.{ u1, i4, u5, i15, u24 }) |T| {
198 var x: T = 0;
199 try testAtomicsWithType(T, 0, 1);197 try testAtomicsWithType(T, 0, 1);
200 }198 }
201 try testAtomicsWithType(u0, 0, 0);199 try testAtomicsWithType(u0, 0, 0);
test/behavior/await_struct.zig+1
...@@ -12,6 +12,7 @@ var await_final_result = Foo{ .x = 0 };...@@ -12,6 +12,7 @@ var await_final_result = Foo{ .x = 0 };
12test "coroutine await struct" {12test "coroutine await struct" {
13 await_seq('a');13 await_seq('a');
14 var p = async await_amain();14 var p = async await_amain();
15 _ = p;
15 await_seq('f');16 await_seq('f');
16 resume await_a_promise;17 resume await_a_promise;
17 await_seq('i');18 await_seq('i');
test/behavior/bit_shifting.zig+1-1
...@@ -100,5 +100,5 @@ test "comptime shr of BigInt" {...@@ -100,5 +100,5 @@ test "comptime shr of BigInt" {
100}100}
101101
102test "comptime shift safety check" {102test "comptime shift safety check" {
103 const x = @as(usize, 42) << @sizeOf(usize);103 _ = @as(usize, 42) << @sizeOf(usize);
104}104}
test/behavior/bugs/1467.zig+1
...@@ -4,4 +4,5 @@ pub const S = extern struct {...@@ -4,4 +4,5 @@ pub const S = extern struct {
4};4};
5test "bug 1467" {5test "bug 1467" {
6 const s: S = undefined;6 const s: S = undefined;
7 _ = s;
7}8}
test/behavior/bugs/1500.zig+4
...@@ -7,4 +7,8 @@ const B = fn (A) void;...@@ -7,4 +7,8 @@ const B = fn (A) void;
7test "allow these dependencies" {7test "allow these dependencies" {
8 var a: A = undefined;8 var a: A = undefined;
9 var b: B = undefined;9 var b: B = undefined;
10 if (false) {
11 a;
12 b;
13 }
10}14}
test/behavior/bugs/2346.zig+2
...@@ -1,6 +1,8 @@...@@ -1,6 +1,8 @@
1test "fixed" {1test "fixed" {
2 const a: *void = undefined;2 const a: *void = undefined;
3 const b: *[1]void = a;3 const b: *[1]void = a;
4 _ = b;
4 const c: *[0]u8 = undefined;5 const c: *[0]u8 = undefined;
5 const d: []u8 = c;6 const d: []u8 = c;
7 _ = d;
6}8}
test/behavior/bugs/3586.zig+1
...@@ -8,4 +8,5 @@ test "fixed" {...@@ -8,4 +8,5 @@ test "fixed" {
8 var ctr = Container{8 var ctr = Container{
9 .params = NoteParams{},9 .params = NoteParams{},
10 };10 };
11 _ = ctr;
11}12}
test/behavior/bugs/4954.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1fn f(buf: []u8) void {1fn f(buf: []u8) void {
2 var ptr = &buf[@sizeOf(u32)];2 _ = &buf[@sizeOf(u32)];
3}3}
44
5test "crash" {5test "crash" {
test/behavior/bugs/7003.zig+1
...@@ -5,4 +5,5 @@ test "@Type should resolve its children types" {...@@ -5,4 +5,5 @@ test "@Type should resolve its children types" {
5 comptime var sparse_info = @typeInfo(anyerror!sparse);5 comptime var sparse_info = @typeInfo(anyerror!sparse);
6 sparse_info.ErrorUnion.payload = dense;6 sparse_info.ErrorUnion.payload = dense;
7 const B = @Type(sparse_info);7 const B = @Type(sparse_info);
8 _ = B;
8}9}
test/behavior/bugs/828.zig+4
...@@ -30,4 +30,8 @@ test "comptime struct return should not return the same instance" {...@@ -30,4 +30,8 @@ test "comptime struct return should not return the same instance" {
30 //a second parameter is required to trigger the bug30 //a second parameter is required to trigger the bug
31 const ValA = constCount(&CountBy.One, 12);31 const ValA = constCount(&CountBy.One, 12);
32 const ValB = constCount(&CountBy.One, 15);32 const ValB = constCount(&CountBy.One, 15);
33 if (false) {
34 ValA;
35 ValB;
36 }
33}37}
test/behavior/cast.zig+3
...@@ -102,6 +102,7 @@ fn castToOptionalTypeError(z: i32) !void {...@@ -102,6 +102,7 @@ fn castToOptionalTypeError(z: i32) !void {
102102
103 const f = z;103 const f = z;
104 const g: anyerror!?i32 = f;104 const g: anyerror!?i32 = f;
105 _ = g catch {};
105106
106 const a = A{ .a = z };107 const a = A{ .a = z };
107 const b: anyerror!?A = a;108 const b: anyerror!?A = a;
...@@ -114,7 +115,9 @@ test "implicitly cast from int to anyerror!?T" {...@@ -114,7 +115,9 @@ test "implicitly cast from int to anyerror!?T" {
114}115}
115fn implicitIntLitToOptional() void {116fn implicitIntLitToOptional() void {
116 const f: ?i32 = 1;117 const f: ?i32 = 1;
118 _ = f;
117 const g: anyerror!?i32 = 1;119 const g: anyerror!?i32 = 1;
120 _ = g catch {};
118}121}
119122
120test "return null from fn() anyerror!?&T" {123test "return null from fn() anyerror!?&T" {
test/behavior/enum.zig+2
...@@ -111,6 +111,8 @@ test "enum type" {...@@ -111,6 +111,8 @@ test "enum type" {
111 .y = 5678,111 .y = 5678,
112 },112 },
113 };113 };
114 try expect(foo1.One == 13);
115 try expect(foo2.Two.x == 1234 and foo2.Two.y == 5678);
114 const bar = Bar.B;116 const bar = Bar.B;
115117
116 try expect(bar == Bar.B);118 try expect(bar == Bar.B);
test/behavior/error.zig+5-1
...@@ -103,6 +103,7 @@ fn testErrorSetType() !void {...@@ -103,6 +103,7 @@ fn testErrorSetType() !void {
103103
104 const a: MyErrSet!i32 = 5678;104 const a: MyErrSet!i32 = 5678;
105 const b: MyErrSet!i32 = MyErrSet.OutOfMemory;105 const b: MyErrSet!i32 = MyErrSet.OutOfMemory;
106 try expect(b catch error.OutOfMemory == error.OutOfMemory);
106107
107 if (a) |value| try expect(value == 5678) else |err| switch (err) {108 if (a) |value| try expect(value == 5678) else |err| switch (err) {
108 error.OutOfMemory => unreachable,109 error.OutOfMemory => unreachable,
...@@ -162,6 +163,7 @@ fn testErrToIntWithOnePossibleValue(...@@ -162,6 +163,7 @@ fn testErrToIntWithOnePossibleValue(
162163
163test "empty error union" {164test "empty error union" {
164 const x = error{} || error{};165 const x = error{} || error{};
166 _ = x;
165}167}
166168
167test "error union peer type resolution" {169test "error union peer type resolution" {
...@@ -204,6 +206,7 @@ fn entry() void {...@@ -204,6 +206,7 @@ fn entry() void {
204206
205fn foo2(f: fn () anyerror!void) void {207fn foo2(f: fn () anyerror!void) void {
206 const x = f();208 const x = f();
209 x catch {};
207}210}
208211
209fn bar2() (error{}!void) {}212fn bar2() (error{}!void) {}
...@@ -338,6 +341,7 @@ test "optional error set is the same size as error set" {...@@ -338,6 +341,7 @@ test "optional error set is the same size as error set" {
338test "debug info for optional error set" {341test "debug info for optional error set" {
339 const SomeError = error{Hello};342 const SomeError = error{Hello};
340 var a_local_variable: ?SomeError = null;343 var a_local_variable: ?SomeError = null;
344 _ = a_local_variable;
341}345}
342346
343test "nested catch" {347test "nested catch" {
...@@ -349,7 +353,7 @@ test "nested catch" {...@@ -349,7 +353,7 @@ test "nested catch" {
349 return error.Wrong;353 return error.Wrong;
350 }354 }
351 fn func() anyerror!Foo {355 fn func() anyerror!Foo {
352 const x = fail() catch356 _ = fail() catch
353 fail() catch357 fail() catch
354 return error.Bad;358 return error.Bad;
355 unreachable;359 unreachable;
test/behavior/eval.zig+2
...@@ -184,6 +184,7 @@ fn testTryToTrickEvalWithRuntimeIf(b: bool) usize {...@@ -184,6 +184,7 @@ fn testTryToTrickEvalWithRuntimeIf(b: bool) usize {
184 comptime var i: usize = 0;184 comptime var i: usize = 0;
185 inline while (i < 10) : (i += 1) {185 inline while (i < 10) : (i += 1) {
186 const result = if (b) false else true;186 const result = if (b) false else true;
187 _ = result;
187 }188 }
188 comptime {189 comptime {
189 return i;190 return i;
...@@ -195,6 +196,7 @@ test "inlined loop has array literal with elided runtime scope on first iteratio...@@ -195,6 +196,7 @@ test "inlined loop has array literal with elided runtime scope on first iteratio
195 comptime var i: usize = 0;196 comptime var i: usize = 0;
196 inline while (i < 2) : (i += 1) {197 inline while (i < 2) : (i += 1) {
197 const result = if (i == 0) [1]i32{2} else runtime;198 const result = if (i == 0) [1]i32{2} else runtime;
199 _ = result;
198 }200 }
199 comptime {201 comptime {
200 try expect(i == 2);202 try expect(i == 2);
test/behavior/import.zig+1-1
...@@ -18,5 +18,5 @@ test "import in non-toplevel scope" {...@@ -18,5 +18,5 @@ test "import in non-toplevel scope" {
18}18}
1919
20test "import empty file" {20test "import empty file" {
21 const empty = @import("import/empty.zig");21 _ = @import("import/empty.zig");
22}22}
test/behavior/inttoptr.zig+1-1
...@@ -5,7 +5,7 @@ test "casting random address to function pointer" {...@@ -5,7 +5,7 @@ test "casting random address to function pointer" {
55
6fn randomAddressToFunction() void {6fn randomAddressToFunction() void {
7 var addr: usize = 0xdeadbeef;7 var addr: usize = 0xdeadbeef;
8 var ptr = @intToPtr(fn () void, addr);8 _ = @intToPtr(fn () void, addr);
9}9}
1010
11test "mutate through ptr initialized with constant intToPtr value" {11test "mutate through ptr initialized with constant intToPtr value" {
test/behavior/ir_block_deps.zig+1
...@@ -5,6 +5,7 @@ fn foo(id: u64) !i32 {...@@ -5,6 +5,7 @@ fn foo(id: u64) !i32 {
5 1 => getErrInt(),5 1 => getErrInt(),
6 2 => {6 2 => {
7 const size = try getErrInt();7 const size = try getErrInt();
8 _ = size;
8 return try getErrInt();9 return try getErrInt();
9 },10 },
10 else => error.ItBroke,11 else => error.ItBroke,
test/behavior/math.zig+11
...@@ -333,6 +333,12 @@ test "quad hex float literal parsing in range" {...@@ -333,6 +333,12 @@ test "quad hex float literal parsing in range" {
333 const b = 0x1.dedafcff354b6ae9758763545432p-9;333 const b = 0x1.dedafcff354b6ae9758763545432p-9;
334 const c = 0x1.2f34dd5f437e849b4baab754cdefp+4534;334 const c = 0x1.2f34dd5f437e849b4baab754cdefp+4534;
335 const d = 0x1.edcbff8ad76ab5bf46463233214fp-435;335 const d = 0x1.edcbff8ad76ab5bf46463233214fp-435;
336 if (false) {
337 a;
338 b;
339 c;
340 d;
341 }
336}342}
337343
338test "quad hex float literal parsing accurate" {344test "quad hex float literal parsing accurate" {
...@@ -457,6 +463,11 @@ test "hex float literal within range" {...@@ -457,6 +463,11 @@ test "hex float literal within range" {
457 const a = 0x1.0p16383;463 const a = 0x1.0p16383;
458 const b = 0x0.1p16387;464 const b = 0x0.1p16387;
459 const c = 0x1.0p-16382;465 const c = 0x1.0p-16382;
466 if (false) {
467 a;
468 b;
469 c;
470 }
460}471}
461472
462test "truncating shift left" {473test "truncating shift left" {
test/behavior/misc.zig+1
...@@ -234,6 +234,7 @@ test "compile time global reinterpret" {...@@ -234,6 +234,7 @@ test "compile time global reinterpret" {
234test "explicit cast maybe pointers" {234test "explicit cast maybe pointers" {
235 const a: ?*i32 = undefined;235 const a: ?*i32 = undefined;
236 const b: ?*f32 = @ptrCast(?*f32, a);236 const b: ?*f32 = @ptrCast(?*f32, a);
237 _ = b;
237}238}
238239
239test "generic malloc free" {240test "generic malloc free" {
test/behavior/null.zig+1
...@@ -39,6 +39,7 @@ test "test maybe object and get a pointer to the inner value" {...@@ -39,6 +39,7 @@ test "test maybe object and get a pointer to the inner value" {
39test "rhs maybe unwrap return" {39test "rhs maybe unwrap return" {
40 const x: ?bool = true;40 const x: ?bool = true;
41 const y = x orelse return;41 const y = x orelse return;
42 _ = y;
42}43}
4344
44test "maybe return" {45test "maybe return" {
test/behavior/optional.zig+1
...@@ -128,6 +128,7 @@ test "nested orelse" {...@@ -128,6 +128,7 @@ test "nested orelse" {
128 const x = maybe() orelse128 const x = maybe() orelse
129 maybe() orelse129 maybe() orelse
130 return null;130 return null;
131 _ = x;
131 unreachable;132 unreachable;
132 }133 }
133 const Foo = struct {134 const Foo = struct {
test/behavior/pointers.zig+5-1
...@@ -65,6 +65,10 @@ test "assigning integer to C pointer" {...@@ -65,6 +65,10 @@ test "assigning integer to C pointer" {
65 var x: i32 = 0;65 var x: i32 = 0;
66 var ptr: [*c]u8 = 0;66 var ptr: [*c]u8 = 0;
67 var ptr2: [*c]u8 = x;67 var ptr2: [*c]u8 = x;
68 if (false) {
69 ptr;
70 ptr2;
71 }
68}72}
6973
70test "implicit cast single item pointer to C pointer and back" {74test "implicit cast single item pointer to C pointer and back" {
...@@ -78,7 +82,6 @@ test "implicit cast single item pointer to C pointer and back" {...@@ -78,7 +82,6 @@ test "implicit cast single item pointer to C pointer and back" {
78test "C pointer comparison and arithmetic" {82test "C pointer comparison and arithmetic" {
79 const S = struct {83 const S = struct {
80 fn doTheTest() !void {84 fn doTheTest() !void {
81 var one: usize = 1;
82 var ptr1: [*c]u32 = 0;85 var ptr1: [*c]u32 = 0;
83 var ptr2 = ptr1 + 10;86 var ptr2 = ptr1 + 10;
84 try expect(ptr1 == 0);87 try expect(ptr1 == 0);
...@@ -325,6 +328,7 @@ test "@ptrToInt on null optional at comptime" {...@@ -325,6 +328,7 @@ test "@ptrToInt on null optional at comptime" {
325 {328 {
326 const pointer = @intToPtr(?*u8, 0x000);329 const pointer = @intToPtr(?*u8, 0x000);
327 const x = @ptrToInt(pointer);330 const x = @ptrToInt(pointer);
331 _ = x;
328 comptime try expect(0 == @ptrToInt(pointer));332 comptime try expect(0 == @ptrToInt(pointer));
329 }333 }
330 {334 {
test/behavior/sizeof_and_typeof.zig+2-2
...@@ -195,11 +195,11 @@ test "branching logic inside @TypeOf" {...@@ -195,11 +195,11 @@ test "branching logic inside @TypeOf" {
195195
196fn fn1(alpha: bool) void {196fn fn1(alpha: bool) void {
197 const n: usize = 7;197 const n: usize = 7;
198 const v = if (alpha) n else @sizeOf(usize);198 _ = if (alpha) n else @sizeOf(usize);
199}199}
200200
201test "lazy @sizeOf result is checked for definedness" {201test "lazy @sizeOf result is checked for definedness" {
202 const f = fn1;202 _ = fn1;
203}203}
204204
205test "@bitSizeOf" {205test "@bitSizeOf" {
test/behavior/slice.zig+1
...@@ -104,6 +104,7 @@ test "obtaining a null terminated slice" {...@@ -104,6 +104,7 @@ test "obtaining a null terminated slice" {
104104
105 // now we obtain a null terminated slice:105 // now we obtain a null terminated slice:
106 const ptr = buf[0..3 :0];106 const ptr = buf[0..3 :0];
107 _ = ptr;
107108
108 var runtime_len: usize = 3;109 var runtime_len: usize = 3;
109 const ptr2 = buf[0..runtime_len :0];110 const ptr2 = buf[0..runtime_len :0];
test/behavior/slice_sentinel_comptime.zig+28
...@@ -3,6 +3,7 @@ test "comptime slice-sentinel in bounds (unterminated)" {...@@ -3,6 +3,7 @@ test "comptime slice-sentinel in bounds (unterminated)" {
3 comptime {3 comptime {
4 var target = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;4 var target = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
5 const slice = target[0..3 :'d'];5 const slice = target[0..3 :'d'];
6 _ = slice;
6 }7 }
78
8 // ptr_array9 // ptr_array
...@@ -10,6 +11,7 @@ test "comptime slice-sentinel in bounds (unterminated)" {...@@ -10,6 +11,7 @@ test "comptime slice-sentinel in bounds (unterminated)" {
10 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;11 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
11 var target = &buf;12 var target = &buf;
12 const slice = target[0..3 :'d'];13 const slice = target[0..3 :'d'];
14 _ = slice;
13 }15 }
1416
15 // vector_ConstPtrSpecialBaseArray17 // vector_ConstPtrSpecialBaseArray
...@@ -17,6 +19,7 @@ test "comptime slice-sentinel in bounds (unterminated)" {...@@ -17,6 +19,7 @@ test "comptime slice-sentinel in bounds (unterminated)" {
17 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;19 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
18 var target: [*]u8 = &buf;20 var target: [*]u8 = &buf;
19 const slice = target[0..3 :'d'];21 const slice = target[0..3 :'d'];
22 _ = slice;
20 }23 }
2124
22 // vector_ConstPtrSpecialRef25 // vector_ConstPtrSpecialRef
...@@ -24,6 +27,7 @@ test "comptime slice-sentinel in bounds (unterminated)" {...@@ -24,6 +27,7 @@ test "comptime slice-sentinel in bounds (unterminated)" {
24 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;27 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
25 var target: [*]u8 = @ptrCast([*]u8, &buf);28 var target: [*]u8 = @ptrCast([*]u8, &buf);
26 const slice = target[0..3 :'d'];29 const slice = target[0..3 :'d'];
30 _ = slice;
27 }31 }
2832
29 // cvector_ConstPtrSpecialBaseArray33 // cvector_ConstPtrSpecialBaseArray
...@@ -31,6 +35,7 @@ test "comptime slice-sentinel in bounds (unterminated)" {...@@ -31,6 +35,7 @@ test "comptime slice-sentinel in bounds (unterminated)" {
31 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;35 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
32 var target: [*c]u8 = &buf;36 var target: [*c]u8 = &buf;
33 const slice = target[0..3 :'d'];37 const slice = target[0..3 :'d'];
38 _ = slice;
34 }39 }
3540
36 // cvector_ConstPtrSpecialRef41 // cvector_ConstPtrSpecialRef
...@@ -38,6 +43,7 @@ test "comptime slice-sentinel in bounds (unterminated)" {...@@ -38,6 +43,7 @@ test "comptime slice-sentinel in bounds (unterminated)" {
38 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;43 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
39 var target: [*c]u8 = @ptrCast([*c]u8, &buf);44 var target: [*c]u8 = @ptrCast([*c]u8, &buf);
40 const slice = target[0..3 :'d'];45 const slice = target[0..3 :'d'];
46 _ = slice;
41 }47 }
4248
43 // slice49 // slice
...@@ -45,6 +51,7 @@ test "comptime slice-sentinel in bounds (unterminated)" {...@@ -45,6 +51,7 @@ test "comptime slice-sentinel in bounds (unterminated)" {
45 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;51 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
46 var target: []u8 = &buf;52 var target: []u8 = &buf;
47 const slice = target[0..3 :'d'];53 const slice = target[0..3 :'d'];
54 _ = slice;
48 }55 }
49}56}
5057
...@@ -53,6 +60,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" {...@@ -53,6 +60,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" {
53 comptime {60 comptime {
54 var target = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;61 var target = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;
55 const slice = target[0..13 :0xff];62 const slice = target[0..13 :0xff];
63 _ = slice;
56 }64 }
5765
58 // ptr_array66 // ptr_array
...@@ -60,6 +68,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" {...@@ -60,6 +68,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" {
60 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;68 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;
61 var target = &buf;69 var target = &buf;
62 const slice = target[0..13 :0xff];70 const slice = target[0..13 :0xff];
71 _ = slice;
63 }72 }
6473
65 // vector_ConstPtrSpecialBaseArray74 // vector_ConstPtrSpecialBaseArray
...@@ -67,6 +76,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" {...@@ -67,6 +76,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" {
67 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;76 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;
68 var target: [*]u8 = &buf;77 var target: [*]u8 = &buf;
69 const slice = target[0..13 :0xff];78 const slice = target[0..13 :0xff];
79 _ = slice;
70 }80 }
7181
72 // vector_ConstPtrSpecialRef82 // vector_ConstPtrSpecialRef
...@@ -74,6 +84,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" {...@@ -74,6 +84,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" {
74 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;84 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;
75 var target: [*]u8 = @ptrCast([*]u8, &buf);85 var target: [*]u8 = @ptrCast([*]u8, &buf);
76 const slice = target[0..13 :0xff];86 const slice = target[0..13 :0xff];
87 _ = slice;
77 }88 }
7889
79 // cvector_ConstPtrSpecialBaseArray90 // cvector_ConstPtrSpecialBaseArray
...@@ -81,6 +92,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" {...@@ -81,6 +92,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" {
81 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;92 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;
82 var target: [*c]u8 = &buf;93 var target: [*c]u8 = &buf;
83 const slice = target[0..13 :0xff];94 const slice = target[0..13 :0xff];
95 _ = slice;
84 }96 }
8597
86 // cvector_ConstPtrSpecialRef98 // cvector_ConstPtrSpecialRef
...@@ -88,6 +100,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" {...@@ -88,6 +100,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" {
88 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;100 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;
89 var target: [*c]u8 = @ptrCast([*c]u8, &buf);101 var target: [*c]u8 = @ptrCast([*c]u8, &buf);
90 const slice = target[0..13 :0xff];102 const slice = target[0..13 :0xff];
103 _ = slice;
91 }104 }
92105
93 // slice106 // slice
...@@ -95,6 +108,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" {...@@ -95,6 +108,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" {
95 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;108 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;
96 var target: []u8 = &buf;109 var target: []u8 = &buf;
97 const slice = target[0..13 :0xff];110 const slice = target[0..13 :0xff];
111 _ = slice;
98 }112 }
99}113}
100114
...@@ -103,6 +117,7 @@ test "comptime slice-sentinel in bounds (terminated)" {...@@ -103,6 +117,7 @@ test "comptime slice-sentinel in bounds (terminated)" {
103 comptime {117 comptime {
104 var target = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;118 var target = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
105 const slice = target[0..3 :'d'];119 const slice = target[0..3 :'d'];
120 _ = slice;
106 }121 }
107122
108 // ptr_array123 // ptr_array
...@@ -110,6 +125,7 @@ test "comptime slice-sentinel in bounds (terminated)" {...@@ -110,6 +125,7 @@ test "comptime slice-sentinel in bounds (terminated)" {
110 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;125 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
111 var target = &buf;126 var target = &buf;
112 const slice = target[0..3 :'d'];127 const slice = target[0..3 :'d'];
128 _ = slice;
113 }129 }
114130
115 // vector_ConstPtrSpecialBaseArray131 // vector_ConstPtrSpecialBaseArray
...@@ -117,6 +133,7 @@ test "comptime slice-sentinel in bounds (terminated)" {...@@ -117,6 +133,7 @@ test "comptime slice-sentinel in bounds (terminated)" {
117 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;133 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
118 var target: [*]u8 = &buf;134 var target: [*]u8 = &buf;
119 const slice = target[0..3 :'d'];135 const slice = target[0..3 :'d'];
136 _ = slice;
120 }137 }
121138
122 // vector_ConstPtrSpecialRef139 // vector_ConstPtrSpecialRef
...@@ -124,6 +141,7 @@ test "comptime slice-sentinel in bounds (terminated)" {...@@ -124,6 +141,7 @@ test "comptime slice-sentinel in bounds (terminated)" {
124 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;141 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
125 var target: [*]u8 = @ptrCast([*]u8, &buf);142 var target: [*]u8 = @ptrCast([*]u8, &buf);
126 const slice = target[0..3 :'d'];143 const slice = target[0..3 :'d'];
144 _ = slice;
127 }145 }
128146
129 // cvector_ConstPtrSpecialBaseArray147 // cvector_ConstPtrSpecialBaseArray
...@@ -131,6 +149,7 @@ test "comptime slice-sentinel in bounds (terminated)" {...@@ -131,6 +149,7 @@ test "comptime slice-sentinel in bounds (terminated)" {
131 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;149 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
132 var target: [*c]u8 = &buf;150 var target: [*c]u8 = &buf;
133 const slice = target[0..3 :'d'];151 const slice = target[0..3 :'d'];
152 _ = slice;
134 }153 }
135154
136 // cvector_ConstPtrSpecialRef155 // cvector_ConstPtrSpecialRef
...@@ -138,6 +157,7 @@ test "comptime slice-sentinel in bounds (terminated)" {...@@ -138,6 +157,7 @@ test "comptime slice-sentinel in bounds (terminated)" {
138 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;157 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
139 var target: [*c]u8 = @ptrCast([*c]u8, &buf);158 var target: [*c]u8 = @ptrCast([*c]u8, &buf);
140 const slice = target[0..3 :'d'];159 const slice = target[0..3 :'d'];
160 _ = slice;
141 }161 }
142162
143 // slice163 // slice
...@@ -145,6 +165,7 @@ test "comptime slice-sentinel in bounds (terminated)" {...@@ -145,6 +165,7 @@ test "comptime slice-sentinel in bounds (terminated)" {
145 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;165 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
146 var target: []u8 = &buf;166 var target: []u8 = &buf;
147 const slice = target[0..3 :'d'];167 const slice = target[0..3 :'d'];
168 _ = slice;
148 }169 }
149}170}
150171
...@@ -153,6 +174,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" {...@@ -153,6 +174,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" {
153 comptime {174 comptime {
154 var target = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;175 var target = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
155 const slice = target[0..14 :0];176 const slice = target[0..14 :0];
177 _ = slice;
156 }178 }
157179
158 // ptr_array180 // ptr_array
...@@ -160,6 +182,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" {...@@ -160,6 +182,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" {
160 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;182 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
161 var target = &buf;183 var target = &buf;
162 const slice = target[0..14 :0];184 const slice = target[0..14 :0];
185 _ = slice;
163 }186 }
164187
165 // vector_ConstPtrSpecialBaseArray188 // vector_ConstPtrSpecialBaseArray
...@@ -167,6 +190,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" {...@@ -167,6 +190,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" {
167 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;190 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
168 var target: [*]u8 = &buf;191 var target: [*]u8 = &buf;
169 const slice = target[0..14 :0];192 const slice = target[0..14 :0];
193 _ = slice;
170 }194 }
171195
172 // vector_ConstPtrSpecialRef196 // vector_ConstPtrSpecialRef
...@@ -174,6 +198,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" {...@@ -174,6 +198,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" {
174 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;198 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
175 var target: [*]u8 = @ptrCast([*]u8, &buf);199 var target: [*]u8 = @ptrCast([*]u8, &buf);
176 const slice = target[0..14 :0];200 const slice = target[0..14 :0];
201 _ = slice;
177 }202 }
178203
179 // cvector_ConstPtrSpecialBaseArray204 // cvector_ConstPtrSpecialBaseArray
...@@ -181,6 +206,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" {...@@ -181,6 +206,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" {
181 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;206 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
182 var target: [*c]u8 = &buf;207 var target: [*c]u8 = &buf;
183 const slice = target[0..14 :0];208 const slice = target[0..14 :0];
209 _ = slice;
184 }210 }
185211
186 // cvector_ConstPtrSpecialRef212 // cvector_ConstPtrSpecialRef
...@@ -188,6 +214,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" {...@@ -188,6 +214,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" {
188 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;214 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
189 var target: [*c]u8 = @ptrCast([*c]u8, &buf);215 var target: [*c]u8 = @ptrCast([*c]u8, &buf);
190 const slice = target[0..14 :0];216 const slice = target[0..14 :0];
217 _ = slice;
191 }218 }
192219
193 // slice220 // slice
...@@ -195,5 +222,6 @@ test "comptime slice-sentinel in bounds (on target sentinel)" {...@@ -195,5 +222,6 @@ test "comptime slice-sentinel in bounds (on target sentinel)" {
195 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;222 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
196 var target: []u8 = &buf;223 var target: []u8 = &buf;
197 const slice = target[0..14 :0];224 const slice = target[0..14 :0];
225 _ = slice;
198 }226 }
199}227}
test/behavior/struct.zig+5-3
...@@ -584,13 +584,14 @@ test "default struct initialization fields" {...@@ -584,13 +584,14 @@ test "default struct initialization fields" {
584 const x = S{584 const x = S{
585 .b = 5,585 .b = 5,
586 };586 };
587 if (x.a + x.b != 1239) {
588 @compileError("it should be comptime known");
589 }
590 var five: i32 = 5;587 var five: i32 = 5;
591 const y = S{588 const y = S{
592 .b = five,589 .b = five,
593 };590 };
591 if (x.a + x.b != 1239) {
592 @compileError("it should be comptime known");
593 }
594 try expectEqual(y, x);
594 try expectEqual(1239, x.a + x.b);595 try expectEqual(1239, x.a + x.b);
595}596}
596597
...@@ -654,6 +655,7 @@ test "zero-bit field in packed struct" {...@@ -654,6 +655,7 @@ test "zero-bit field in packed struct" {
654 y: void,655 y: void,
655 };656 };
656 var x: S = undefined;657 var x: S = undefined;
658 _ = x;
657}659}
658660
659test "struct field init with catch" {661test "struct field init with catch" {
test/behavior/switch.zig+2
...@@ -103,6 +103,7 @@ fn switchProngWithVarFn(a: SwitchProngWithVarEnum) !void {...@@ -103,6 +103,7 @@ fn switchProngWithVarFn(a: SwitchProngWithVarEnum) !void {
103 },103 },
104 SwitchProngWithVarEnum.Meh => |x| {104 SwitchProngWithVarEnum.Meh => |x| {
105 const v: void = x;105 const v: void = x;
106 _ = v;
106 },107 },
107 }108 }
108}109}
...@@ -454,6 +455,7 @@ test "switch variable for range and multiple prongs" {...@@ -454,6 +455,7 @@ test "switch variable for range and multiple prongs" {
454 }455 }
455 }456 }
456 };457 };
458 _ = S;
457}459}
458460
459var state: u32 = 0;461var state: u32 = 0;
test/behavior/tuple.zig+1
...@@ -105,6 +105,7 @@ test "tuple initializer for var" {...@@ -105,6 +105,7 @@ test "tuple initializer for var" {
105 .id = @as(usize, 2),105 .id = @as(usize, 2),
106 .name = Bytes{ .id = 20 },106 .name = Bytes{ .id = 20 },
107 };107 };
108 _ = tmp;
108 }109 }
109 };110 };
110111
test/behavior/type.zig+1
...@@ -436,6 +436,7 @@ test "Type.Fn" {...@@ -436,6 +436,7 @@ test "Type.Fn" {
436 }.func;436 }.func;
437 const Foo = @Type(@typeInfo(@TypeOf(foo)));437 const Foo = @Type(@typeInfo(@TypeOf(foo)));
438 const foo_2: Foo = foo;438 const foo_2: Foo = foo;
439 _ = foo_2;
439}440}
440441
441test "Type.BoundFn" {442test "Type.BoundFn" {
test/behavior/type_info.zig+1
...@@ -329,6 +329,7 @@ test "typeInfo with comptime parameter in struct fn def" {...@@ -329,6 +329,7 @@ test "typeInfo with comptime parameter in struct fn def" {
329 pub fn func(comptime x: f32) void {}329 pub fn func(comptime x: f32) void {}
330 };330 };
331 comptime var info = @typeInfo(S);331 comptime var info = @typeInfo(S);
332 _ = info;
332}333}
333334
334test "type info: vectors" {335test "type info: vectors" {
test/behavior/union.zig+1
...@@ -781,6 +781,7 @@ test "@unionInit on union w/ tag but no fields" {...@@ -781,6 +781,7 @@ test "@unionInit on union w/ tag but no fields" {
781781
782 fn doTheTest() !void {782 fn doTheTest() !void {
783 var data: Data = .{ .no_op = .{} };783 var data: Data = .{ .no_op = .{} };
784 _ = data;
784 var o = Data.decode(&[_]u8{});785 var o = Data.decode(&[_]u8{});
785 try expectEqual(Type.no_op, o);786 try expectEqual(Type.no_op, o);
786 }787 }
test/behavior/var_args.zig+2-2
...@@ -18,7 +18,7 @@ test "add arbitrary args" {...@@ -18,7 +18,7 @@ test "add arbitrary args" {
18}18}
1919
20fn readFirstVarArg(args: anytype) void {20fn readFirstVarArg(args: anytype) void {
21 const value = args[0];21 _ = args[0];
22}22}
2323
24test "send void arg to var args" {24test "send void arg to var args" {
...@@ -79,5 +79,5 @@ test "pass zero length array to var args param" {...@@ -79,5 +79,5 @@ test "pass zero length array to var args param" {
79}79}
8080
81fn doNothingWithFirstArg(args: anytype) void {81fn doNothingWithFirstArg(args: anytype) void {
82 const a = args[0];82 _ = args[0];
83}83}
test/behavior/vector.zig+2
...@@ -113,6 +113,7 @@ test "array to vector" {...@@ -113,6 +113,7 @@ test "array to vector" {
113 var foo: f32 = 3.14;113 var foo: f32 = 3.14;
114 var arr = [4]f32{ foo, 1.5, 0.0, 0.0 };114 var arr = [4]f32{ foo, 1.5, 0.0, 0.0 };
115 var vec: Vector(4, f32) = arr;115 var vec: Vector(4, f32) = arr;
116 _ = vec;
116}117}
117118
118test "vector casts of sizes not divisable by 8" {119test "vector casts of sizes not divisable by 8" {
...@@ -264,6 +265,7 @@ test "initialize vector which is a struct field" {...@@ -264,6 +265,7 @@ test "initialize vector which is a struct field" {
264 var foo = Vec4Obj{265 var foo = Vec4Obj{
265 .data = [_]f32{ 1, 2, 3, 4 },266 .data = [_]f32{ 1, 2, 3, 4 },
266 };267 };
268 _ = foo;
267 }269 }
268 };270 };
269 try S.doTheTest();271 try S.doTheTest();
test/behavior/void.zig+1-1
...@@ -36,5 +36,5 @@ test "void optional" {...@@ -36,5 +36,5 @@ test "void optional" {
3636
37test "void array as a local variable initializer" {37test "void array as a local variable initializer" {
38 var x = [_]void{{}} ** 1004;38 var x = [_]void{{}} ** 1004;
39 var y = x[0];39 _ = x[0];
40}40}
test/stage2/test.zig+1
...@@ -899,6 +899,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -899,6 +899,7 @@ pub fn addCases(ctx: *TestContext) !void {
899 \\ try expect(false);899 \\ try expect(false);
900 \\ }900 \\ }
901 \\ };901 \\ };
902 \\ _ = S;
902 \\}903 \\}
903 ,904 ,
904 &.{":4:13: error: invalid 'try' outside function scope"},905 &.{":4:13: error: invalid 'try' outside function scope"},
test/tests.zig-1
...@@ -525,7 +525,6 @@ pub fn addPkgTests(...@@ -525,7 +525,6 @@ pub fn addPkgTests(
525 if (skip_single_threaded and test_target.single_threaded)525 if (skip_single_threaded and test_target.single_threaded)
526 continue;526 continue;
527527
528 const ArchTag = std.meta.Tag(std.Target.Cpu.Arch);
529 if (test_target.disable_native and528 if (test_target.disable_native and
530 test_target.target.getOsTag() == std.Target.current.os.tag and529 test_target.target.getOsTag() == std.Target.current.os.tag and
531 test_target.target.getCpuArch() == std.Target.current.cpu.arch)530 test_target.target.getCpuArch() == std.Target.current.cpu.arch)