| author | |
| committer | |
| log | c6844072ce440f581787bf97909261084a9edc6c |
| tree | b0cade24a1ee14777be05644c19d76d158c3ab29 |
| parent | 8a6de78e0787015153707361a58659834d4c39c2 |
| parent | 7bebb24838a603a436b58e49ee85110af9e8e05f |
| signature |
stage2 astgen: catch unused vars226 files changed, 1412 insertions(+), 775 deletions(-)
doc/docgen.zig-12| ... | ... | @@ -1017,7 +1017,6 @@ fn tokenizeAndPrint(docgen_tokenizer: *Tokenizer, out: anytype, source_token: To |
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | 1019 | fn 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 | 1020 | var progress = Progress{}; |
| 1022 | 1021 | const root_node = try progress.start("Generating docgen examples", toc.nodes.len); |
| 1023 | 1022 | defer root_node.end(); |
| ... | ... | @@ -1090,7 +1089,6 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1090 | 1089 | |
| 1091 | 1090 | switch (code.id) { |
| 1092 | 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 | 1092 | var build_args = std.ArrayList([]const u8).init(allocator); |
| 1095 | 1093 | defer build_args.deinit(); |
| 1096 | 1094 | try build_args.appendSlice(&[_][]const u8{ |
| ... | ... | @@ -1361,19 +1359,9 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1361 | 1359 | }, |
| 1362 | 1360 | Code.Id.Obj => |maybe_error_match| { |
| 1363 | 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 | 1362 | var build_args = std.ArrayList([]const u8).init(allocator); |
| 1369 | 1363 | defer build_args.deinit(); |
| 1370 | 1364 | |
| 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 | 1365 | try build_args.appendSlice(&[_][]const u8{ |
| 1378 | 1366 | zig_exe, |
| 1379 | 1367 | "build-obj", |
lib/std/Progress.zig+1-1| ... | ... | @@ -295,7 +295,7 @@ fn refreshWithHeldLock(self: *Progress) void { |
| 295 | 295 | end += 1; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | _ = file.write(self.output_buffer[0..end]) catch |e| { | |
| 298 | _ = file.write(self.output_buffer[0..end]) catch { | |
| 299 | 299 | // Stop trying to write to this file once it errors. |
| 300 | 300 | self.terminal = null; |
| 301 | 301 | }; |
lib/std/SemanticVersion.zig+2-1| ... | ... | @@ -162,6 +162,7 @@ pub fn format( |
| 162 | 162 | options: std.fmt.FormatOptions, |
| 163 | 163 | out_stream: anytype, |
| 164 | 164 | ) !void { |
| 165 | _ = options; | |
| 165 | 166 | if (fmt.len != 0) @compileError("Unknown format string: '" ++ fmt ++ "'"); |
| 166 | 167 | try std.fmt.format(out_stream, "{d}.{d}.{d}", .{ self.major, self.minor, self.patch }); |
| 167 | 168 | if (self.pre) |pre| try std.fmt.format(out_stream, "-{s}", .{pre}); |
| ... | ... | @@ -259,7 +260,7 @@ test "SemanticVersion format" { |
| 259 | 260 | |
| 260 | 261 | // Invalid version string that may overflow. |
| 261 | 262 | const big_invalid = "99999999999999999999999.999999999999999999.99999999999999999----RC-SNAPSHOT.12.09.1--------------------------------..12"; |
| 262 | if (parse(big_invalid)) |ver| std.debug.panic("expected error, found {}", .{ver}) else |err| {} | |
| 263 | if (parse(big_invalid)) |ver| std.debug.panic("expected error, found {}", .{ver}) else |_| {} | |
| 263 | 264 | } |
| 264 | 265 | |
| 265 | 266 | test "SemanticVersion precedence" { |
lib/std/Thread.zig+2-2| ... | ... | @@ -518,8 +518,8 @@ pub fn cpuCount() CpuCountError!usize { |
| 518 | 518 | }, |
| 519 | 519 | .haiku => { |
| 520 | 520 | var count: u32 = undefined; |
| 521 | var system_info: os.system_info = undefined; | |
| 522 | const rc = os.system.get_system_info(&system_info); | |
| 521 | // var system_info: os.system_info = undefined; | |
| 522 | // const rc = os.system.get_system_info(&system_info); | |
| 523 | 523 | count = system_info.cpu_count; |
| 524 | 524 | return @intCast(usize, count); |
| 525 | 525 | }, |
lib/std/Thread/Condition.zig+8-2| ... | ... | @@ -40,12 +40,18 @@ else |
| 40 | 40 | |
| 41 | 41 | pub const SingleThreadedCondition = struct { |
| 42 | 42 | pub fn wait(cond: *SingleThreadedCondition, mutex: *Mutex) void { |
| 43 | _ = cond; | |
| 44 | _ = mutex; | |
| 43 | 45 | unreachable; // deadlock detected |
| 44 | 46 | } |
| 45 | 47 | |
| 46 | pub fn signal(cond: *SingleThreadedCondition) void {} | |
| 48 | pub fn signal(cond: *SingleThreadedCondition) void { | |
| 49 | _ = cond; | |
| 50 | } | |
| 47 | 51 | |
| 48 | pub fn broadcast(cond: *SingleThreadedCondition) void {} | |
| 52 | pub fn broadcast(cond: *SingleThreadedCondition) void { | |
| 53 | _ = cond; | |
| 54 | } | |
| 49 | 55 | }; |
| 50 | 56 | |
| 51 | 57 | pub const WindowsCondition = struct { |
lib/std/Thread/StaticResetEvent.zig+6-1| ... | ... | @@ -105,6 +105,7 @@ pub const DebugEvent = struct { |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | pub fn timedWait(ev: *DebugEvent, timeout: u64) TimedWaitResult { |
| 108 | _ = timeout; | |
| 108 | 109 | switch (ev.state) { |
| 109 | 110 | .unset => return .timed_out, |
| 110 | 111 | .set => return .event_set, |
| ... | ... | @@ -174,7 +175,10 @@ pub const AtomicEvent = struct { |
| 174 | 175 | }; |
| 175 | 176 | |
| 176 | 177 | pub const SpinFutex = struct { |
| 177 | fn wake(waiters: *u32, wake_count: u32) void {} | |
| 178 | fn wake(waiters: *u32, wake_count: u32) void { | |
| 179 | _ = waiters; | |
| 180 | _ = wake_count; | |
| 181 | } | |
| 178 | 182 | |
| 179 | 183 | fn wait(waiters: *u32, timeout: ?u64) !void { |
| 180 | 184 | var timer: time.Timer = undefined; |
| ... | ... | @@ -193,6 +197,7 @@ pub const AtomicEvent = struct { |
| 193 | 197 | |
| 194 | 198 | pub const LinuxFutex = struct { |
| 195 | 199 | fn wake(waiters: *u32, wake_count: u32) void { |
| 200 | _ = wake_count; | |
| 196 | 201 | const waiting = std.math.maxInt(i32); // wake_count |
| 197 | 202 | const ptr = @ptrCast(*const i32, waiters); |
| 198 | 203 | const rc = linux.futex_wake(ptr, linux.FUTEX_WAKE | linux.FUTEX_PRIVATE_FLAG, waiting); |
lib/std/array_hash_map.zig+16-9| ... | ... | @@ -40,9 +40,11 @@ pub fn StringArrayHashMapUnmanaged(comptime V: type) type { |
| 40 | 40 | |
| 41 | 41 | pub const StringContext = struct { |
| 42 | 42 | pub fn hash(self: @This(), s: []const u8) u32 { |
| 43 | _ = self; | |
| 43 | 44 | return hashString(s); |
| 44 | 45 | } |
| 45 | 46 | pub fn eql(self: @This(), a: []const u8, b: []const u8) bool { |
| 47 | _ = self; | |
| 46 | 48 | return eqlString(a, b); |
| 47 | 49 | } |
| 48 | 50 | }; |
| ... | ... | @@ -1324,17 +1326,17 @@ pub fn ArrayHashMapUnmanaged( |
| 1324 | 1326 | } |
| 1325 | 1327 | fn removeFromIndexByIndexGeneric(self: *Self, entry_index: usize, ctx: ByIndexContext, header: *IndexHeader, comptime I: type, indexes: []Index(I)) void { |
| 1326 | 1328 | const slot = self.getSlotByIndex(entry_index, ctx, header, I, indexes); |
| 1327 | self.removeSlot(slot, header, I, indexes); | |
| 1329 | removeSlot(slot, header, I, indexes); | |
| 1328 | 1330 | } |
| 1329 | 1331 | |
| 1330 | 1332 | fn removeFromIndexByKey(self: *Self, key: anytype, ctx: anytype, header: *IndexHeader, comptime I: type, indexes: []Index(I)) ?usize { |
| 1331 | 1333 | const slot = self.getSlotByKey(key, ctx, header, I, indexes) orelse return null; |
| 1332 | 1334 | const removed_entry_index = indexes[slot].entry_index; |
| 1333 | self.removeSlot(slot, header, I, indexes); | |
| 1335 | removeSlot(slot, header, I, indexes); | |
| 1334 | 1336 | return removed_entry_index; |
| 1335 | 1337 | } |
| 1336 | 1338 | |
| 1337 | fn removeSlot(self: *Self, removed_slot: usize, header: *IndexHeader, comptime I: type, indexes: []Index(I)) void { | |
| 1339 | fn removeSlot(removed_slot: usize, header: *IndexHeader, comptime I: type, indexes: []Index(I)) void { | |
| 1338 | 1340 | const start_index = removed_slot +% 1; |
| 1339 | 1341 | const end_index = start_index +% indexes.len; |
| 1340 | 1342 | |
| ... | ... | @@ -1619,13 +1621,13 @@ pub fn ArrayHashMapUnmanaged( |
| 1619 | 1621 | if (self.index_header) |header| { |
| 1620 | 1622 | p("\n", .{}); |
| 1621 | 1623 | switch (header.capacityIndexType()) { |
| 1622 | .u8 => self.dumpIndex(header, u8), | |
| 1623 | .u16 => self.dumpIndex(header, u16), | |
| 1624 | .u32 => self.dumpIndex(header, u32), | |
| 1624 | .u8 => dumpIndex(header, u8), | |
| 1625 | .u16 => dumpIndex(header, u16), | |
| 1626 | .u32 => dumpIndex(header, u32), | |
| 1625 | 1627 | } |
| 1626 | 1628 | } |
| 1627 | 1629 | } |
| 1628 | fn dumpIndex(self: Self, header: *IndexHeader, comptime I: type) void { | |
| 1630 | fn dumpIndex(header: *IndexHeader, comptime I: type) void { | |
| 1629 | 1631 | const p = std.debug.print; |
| 1630 | 1632 | p(" index len=0x{x} type={}\n", .{ header.length(), header.capacityIndexType() }); |
| 1631 | 1633 | const indexes = header.indexes(I); |
| ... | ... | @@ -1918,7 +1920,7 @@ test "iterator hash map" { |
| 1918 | 1920 | try testing.expect(count == 3); |
| 1919 | 1921 | try testing.expect(it.next() == null); |
| 1920 | 1922 | |
| 1921 | for (buffer) |v, i| { | |
| 1923 | for (buffer) |_, i| { | |
| 1922 | 1924 | try testing.expect(buffer[@intCast(usize, keys[i])] == values[i]); |
| 1923 | 1925 | } |
| 1924 | 1926 | |
| ... | ... | @@ -1930,7 +1932,7 @@ test "iterator hash map" { |
| 1930 | 1932 | if (count >= 2) break; |
| 1931 | 1933 | } |
| 1932 | 1934 | |
| 1933 | for (buffer[0..2]) |v, i| { | |
| 1935 | for (buffer[0..2]) |_, i| { | |
| 1934 | 1936 | try testing.expect(buffer[@intCast(usize, keys[i])] == values[i]); |
| 1935 | 1937 | } |
| 1936 | 1938 | |
| ... | ... | @@ -2154,6 +2156,7 @@ test "compile everything" { |
| 2154 | 2156 | pub fn getHashPtrAddrFn(comptime K: type, comptime Context: type) (fn (Context, K) u32) { |
| 2155 | 2157 | return struct { |
| 2156 | 2158 | fn hash(ctx: Context, key: K) u32 { |
| 2159 | _ = ctx; | |
| 2157 | 2160 | return getAutoHashFn(usize, void)({}, @ptrToInt(key)); |
| 2158 | 2161 | } |
| 2159 | 2162 | }.hash; |
| ... | ... | @@ -2162,6 +2165,7 @@ pub fn getHashPtrAddrFn(comptime K: type, comptime Context: type) (fn (Context, |
| 2162 | 2165 | pub fn getTrivialEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K) bool) { |
| 2163 | 2166 | return struct { |
| 2164 | 2167 | fn eql(ctx: Context, a: K, b: K) bool { |
| 2168 | _ = ctx; | |
| 2165 | 2169 | return a == b; |
| 2166 | 2170 | } |
| 2167 | 2171 | }.eql; |
| ... | ... | @@ -2177,6 +2181,7 @@ pub fn AutoContext(comptime K: type) type { |
| 2177 | 2181 | pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K) u32) { |
| 2178 | 2182 | return struct { |
| 2179 | 2183 | fn hash(ctx: Context, key: K) u32 { |
| 2184 | _ = ctx; | |
| 2180 | 2185 | if (comptime trait.hasUniqueRepresentation(K)) { |
| 2181 | 2186 | return @truncate(u32, Wyhash.hash(0, std.mem.asBytes(&key))); |
| 2182 | 2187 | } else { |
| ... | ... | @@ -2191,6 +2196,7 @@ pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K) |
| 2191 | 2196 | pub fn getAutoEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K) bool) { |
| 2192 | 2197 | return struct { |
| 2193 | 2198 | fn eql(ctx: Context, a: K, b: K) bool { |
| 2199 | _ = ctx; | |
| 2194 | 2200 | return meta.eql(a, b); |
| 2195 | 2201 | } |
| 2196 | 2202 | }.eql; |
| ... | ... | @@ -2217,6 +2223,7 @@ pub fn autoEqlIsCheap(comptime K: type) bool { |
| 2217 | 2223 | pub fn getAutoHashStratFn(comptime K: type, comptime Context: type, comptime strategy: std.hash.Strategy) (fn (Context, K) u32) { |
| 2218 | 2224 | return struct { |
| 2219 | 2225 | fn hash(ctx: Context, key: K) u32 { |
| 2226 | _ = ctx; | |
| 2220 | 2227 | var hasher = Wyhash.init(0); |
| 2221 | 2228 | std.hash.autoHashStrat(&hasher, key, strategy); |
| 2222 | 2229 | return @truncate(u32, hasher.final()); |
lib/std/atomic/Atomic.zig+2| ... | ... | @@ -232,6 +232,7 @@ test "Atomic.loadUnchecked" { |
| 232 | 232 | |
| 233 | 233 | test "Atomic.storeUnchecked" { |
| 234 | 234 | inline for (atomicIntTypes()) |Int| { |
| 235 | _ = Int; | |
| 235 | 236 | var x = Atomic(usize).init(5); |
| 236 | 237 | x.storeUnchecked(10); |
| 237 | 238 | try testing.expectEqual(x.loadUnchecked(), 10); |
| ... | ... | @@ -250,6 +251,7 @@ test "Atomic.load" { |
| 250 | 251 | test "Atomic.store" { |
| 251 | 252 | inline for (atomicIntTypes()) |Int| { |
| 252 | 253 | inline for (.{ .Unordered, .Monotonic, .Release, .SeqCst }) |ordering| { |
| 254 | _ = Int; | |
| 253 | 255 | var x = Atomic(usize).init(5); |
| 254 | 256 | x.store(10, ordering); |
| 255 | 257 | try testing.expectEqual(x.load(.SeqCst), 10); |
lib/std/base64.zig-5| ... | ... | @@ -112,9 +112,6 @@ pub const Base64Encoder = struct { |
| 112 | 112 | const out_len = encoder.calcSize(source.len); |
| 113 | 113 | assert(dest.len >= out_len); |
| 114 | 114 | |
| 115 | const nibbles = source.len / 3; | |
| 116 | const leftover = source.len - 3 * nibbles; | |
| 117 | ||
| 118 | 115 | var acc: u12 = 0; |
| 119 | 116 | var acc_len: u4 = 0; |
| 120 | 117 | var out_idx: usize = 0; |
| ... | ... | @@ -223,7 +220,6 @@ pub const Base64Decoder = struct { |
| 223 | 220 | if (decoder.pad_char) |pad_char| { |
| 224 | 221 | const padding_len = acc_len / 2; |
| 225 | 222 | var padding_chars: usize = 0; |
| 226 | var i: usize = 0; | |
| 227 | 223 | for (leftover) |c| { |
| 228 | 224 | if (c != pad_char) { |
| 229 | 225 | return if (c == Base64Decoder.invalid_char) error.InvalidCharacter else error.InvalidPadding; |
| ... | ... | @@ -302,7 +298,6 @@ pub const Base64DecoderWithIgnore = struct { |
| 302 | 298 | var leftover = source[leftover_idx.?..]; |
| 303 | 299 | if (decoder.pad_char) |pad_char| { |
| 304 | 300 | var padding_chars: usize = 0; |
| 305 | var i: usize = 0; | |
| 306 | 301 | for (leftover) |c| { |
| 307 | 302 | if (decoder_with_ignore.char_is_ignored[c]) continue; |
| 308 | 303 | if (c != pad_char) { |
lib/std/bit_set.zig+4-2| ... | ... | @@ -84,6 +84,7 @@ pub fn IntegerBitSet(comptime size: u16) type { |
| 84 | 84 | |
| 85 | 85 | /// Returns the number of bits in this bit set |
| 86 | 86 | pub inline fn capacity(self: Self) usize { |
| 87 | _ = self; | |
| 87 | 88 | return bit_length; |
| 88 | 89 | } |
| 89 | 90 | |
| ... | ... | @@ -311,6 +312,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type { |
| 311 | 312 | |
| 312 | 313 | /// Returns the number of bits in this bit set |
| 313 | 314 | pub inline fn capacity(self: Self) usize { |
| 315 | _ = self; | |
| 314 | 316 | return bit_length; |
| 315 | 317 | } |
| 316 | 318 | |
| ... | ... | @@ -373,7 +375,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type { |
| 373 | 375 | |
| 374 | 376 | /// Flips every bit in the bit set. |
| 375 | 377 | pub fn toggleAll(self: *Self) void { |
| 376 | for (self.masks) |*mask, i| { | |
| 378 | for (self.masks) |*mask| { | |
| 377 | 379 | mask.* = ~mask.*; |
| 378 | 380 | } |
| 379 | 381 | |
| ... | ... | @@ -642,7 +644,7 @@ pub const DynamicBitSetUnmanaged = struct { |
| 642 | 644 | if (bit_length == 0) return; |
| 643 | 645 | |
| 644 | 646 | const num_masks = numMasks(self.bit_length); |
| 645 | for (self.masks[0..num_masks]) |*mask, i| { | |
| 647 | for (self.masks[0..num_masks]) |*mask| { | |
| 646 | 648 | mask.* = ~mask.*; |
| 647 | 649 | } |
| 648 | 650 |
lib/std/build.zig+5-2| ... | ... | @@ -390,6 +390,7 @@ pub const Builder = struct { |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | pub fn version(self: *const Builder, major: u32, minor: u32, patch: u32) LibExeObjStep.SharedLibKind { |
| 393 | _ = self; | |
| 393 | 394 | return .{ |
| 394 | 395 | .versioned = .{ |
| 395 | 396 | .major = major, |
| ... | ... | @@ -543,7 +544,7 @@ pub const Builder = struct { |
| 543 | 544 | return null; |
| 544 | 545 | }, |
| 545 | 546 | .scalar => |s| { |
| 546 | const n = std.fmt.parseFloat(T, s) catch |err| { | |
| 547 | const n = std.fmt.parseFloat(T, s) catch { | |
| 547 | 548 | warn("Expected -D{s} to be a float of type {s}.\n\n", .{ name, @typeName(T) }); |
| 548 | 549 | self.markInvalidUserInput(); |
| 549 | 550 | return null; |
| ... | ... | @@ -3129,7 +3130,9 @@ pub const Step = struct { |
| 3129 | 3130 | self.dependencies.append(other) catch unreachable; |
| 3130 | 3131 | } |
| 3131 | 3132 | |
| 3132 | fn makeNoOp(self: *Step) anyerror!void {} | |
| 3133 | fn makeNoOp(self: *Step) anyerror!void { | |
| 3134 | _ = self; | |
| 3135 | } | |
| 3133 | 3136 | |
| 3134 | 3137 | pub fn cast(step: *Step, comptime T: type) ?*T { |
| 3135 | 3138 | if (step.id == T.base_id) { |
lib/std/build/InstallRawStep.zig+2| ... | ... | @@ -139,6 +139,7 @@ const BinaryElfOutput = struct { |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | fn segmentSortCompare(context: void, left: *BinaryElfSegment, right: *BinaryElfSegment) bool { |
| 142 | _ = context; | |
| 142 | 143 | if (left.physicalAddress < right.physicalAddress) { |
| 143 | 144 | return true; |
| 144 | 145 | } |
| ... | ... | @@ -149,6 +150,7 @@ const BinaryElfOutput = struct { |
| 149 | 150 | } |
| 150 | 151 | |
| 151 | 152 | fn sectionSortCompare(context: void, left: *BinaryElfSection, right: *BinaryElfSection) bool { |
| 153 | _ = context; | |
| 152 | 154 | return left.binaryOffset < right.binaryOffset; |
| 153 | 155 | } |
| 154 | 156 | }; |
lib/std/builtin.zig+3| ... | ... | @@ -65,6 +65,8 @@ pub const StackTrace = struct { |
| 65 | 65 | options: std.fmt.FormatOptions, |
| 66 | 66 | writer: anytype, |
| 67 | 67 | ) !void { |
| 68 | _ = fmt; | |
| 69 | _ = options; | |
| 68 | 70 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 69 | 71 | defer arena.deinit(); |
| 70 | 72 | const debug_info = std.debug.getSelfDebugInfo() catch |err| { |
| ... | ... | @@ -521,6 +523,7 @@ pub const Version = struct { |
| 521 | 523 | options: std.fmt.FormatOptions, |
| 522 | 524 | out_stream: anytype, |
| 523 | 525 | ) !void { |
| 526 | _ = options; | |
| 524 | 527 | if (fmt.len == 0) { |
| 525 | 528 | if (self.patch == 0) { |
| 526 | 529 | if (self.minor == 0) { |
lib/std/c/tokenizer.zig+6-7| ... | ... | @@ -351,7 +351,6 @@ pub const Tokenizer = struct { |
| 351 | 351 | pp_directive: bool = false, |
| 352 | 352 | |
| 353 | 353 | pub fn next(self: *Tokenizer) Token { |
| 354 | const start_index = self.index; | |
| 355 | 354 | var result = Token{ |
| 356 | 355 | .id = .Eof, |
| 357 | 356 | .start = self.index, |
| ... | ... | @@ -1380,12 +1379,12 @@ test "operators" { |
| 1380 | 1379 | |
| 1381 | 1380 | test "keywords" { |
| 1382 | 1381 | try expectTokens( |
| 1383 | \\auto break case char const continue default do | |
| 1384 | \\double else enum extern float for goto if int | |
| 1385 | \\long register return short signed sizeof static | |
| 1386 | \\struct switch typedef union unsigned void volatile | |
| 1387 | \\while _Bool _Complex _Imaginary inline restrict _Alignas | |
| 1388 | \\_Alignof _Atomic _Generic _Noreturn _Static_assert _Thread_local | |
| 1382 | \\auto break case char const continue default do | |
| 1383 | \\double else enum extern float for goto if int | |
| 1384 | \\long register return short signed sizeof static | |
| 1385 | \\struct switch typedef union unsigned void volatile | |
| 1386 | \\while _Bool _Complex _Imaginary inline restrict _Alignas | |
| 1387 | \\_Alignof _Atomic _Generic _Noreturn _Static_assert _Thread_local | |
| 1389 | 1388 | \\ |
| 1390 | 1389 | , &[_]Token.Id{ |
| 1391 | 1390 | .Keyword_auto, |
lib/std/compress/gzip.zig+2| ... | ... | @@ -62,6 +62,8 @@ pub fn GzipStream(comptime ReaderType: type) type { |
| 62 | 62 | const XFL = header[8]; |
| 63 | 63 | // Operating system where the compression took place |
| 64 | 64 | const OS = header[9]; |
| 65 | _ = XFL; | |
| 66 | _ = OS; | |
| 65 | 67 | |
| 66 | 68 | if (FLG & FEXTRA != 0) { |
| 67 | 69 | // 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 | 35 | const CM = @truncate(u4, header[0]); |
| 36 | 36 | const CINFO = @truncate(u4, header[0] >> 4); |
| 37 | 37 | const FCHECK = @truncate(u5, header[1]); |
| 38 | _ = FCHECK; | |
| 38 | 39 | const FDICT = @truncate(u1, header[1] >> 5); |
| 39 | 40 | |
| 40 | 41 | if ((@as(u16, header[0]) << 8 | header[1]) % 31 != 0) |
lib/std/comptime_string_map.zig+1| ... | ... | @@ -23,6 +23,7 @@ pub fn ComptimeStringMap(comptime V: type, comptime kvs: anytype) type { |
| 23 | 23 | var sorted_kvs: [kvs.len]KV = undefined; |
| 24 | 24 | const lenAsc = (struct { |
| 25 | 25 | fn lenAsc(context: void, a: KV, b: KV) bool { |
| 26 | _ = context; | |
| 26 | 27 | return a.key.len < b.key.len; |
| 27 | 28 | } |
| 28 | 29 | }).lenAsc; |
lib/std/crypto/25519/ed25519.zig+1-1| ... | ... | @@ -346,7 +346,7 @@ test "ed25519 test vectors" { |
| 346 | 346 | .expected = error.IdentityElement, // 11 - small-order A |
| 347 | 347 | }, |
| 348 | 348 | }; |
| 349 | for (entries) |entry, i| { | |
| 349 | for (entries) |entry| { | |
| 350 | 350 | var msg: [entry.msg_hex.len / 2]u8 = undefined; |
| 351 | 351 | _ = try fmt.hexToBytes(&msg, entry.msg_hex); |
| 352 | 352 | var public_key: [32]u8 = undefined; |
lib/std/crypto/25519/scalar.zig-6| ... | ... | @@ -330,13 +330,10 @@ pub const Scalar = struct { |
| 330 | 330 | const carry9 = z02 >> 56; |
| 331 | 331 | const c01 = carry9; |
| 332 | 332 | const carry10 = (z12 + c01) >> 56; |
| 333 | const t21 = @truncate(u64, z12 + c01) & 0xffffffffffffff; | |
| 334 | 333 | const c11 = carry10; |
| 335 | 334 | const carry11 = (z22 + c11) >> 56; |
| 336 | const t22 = @truncate(u64, z22 + c11) & 0xffffffffffffff; | |
| 337 | 335 | const c21 = carry11; |
| 338 | 336 | const carry12 = (z32 + c21) >> 56; |
| 339 | const t23 = @truncate(u64, z32 + c21) & 0xffffffffffffff; | |
| 340 | 337 | const c31 = carry12; |
| 341 | 338 | const carry13 = (z42 + c31) >> 56; |
| 342 | 339 | const t24 = @truncate(u64, z42 + c31) & 0xffffffffffffff; |
| ... | ... | @@ -605,13 +602,10 @@ const ScalarDouble = struct { |
| 605 | 602 | const carry0 = z01 >> 56; |
| 606 | 603 | const c00 = carry0; |
| 607 | 604 | const carry1 = (z11 + c00) >> 56; |
| 608 | const t100 = @as(u64, @truncate(u64, z11 + c00)) & 0xffffffffffffff; | |
| 609 | 605 | const c10 = carry1; |
| 610 | 606 | const carry2 = (z21 + c10) >> 56; |
| 611 | const t101 = @as(u64, @truncate(u64, z21 + c10)) & 0xffffffffffffff; | |
| 612 | 607 | const c20 = carry2; |
| 613 | 608 | const carry3 = (z31 + c20) >> 56; |
| 614 | const t102 = @as(u64, @truncate(u64, z31 + c20)) & 0xffffffffffffff; | |
| 615 | 609 | const c30 = carry3; |
| 616 | 610 | const carry4 = (z41 + c30) >> 56; |
| 617 | 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 | 49 | |
| 50 | 50 | /// Encrypt a block with a round key. |
| 51 | 51 | pub inline fn encrypt(block: Block, round_key: Block) Block { |
| 52 | const src = &block.repr; | |
| 53 | ||
| 54 | 52 | const s0 = block.repr[0]; |
| 55 | 53 | const s1 = block.repr[1]; |
| 56 | 54 | const s2 = block.repr[2]; |
| ... | ... | @@ -66,8 +64,6 @@ pub const Block = struct { |
| 66 | 64 | |
| 67 | 65 | /// Encrypt a block with the last round key. |
| 68 | 66 | pub inline fn encryptLast(block: Block, round_key: Block) Block { |
| 69 | const src = &block.repr; | |
| 70 | ||
| 71 | 67 | const t0 = block.repr[0]; |
| 72 | 68 | const t1 = block.repr[1]; |
| 73 | 69 | const t2 = block.repr[2]; |
| ... | ... | @@ -88,8 +84,6 @@ pub const Block = struct { |
| 88 | 84 | |
| 89 | 85 | /// Decrypt a block with a round key. |
| 90 | 86 | pub inline fn decrypt(block: Block, round_key: Block) Block { |
| 91 | const src = &block.repr; | |
| 92 | ||
| 93 | 87 | const s0 = block.repr[0]; |
| 94 | 88 | const s1 = block.repr[1]; |
| 95 | 89 | const s2 = block.repr[2]; |
| ... | ... | @@ -105,8 +99,6 @@ pub const Block = struct { |
| 105 | 99 | |
| 106 | 100 | /// Decrypt a block with the last round key. |
| 107 | 101 | pub inline fn decryptLast(block: Block, round_key: Block) Block { |
| 108 | const src = &block.repr; | |
| 109 | ||
| 110 | 102 | const t0 = block.repr[0]; |
| 111 | 103 | const t1 = block.repr[1]; |
| 112 | 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 | 114 | const ad = ""; |
| 115 | 115 | const m = ""; |
| 116 | 116 | var c: [m.len]u8 = undefined; |
| 117 | var m2: [m.len]u8 = undefined; | |
| 118 | 117 | var tag: [Aes256Gcm.tag_length]u8 = undefined; |
| 119 | 118 | |
| 120 | 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 | 271 | var c: [0]u8 = undefined; |
| 272 | 272 | Aes128Ocb.encrypt(&c, &tag, "", "", nonce, k); |
| 273 | 273 | |
| 274 | var expected_c: [c.len]u8 = undefined; | |
| 275 | 274 | var expected_tag: [tag.len]u8 = undefined; |
| 276 | 275 | _ = try hexToBytes(&expected_tag, "785407BFFFC8AD9EDCC5520AC9111EE6"); |
| 277 | 276 |
lib/std/crypto/bcrypt.zig-2| ... | ... | @@ -48,7 +48,6 @@ const State = struct { |
| 48 | 48 | fn expand0(state: *State, key: []const u8) void { |
| 49 | 49 | var i: usize = 0; |
| 50 | 50 | var j: usize = 0; |
| 51 | var t: u32 = undefined; | |
| 52 | 51 | while (i < state.subkeys.len) : (i += 1) { |
| 53 | 52 | state.subkeys[i] ^= toWord(key, &j); |
| 54 | 53 | } |
| ... | ... | @@ -75,7 +74,6 @@ const State = struct { |
| 75 | 74 | fn expand(state: *State, data: []const u8, key: []const u8) void { |
| 76 | 75 | var i: usize = 0; |
| 77 | 76 | var j: usize = 0; |
| 78 | var t: u32 = undefined; | |
| 79 | 77 | while (i < state.subkeys.len) : (i += 1) { |
| 80 | 78 | state.subkeys[i] ^= toWord(key, &j); |
| 81 | 79 | } |
lib/std/crypto/blake3.zig+1| ... | ... | @@ -394,6 +394,7 @@ pub const Blake3 = struct { |
| 394 | 394 | /// Construct a new `Blake3` for the key derivation function. The context |
| 395 | 395 | /// string should be hardcoded, globally unique, and application-specific. |
| 396 | 396 | pub fn initKdf(context: []const u8, options: KdfOptions) Blake3 { |
| 397 | _ = options; | |
| 397 | 398 | var context_hasher = Blake3.init_internal(IV, DERIVE_KEY_CONTEXT); |
| 398 | 399 | context_hasher.update(context); |
| 399 | 400 | var context_key: [KEY_LEN]u8 = undefined; |
lib/std/crypto/chacha20.zig-1| ... | ... | @@ -444,7 +444,6 @@ fn ChaChaWith64BitNonce(comptime rounds_nb: usize) type { |
| 444 | 444 | if (comptime @sizeOf(usize) > 4) { |
| 445 | 445 | // A big block is giant: 256 GiB, but we can avoid this limitation |
| 446 | 446 | var remaining_blocks: u32 = @intCast(u32, (in.len / big_block)); |
| 447 | var i: u32 = 0; | |
| 448 | 447 | while (remaining_blocks > 0) : (remaining_blocks -= 1) { |
| 449 | 448 | ChaChaImpl(rounds_nb).chacha20Xor(out[cursor .. cursor + big_block], in[cursor .. cursor + big_block], k, c); |
| 450 | 449 | c[1] += 1; // upper 32-bit of counter, generic chacha20Xor() doesn't know about this. |
lib/std/crypto/gimli.zig+1| ... | ... | @@ -219,6 +219,7 @@ pub const Hash = struct { |
| 219 | 219 | const Self = @This(); |
| 220 | 220 | |
| 221 | 221 | pub fn init(options: Options) Self { |
| 222 | _ = options; | |
| 222 | 223 | return Self{ |
| 223 | 224 | .state = State{ .data = [_]u32{0} ** (State.BLOCKBYTES / 4) }, |
| 224 | 225 | .buf_off = 0, |
lib/std/crypto/md5.zig+1| ... | ... | @@ -45,6 +45,7 @@ pub const Md5 = struct { |
| 45 | 45 | total_len: u64, |
| 46 | 46 | |
| 47 | 47 | pub fn init(options: Options) Self { |
| 48 | _ = options; | |
| 48 | 49 | return Self{ |
| 49 | 50 | .s = [_]u32{ |
| 50 | 51 | 0x67452301, |
lib/std/crypto/pcurves/p256/scalar.zig+1-1| ... | ... | @@ -63,7 +63,7 @@ pub fn add(a: CompressedScalar, b: CompressedScalar, endian: builtin.Endian) Non |
| 63 | 63 | |
| 64 | 64 | /// Return -s (mod L) |
| 65 | 65 | pub fn neg(s: CompressedScalar, endian: builtin.Endian) NonCanonicalError!CompressedScalar { |
| 66 | return (try Scalar.fromBytes(a, endian)).neg().toBytes(endian); | |
| 66 | return (try Scalar.fromBytes(s, endian)).neg().toBytes(endian); | |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /// Return (a-b) (mod L) |
lib/std/crypto/sha1.zig+1| ... | ... | @@ -43,6 +43,7 @@ pub const Sha1 = struct { |
| 43 | 43 | total_len: u64 = 0, |
| 44 | 44 | |
| 45 | 45 | pub fn init(options: Options) Self { |
| 46 | _ = options; | |
| 46 | 47 | return Self{ |
| 47 | 48 | .s = [_]u32{ |
| 48 | 49 | 0x67452301, |
lib/std/crypto/sha2.zig+2| ... | ... | @@ -95,6 +95,7 @@ fn Sha2x32(comptime params: Sha2Params32) type { |
| 95 | 95 | total_len: u64 = 0, |
| 96 | 96 | |
| 97 | 97 | pub fn init(options: Options) Self { |
| 98 | _ = options; | |
| 98 | 99 | return Self{ |
| 99 | 100 | .s = [_]u32{ |
| 100 | 101 | params.iv0, |
| ... | ... | @@ -462,6 +463,7 @@ fn Sha2x64(comptime params: Sha2Params64) type { |
| 462 | 463 | total_len: u128 = 0, |
| 463 | 464 | |
| 464 | 465 | pub fn init(options: Options) Self { |
| 466 | _ = options; | |
| 465 | 467 | return Self{ |
| 466 | 468 | .s = [_]u64{ |
| 467 | 469 | params.iv0, |
lib/std/crypto/sha3.zig+1| ... | ... | @@ -28,6 +28,7 @@ fn Keccak(comptime bits: usize, comptime delim: u8) type { |
| 28 | 28 | rate: usize, |
| 29 | 29 | |
| 30 | 30 | pub fn init(options: Options) Self { |
| 31 | _ = options; | |
| 31 | 32 | return Self{ .s = [_]u8{0} ** 200, .offset = 0, .rate = 200 - (bits / 4) }; |
| 32 | 33 | } |
| 33 | 34 |
lib/std/crypto/tlcsprng.zig+1-1| ... | ... | @@ -84,7 +84,7 @@ fn tlsCsprngFill(_: *const std.rand.Random, buffer: []u8) void { |
| 84 | 84 | os.MAP_PRIVATE | os.MAP_ANONYMOUS, |
| 85 | 85 | -1, |
| 86 | 86 | 0, |
| 87 | ) catch |err| { | |
| 87 | ) catch { | |
| 88 | 88 | // Could not allocate memory for the local state, fall back to |
| 89 | 89 | // the OS syscall. |
| 90 | 90 | return fillWithOsEntropy(buffer); |
lib/std/debug.zig+6-1| ... | ... | @@ -325,6 +325,7 @@ pub fn writeStackTrace( |
| 325 | 325 | debug_info: *DebugInfo, |
| 326 | 326 | tty_config: TTY.Config, |
| 327 | 327 | ) !void { |
| 328 | _ = allocator; | |
| 328 | 329 | if (builtin.strip_debug_info) return error.MissingDebugInfo; |
| 329 | 330 | var frame_index: usize = 0; |
| 330 | 331 | var frames_left: usize = std.math.min(stack_trace.index, stack_trace.instruction_addresses.len); |
| ... | ... | @@ -680,6 +681,7 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf |
| 680 | 681 | try di.coff.loadSections(); |
| 681 | 682 | if (di.coff.getSection(".debug_info")) |sec| { |
| 682 | 683 | // This coff file has embedded DWARF debug info |
| 684 | _ = sec; | |
| 683 | 685 | // TODO: free the section data slices |
| 684 | 686 | const debug_info_data = di.coff.getSectionData(".debug_info", allocator) catch null; |
| 685 | 687 | const debug_abbrev_data = di.coff.getSectionData(".debug_abbrev", allocator) catch null; |
| ... | ... | @@ -896,7 +898,6 @@ fn printLineFromFileAnyOs(out_stream: anytype, line_info: LineInfo) !void { |
| 896 | 898 | var buf: [mem.page_size]u8 = undefined; |
| 897 | 899 | var line: usize = 1; |
| 898 | 900 | var column: usize = 1; |
| 899 | var abs_index: usize = 0; | |
| 900 | 901 | while (true) { |
| 901 | 902 | const amt_read = try f.read(buf[0..]); |
| 902 | 903 | const slice = buf[0..amt_read]; |
| ... | ... | @@ -931,6 +932,7 @@ const MachoSymbol = struct { |
| 931 | 932 | } |
| 932 | 933 | |
| 933 | 934 | fn addressLessThan(context: void, lhs: MachoSymbol, rhs: MachoSymbol) bool { |
| 935 | _ = context; | |
| 934 | 936 | return lhs.address() < rhs.address(); |
| 935 | 937 | } |
| 936 | 938 | }; |
| ... | ... | @@ -1135,6 +1137,7 @@ pub const DebugInfo = struct { |
| 1135 | 1137 | |
| 1136 | 1138 | if (os.dl_iterate_phdr(&ctx, anyerror, struct { |
| 1137 | 1139 | fn callback(info: *os.dl_phdr_info, size: usize, context: *CtxTy) !void { |
| 1140 | _ = size; | |
| 1138 | 1141 | // The base address is too high |
| 1139 | 1142 | if (context.address < info.dlpi_addr) |
| 1140 | 1143 | return; |
| ... | ... | @@ -1190,6 +1193,8 @@ pub const DebugInfo = struct { |
| 1190 | 1193 | } |
| 1191 | 1194 | |
| 1192 | 1195 | fn lookupModuleHaiku(self: *DebugInfo, address: usize) !*ModuleDebugInfo { |
| 1196 | _ = self; | |
| 1197 | _ = address; | |
| 1193 | 1198 | @panic("TODO implement lookup module for Haiku"); |
| 1194 | 1199 | } |
| 1195 | 1200 | }; |
lib/std/dwarf.zig+4-2| ... | ... | @@ -283,6 +283,7 @@ fn parseFormValueBlock(allocator: *mem.Allocator, in_stream: anytype, endian: bu |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: anytype, signed: bool, endian: builtin.Endian, comptime size: i32) !FormValue { |
| 286 | _ = allocator; | |
| 286 | 287 | // TODO: Please forgive me, I've worked around zig not properly spilling some intermediate values here. |
| 287 | 288 | // `nosuspend` should be removed from all the function calls once it is fixed. |
| 288 | 289 | return FormValue{ |
| ... | ... | @@ -310,6 +311,7 @@ fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: anytype, signed: |
| 310 | 311 | |
| 311 | 312 | // TODO the nosuspends here are workarounds |
| 312 | 313 | fn parseFormValueRef(allocator: *mem.Allocator, in_stream: anytype, endian: builtin.Endian, size: i32) !FormValue { |
| 314 | _ = allocator; | |
| 313 | 315 | return FormValue{ |
| 314 | 316 | .Ref = switch (size) { |
| 315 | 317 | 1 => try nosuspend in_stream.readInt(u8, endian), |
| ... | ... | @@ -453,13 +455,13 @@ pub const DwarfInfo = struct { |
| 453 | 455 | if (this_die_obj.getAttr(AT_name)) |_| { |
| 454 | 456 | const name = try this_die_obj.getAttrString(di, AT_name); |
| 455 | 457 | break :x name; |
| 456 | } else if (this_die_obj.getAttr(AT_abstract_origin)) |ref| { | |
| 458 | } else if (this_die_obj.getAttr(AT_abstract_origin)) |_| { | |
| 457 | 459 | // Follow the DIE it points to and repeat |
| 458 | 460 | const ref_offset = try this_die_obj.getAttrRef(AT_abstract_origin); |
| 459 | 461 | if (ref_offset > next_offset) return error.InvalidDebugInfo; |
| 460 | 462 | try seekable.seekTo(this_unit_offset + ref_offset); |
| 461 | 463 | this_die_obj = (try di.parseDie(in, abbrev_table, is_64)) orelse return error.InvalidDebugInfo; |
| 462 | } else if (this_die_obj.getAttr(AT_specification)) |ref| { | |
| 464 | } else if (this_die_obj.getAttr(AT_specification)) |_| { | |
| 463 | 465 | // Follow the DIE it points to and repeat |
| 464 | 466 | const ref_offset = try this_die_obj.getAttrRef(AT_specification); |
| 465 | 467 | if (ref_offset > next_offset) return error.InvalidDebugInfo; |
lib/std/dynamic_library.zig+2-1| ... | ... | @@ -66,6 +66,7 @@ pub fn get_DYNAMIC() ?[*]elf.Dyn { |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | pub fn linkmap_iterator(phdrs: []elf.Phdr) !LinkMap.Iterator { |
| 69 | _ = phdrs; | |
| 69 | 70 | const _DYNAMIC = get_DYNAMIC() orelse { |
| 70 | 71 | // No PT_DYNAMIC means this is either a statically-linked program or a |
| 71 | 72 | // badly corrupted dynamically-linked one. |
| ... | ... | @@ -407,7 +408,7 @@ test "dynamic_library" { |
| 407 | 408 | else => return error.SkipZigTest, |
| 408 | 409 | }; |
| 409 | 410 | |
| 410 | const dynlib = DynLib.open(libname) catch |err| { | |
| 411 | _ = DynLib.open(libname) catch |err| { | |
| 411 | 412 | try testing.expect(err == error.FileNotFound); |
| 412 | 413 | return; |
| 413 | 414 | }; |
lib/std/enums.zig+9-4| ... | ... | @@ -18,7 +18,7 @@ const EnumField = std.builtin.TypeInfo.EnumField; |
| 18 | 18 | pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_default: ?Data) type { |
| 19 | 19 | const StructField = std.builtin.TypeInfo.StructField; |
| 20 | 20 | var fields: []const StructField = &[_]StructField{}; |
| 21 | for (std.meta.fields(E)) |field, i| { | |
| 21 | for (std.meta.fields(E)) |field| { | |
| 22 | 22 | fields = fields ++ &[_]StructField{.{ |
| 23 | 23 | .name = field.name, |
| 24 | 24 | .field_type = Data, |
| ... | ... | @@ -144,7 +144,7 @@ pub fn directEnumArrayDefault( |
| 144 | 144 | ) [directEnumArrayLen(E, max_unused_slots)]Data { |
| 145 | 145 | const len = comptime directEnumArrayLen(E, max_unused_slots); |
| 146 | 146 | var result: [len]Data = if (default) |d| [_]Data{d} ** len else undefined; |
| 147 | inline for (@typeInfo(@TypeOf(init_values)).Struct.fields) |f, i| { | |
| 147 | inline for (@typeInfo(@TypeOf(init_values)).Struct.fields) |f| { | |
| 148 | 148 | const enum_value = @field(E, f.name); |
| 149 | 149 | const index = @intCast(usize, @enumToInt(enum_value)); |
| 150 | 150 | result[index] = @field(init_values, f.name); |
| ... | ... | @@ -334,6 +334,7 @@ pub fn EnumArray(comptime E: type, comptime V: type) type { |
| 334 | 334 | /// TODO: Once #8169 is fixed, consider switching this param |
| 335 | 335 | /// back to an optional. |
| 336 | 336 | pub fn NoExtension(comptime Self: type) type { |
| 337 | _ = Self; | |
| 337 | 338 | return NoExt; |
| 338 | 339 | } |
| 339 | 340 | const NoExt = struct {}; |
| ... | ... | @@ -729,6 +730,7 @@ test "std.enums.ensureIndexer" { |
| 729 | 730 | } |
| 730 | 731 | |
| 731 | 732 | fn ascByValue(ctx: void, comptime a: EnumField, comptime b: EnumField) bool { |
| 733 | _ = ctx; | |
| 732 | 734 | return a.value < b.value; |
| 733 | 735 | } |
| 734 | 736 | pub fn EnumIndexer(comptime E: type) type { |
| ... | ... | @@ -743,9 +745,11 @@ pub fn EnumIndexer(comptime E: type) type { |
| 743 | 745 | pub const Key = E; |
| 744 | 746 | pub const count: usize = 0; |
| 745 | 747 | pub fn indexOf(e: E) usize { |
| 748 | _ = e; | |
| 746 | 749 | unreachable; |
| 747 | 750 | } |
| 748 | 751 | pub fn keyForIndex(i: usize) E { |
| 752 | _ = i; | |
| 749 | 753 | unreachable; |
| 750 | 754 | } |
| 751 | 755 | }; |
| ... | ... | @@ -753,10 +757,11 @@ pub fn EnumIndexer(comptime E: type) type { |
| 753 | 757 | std.sort.sort(EnumField, &fields, {}, ascByValue); |
| 754 | 758 | const min = fields[0].value; |
| 755 | 759 | const max = fields[fields.len - 1].value; |
| 760 | const fields_len = fields.len; | |
| 756 | 761 | if (max - min == fields.len - 1) { |
| 757 | 762 | return struct { |
| 758 | 763 | pub const Key = E; |
| 759 | pub const count = fields.len; | |
| 764 | pub const count = fields_len; | |
| 760 | 765 | pub fn indexOf(e: E) usize { |
| 761 | 766 | return @intCast(usize, @enumToInt(e) - min); |
| 762 | 767 | } |
| ... | ... | @@ -774,7 +779,7 @@ pub fn EnumIndexer(comptime E: type) type { |
| 774 | 779 | |
| 775 | 780 | return struct { |
| 776 | 781 | pub const Key = E; |
| 777 | pub const count = fields.len; | |
| 782 | pub const count = fields_len; | |
| 778 | 783 | pub fn indexOf(e: E) usize { |
| 779 | 784 | for (keys) |k, i| { |
| 780 | 785 | if (k == e) return i; |
lib/std/event/channel.zig-1| ... | ... | @@ -308,7 +308,6 @@ test "std.event.Channel wraparound" { |
| 308 | 308 | |
| 309 | 309 | // add items to channel and pull them out until |
| 310 | 310 | // the buffer wraps around, make sure it doesn't crash. |
| 311 | var result: i32 = undefined; | |
| 312 | 311 | channel.put(5); |
| 313 | 312 | try testing.expectEqual(@as(i32, 5), channel.get()); |
| 314 | 313 | channel.put(6); |
lib/std/event/group.zig+1-1| ... | ... | @@ -130,7 +130,7 @@ test "std.event.Group" { |
| 130 | 130 | // TODO this file has bit-rotted. repair it |
| 131 | 131 | if (true) return error.SkipZigTest; |
| 132 | 132 | |
| 133 | const handle = async testGroup(std.heap.page_allocator); | |
| 133 | _ = async testGroup(std.heap.page_allocator); | |
| 134 | 134 | } |
| 135 | 135 | fn testGroup(allocator: *Allocator) callconv(.Async) void { |
| 136 | 136 | var count: usize = 0; |
lib/std/event/loop.zig+2-2| ... | ... | @@ -345,7 +345,7 @@ pub const Loop = struct { |
| 345 | 345 | ); |
| 346 | 346 | errdefer windows.CloseHandle(self.os_data.io_port); |
| 347 | 347 | |
| 348 | for (self.eventfd_resume_nodes) |*eventfd_node, i| { | |
| 348 | for (self.eventfd_resume_nodes) |*eventfd_node| { | |
| 349 | 349 | eventfd_node.* = std.atomic.Stack(ResumeNode.EventFd).Node{ |
| 350 | 350 | .data = ResumeNode.EventFd{ |
| 351 | 351 | .base = ResumeNode{ |
| ... | ... | @@ -680,7 +680,7 @@ pub const Loop = struct { |
| 680 | 680 | fn run(func_args: Args, loop: *Loop, allocator: *mem.Allocator) void { |
| 681 | 681 | loop.beginOneEvent(); |
| 682 | 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 | 684 | suspend { |
| 685 | 685 | loop.finishOneEvent(); |
| 686 | 686 | allocator.destroy(@frame()); |
lib/std/event/rwlock.zig+1-1| ... | ... | @@ -225,7 +225,7 @@ test "std.event.RwLock" { |
| 225 | 225 | var lock = RwLock.init(); |
| 226 | 226 | defer lock.deinit(); |
| 227 | 227 | |
| 228 | const handle = testLock(std.heap.page_allocator, &lock); | |
| 228 | _ = testLock(std.heap.page_allocator, &lock); | |
| 229 | 229 | |
| 230 | 230 | const expected_result = [1]i32{shared_it_count * @intCast(i32, shared_test_data.len)} ** shared_test_data.len; |
| 231 | 231 | try testing.expectEqualSlices(i32, expected_result, shared_test_data); |
lib/std/fmt.zig+14-4| ... | ... | @@ -369,6 +369,7 @@ pub fn format( |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @TypeOf(writer).Error!void { |
| 372 | _ = options; | |
| 372 | 373 | const T = @TypeOf(value); |
| 373 | 374 | |
| 374 | 375 | switch (@typeInfo(T)) { |
| ... | ... | @@ -553,7 +554,7 @@ pub fn formatType( |
| 553 | 554 | .Many, .C => { |
| 554 | 555 | if (actual_fmt.len == 0) |
| 555 | 556 | @compileError("cannot format pointer without a specifier (i.e. {s} or {*})"); |
| 556 | if (ptr_info.sentinel) |sentinel| { | |
| 557 | if (ptr_info.sentinel) |_| { | |
| 557 | 558 | return formatType(mem.span(value), actual_fmt, options, writer, max_depth); |
| 558 | 559 | } |
| 559 | 560 | if (ptr_info.child == u8) { |
| ... | ... | @@ -741,6 +742,8 @@ fn formatSliceHexImpl(comptime case: Case) type { |
| 741 | 742 | options: std.fmt.FormatOptions, |
| 742 | 743 | writer: anytype, |
| 743 | 744 | ) !void { |
| 745 | _ = fmt; | |
| 746 | _ = options; | |
| 744 | 747 | var buf: [2]u8 = undefined; |
| 745 | 748 | |
| 746 | 749 | for (bytes) |c| { |
| ... | ... | @@ -777,6 +780,8 @@ fn formatSliceEscapeImpl(comptime case: Case) type { |
| 777 | 780 | options: std.fmt.FormatOptions, |
| 778 | 781 | writer: anytype, |
| 779 | 782 | ) !void { |
| 783 | _ = fmt; | |
| 784 | _ = options; | |
| 780 | 785 | var buf: [4]u8 = undefined; |
| 781 | 786 | |
| 782 | 787 | buf[0] = '\\'; |
| ... | ... | @@ -820,6 +825,7 @@ fn formatSizeImpl(comptime radix: comptime_int) type { |
| 820 | 825 | options: FormatOptions, |
| 821 | 826 | writer: anytype, |
| 822 | 827 | ) !void { |
| 828 | _ = fmt; | |
| 823 | 829 | if (value == 0) { |
| 824 | 830 | return writer.writeAll("0B"); |
| 825 | 831 | } |
| ... | ... | @@ -903,6 +909,7 @@ pub fn formatAsciiChar( |
| 903 | 909 | options: FormatOptions, |
| 904 | 910 | writer: anytype, |
| 905 | 911 | ) !void { |
| 912 | _ = options; | |
| 906 | 913 | return writer.writeAll(@as(*const [1]u8, &c)); |
| 907 | 914 | } |
| 908 | 915 | |
| ... | ... | @@ -1140,7 +1147,7 @@ pub fn formatFloatHexadecimal( |
| 1140 | 1147 | |
| 1141 | 1148 | // +1 for the decimal part. |
| 1142 | 1149 | var buf: [1 + mantissa_digits]u8 = undefined; |
| 1143 | const N = formatIntBuf(&buf, mantissa, 16, .lower, .{ .fill = '0', .width = 1 + mantissa_digits }); | |
| 1150 | _ = formatIntBuf(&buf, mantissa, 16, .lower, .{ .fill = '0', .width = 1 + mantissa_digits }); | |
| 1144 | 1151 | |
| 1145 | 1152 | try writer.writeAll("0x"); |
| 1146 | 1153 | try writer.writeByte(buf[0]); |
| ... | ... | @@ -1362,6 +1369,8 @@ pub fn formatIntBuf(out_buf: []u8, value: anytype, base: u8, case: Case, options |
| 1362 | 1369 | } |
| 1363 | 1370 | |
| 1364 | 1371 | fn formatDuration(ns: u64, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { |
| 1372 | _ = fmt; | |
| 1373 | _ = options; | |
| 1365 | 1374 | var ns_remaining = ns; |
| 1366 | 1375 | inline for (.{ |
| 1367 | 1376 | .{ .ns = 365 * std.time.ns_per_day, .sep = 'y' }, |
| ... | ... | @@ -2152,6 +2161,7 @@ test "custom" { |
| 2152 | 2161 | options: FormatOptions, |
| 2153 | 2162 | writer: anytype, |
| 2154 | 2163 | ) !void { |
| 2164 | _ = options; | |
| 2155 | 2165 | if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "p")) { |
| 2156 | 2166 | return std.fmt.format(writer, "({d:.3},{d:.3})", .{ self.x, self.y }); |
| 2157 | 2167 | } else if (comptime std.mem.eql(u8, fmt, "d")) { |
| ... | ... | @@ -2162,7 +2172,6 @@ test "custom" { |
| 2162 | 2172 | } |
| 2163 | 2173 | }; |
| 2164 | 2174 | |
| 2165 | var buf1: [32]u8 = undefined; | |
| 2166 | 2175 | var value = Vec2{ |
| 2167 | 2176 | .x = 10.2, |
| 2168 | 2177 | .y = 2.22, |
| ... | ... | @@ -2220,7 +2229,7 @@ test "union" { |
| 2220 | 2229 | try std.testing.expect(mem.eql(u8, uu_result[0..3], "UU@")); |
| 2221 | 2230 | |
| 2222 | 2231 | const eu_result = try bufPrint(buf[0..], "{}", .{eu_inst}); |
| 2223 | try std.testing.expect(mem.eql(u8, uu_result[0..3], "EU@")); | |
| 2232 | try std.testing.expect(mem.eql(u8, eu_result[0..3], "EU@")); | |
| 2224 | 2233 | } |
| 2225 | 2234 | |
| 2226 | 2235 | test "enum" { |
| ... | ... | @@ -2341,6 +2350,7 @@ test "formatType max_depth" { |
| 2341 | 2350 | options: FormatOptions, |
| 2342 | 2351 | writer: anytype, |
| 2343 | 2352 | ) !void { |
| 2353 | _ = options; | |
| 2344 | 2354 | if (fmt.len == 0) { |
| 2345 | 2355 | return std.fmt.format(writer, "({d:.3},{d:.3})", .{ self.x, self.y }); |
| 2346 | 2356 | } else { |
lib/std/fmt/parse_float.zig-1| ... | ... | @@ -200,7 +200,6 @@ const ParseResult = enum { |
| 200 | 200 | |
| 201 | 201 | fn parseRepr(s: []const u8, n: *FloatRepr) !ParseResult { |
| 202 | 202 | var digit_index: usize = 0; |
| 203 | var negative = false; | |
| 204 | 203 | var negative_exp = false; |
| 205 | 204 | var exponent: i32 = 0; |
| 206 | 205 |
lib/std/fs.zig+4-3| ... | ... | @@ -477,7 +477,7 @@ pub const Dir = struct { |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | var stat_info: os.libc_stat = undefined; |
| 480 | const rc2 = os.system._kern_read_stat( | |
| 480 | _ = os.system._kern_read_stat( | |
| 481 | 481 | self.dir.fd, |
| 482 | 482 | &haiku_entry.d_name, |
| 483 | 483 | false, |
| ... | ... | @@ -1541,7 +1541,7 @@ pub const Dir = struct { |
| 1541 | 1541 | self: Dir, |
| 1542 | 1542 | target_path: []const u8, |
| 1543 | 1543 | sym_link_path: []const u8, |
| 1544 | flags: SymLinkFlags, | |
| 1544 | _: SymLinkFlags, | |
| 1545 | 1545 | ) !void { |
| 1546 | 1546 | return os.symlinkatWasi(target_path, self.fd, sym_link_path); |
| 1547 | 1547 | } |
| ... | ... | @@ -1879,6 +1879,7 @@ pub const Dir = struct { |
| 1879 | 1879 | /// * NtDll prefixed |
| 1880 | 1880 | /// TODO currently this ignores `flags`. |
| 1881 | 1881 | pub fn accessW(self: Dir, sub_path_w: [*:0]const u16, flags: File.OpenFlags) AccessError!void { |
| 1882 | _ = flags; | |
| 1882 | 1883 | return os.faccessatW(self.fd, sub_path_w, 0, 0); |
| 1883 | 1884 | } |
| 1884 | 1885 | |
| ... | ... | @@ -2438,7 +2439,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 { |
| 2438 | 2439 | }) catch continue; |
| 2439 | 2440 | |
| 2440 | 2441 | var real_path_buf: [MAX_PATH_BYTES]u8 = undefined; |
| 2441 | if (os.realpathZ(&resolved_path_buf, &real_path_buf)) |real_path| { | |
| 2442 | if (os.realpathZ(resolved_path, &real_path_buf)) |real_path| { | |
| 2442 | 2443 | // found a file, and hope it is the right file |
| 2443 | 2444 | if (real_path.len > out_buffer.len) |
| 2444 | 2445 | return error.NameTooLong; |
lib/std/fs/path.zig+2-2| ... | ... | @@ -579,7 +579,7 @@ pub fn resolveWindows(allocator: *Allocator, paths: []const []const u8) ![]u8 { |
| 579 | 579 | // Now we know the disk designator to use, if any, and what kind it is. And our result |
| 580 | 580 | // is big enough to append all the paths to. |
| 581 | 581 | var correct_disk_designator = true; |
| 582 | for (paths[first_index..]) |p, i| { | |
| 582 | for (paths[first_index..]) |p| { | |
| 583 | 583 | const parsed = windowsParsePath(p); |
| 584 | 584 | |
| 585 | 585 | if (parsed.kind != WindowsPath.Kind.None) { |
| ... | ... | @@ -660,7 +660,7 @@ pub fn resolvePosix(allocator: *Allocator, paths: []const []const u8) ![]u8 { |
| 660 | 660 | } |
| 661 | 661 | errdefer allocator.free(result); |
| 662 | 662 | |
| 663 | for (paths[first_index..]) |p, i| { | |
| 663 | for (paths[first_index..]) |p| { | |
| 664 | 664 | var it = mem.tokenize(p, "/"); |
| 665 | 665 | while (it.next()) |component| { |
| 666 | 666 | if (mem.eql(u8, component, ".")) { |
lib/std/fs/test.zig+2| ... | ... | @@ -541,6 +541,7 @@ test "makePath, put some files in it, deleteTree" { |
| 541 | 541 | try tmp.dir.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "file2.txt", "blah"); |
| 542 | 542 | try tmp.dir.deleteTree("os_test_tmp"); |
| 543 | 543 | if (tmp.dir.openDir("os_test_tmp", .{})) |dir| { |
| 544 | _ = dir; | |
| 544 | 545 | @panic("expected error"); |
| 545 | 546 | } else |err| { |
| 546 | 547 | try testing.expect(err == error.FileNotFound); |
| ... | ... | @@ -638,6 +639,7 @@ test "access file" { |
| 638 | 639 | |
| 639 | 640 | try tmp.dir.makePath("os_test_tmp"); |
| 640 | 641 | if (tmp.dir.access("os_test_tmp" ++ fs.path.sep_str ++ "file.txt", .{})) |ok| { |
| 642 | _ = ok; | |
| 641 | 643 | @panic("expected error"); |
| 642 | 644 | } else |err| { |
| 643 | 645 | try testing.expect(err == error.FileNotFound); |
lib/std/fs/wasi.zig+2| ... | ... | @@ -36,6 +36,8 @@ pub const PreopenType = union(PreopenTypeTag) { |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | pub fn format(self: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: anytype) !void { |
| 39 | _ = fmt; | |
| 40 | _ = options; | |
| 39 | 41 | try out_stream.print("PreopenType{{ ", .{}); |
| 40 | 42 | switch (self) { |
| 41 | 43 | PreopenType.Dir => |path| try out_stream.print(".Dir = '{}'", .{std.zig.fmtId(path)}), |
lib/std/hash/cityhash.zig+1-1| ... | ... | @@ -353,7 +353,6 @@ fn SMHasherTest(comptime hash_fn: anytype) u32 { |
| 353 | 353 | |
| 354 | 354 | var key: [256]u8 = undefined; |
| 355 | 355 | var hashes_bytes: [256 * @sizeOf(HashResult)]u8 = undefined; |
| 356 | var final: HashResult = 0; | |
| 357 | 356 | |
| 358 | 357 | std.mem.set(u8, &key, 0); |
| 359 | 358 | std.mem.set(u8, &hashes_bytes, 0); |
| ... | ... | @@ -376,6 +375,7 @@ fn SMHasherTest(comptime hash_fn: anytype) u32 { |
| 376 | 375 | } |
| 377 | 376 | |
| 378 | 377 | fn CityHash32hashIgnoreSeed(str: []const u8, seed: u32) u32 { |
| 378 | _ = seed; | |
| 379 | 379 | return CityHash32.hash(str); |
| 380 | 380 | } |
| 381 | 381 |
lib/std/hash/wyhash.zig-2| ... | ... | @@ -166,8 +166,6 @@ pub const Wyhash = struct { |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | pub fn final(self: *Wyhash) u64 { |
| 169 | const seed = self.state.seed; | |
| 170 | const rem_len = @intCast(u5, self.buf_len); | |
| 171 | 169 | const rem_key = self.buf[0..self.buf_len]; |
| 172 | 170 | |
| 173 | 171 | return self.state.final(rem_key); |
lib/std/hash_map.zig+7-1| ... | ... | @@ -29,6 +29,7 @@ pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K) |
| 29 | 29 | |
| 30 | 30 | return struct { |
| 31 | 31 | fn hash(ctx: Context, key: K) u64 { |
| 32 | _ = ctx; | |
| 32 | 33 | if (comptime trait.hasUniqueRepresentation(K)) { |
| 33 | 34 | return Wyhash.hash(0, std.mem.asBytes(&key)); |
| 34 | 35 | } else { |
| ... | ... | @@ -43,6 +44,7 @@ pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K) |
| 43 | 44 | pub fn getAutoEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K) bool) { |
| 44 | 45 | return struct { |
| 45 | 46 | fn eql(ctx: Context, a: K, b: K) bool { |
| 47 | _ = ctx; | |
| 46 | 48 | return meta.eql(a, b); |
| 47 | 49 | } |
| 48 | 50 | }.eql; |
| ... | ... | @@ -78,9 +80,11 @@ pub fn StringHashMapUnmanaged(comptime V: type) type { |
| 78 | 80 | |
| 79 | 81 | pub const StringContext = struct { |
| 80 | 82 | pub fn hash(self: @This(), s: []const u8) u64 { |
| 83 | _ = self; | |
| 81 | 84 | return hashString(s); |
| 82 | 85 | } |
| 83 | 86 | pub fn eql(self: @This(), a: []const u8, b: []const u8) bool { |
| 87 | _ = self; | |
| 84 | 88 | return eqlString(a, b); |
| 85 | 89 | } |
| 86 | 90 | }; |
| ... | ... | @@ -1809,7 +1813,7 @@ test "std.hash_map getOrPut" { |
| 1809 | 1813 | |
| 1810 | 1814 | i = 0; |
| 1811 | 1815 | while (i < 20) : (i += 1) { |
| 1812 | var n = try map.getOrPutValue(i, 1); | |
| 1816 | _ = try map.getOrPutValue(i, 1); | |
| 1813 | 1817 | } |
| 1814 | 1818 | |
| 1815 | 1819 | i = 0; |
| ... | ... | @@ -1887,9 +1891,11 @@ test "std.hash_map clone" { |
| 1887 | 1891 | test "std.hash_map getOrPutAdapted" { |
| 1888 | 1892 | const AdaptedContext = struct { |
| 1889 | 1893 | fn eql(self: @This(), adapted_key: []const u8, test_key: u64) bool { |
| 1894 | _ = self; | |
| 1890 | 1895 | return std.fmt.parseInt(u64, adapted_key, 10) catch unreachable == test_key; |
| 1891 | 1896 | } |
| 1892 | 1897 | fn hash(self: @This(), adapted_key: []const u8) u64 { |
| 1898 | _ = self; | |
| 1893 | 1899 | const key = std.fmt.parseInt(u64, adapted_key, 10) catch unreachable; |
| 1894 | 1900 | return (AutoContext(u64){}).hash(key); |
| 1895 | 1901 | } |
lib/std/heap.zig+30| ... | ... | @@ -108,6 +108,8 @@ const CAllocator = struct { |
| 108 | 108 | len_align: u29, |
| 109 | 109 | return_address: usize, |
| 110 | 110 | ) error{OutOfMemory}![]u8 { |
| 111 | _ = allocator; | |
| 112 | _ = return_address; | |
| 111 | 113 | assert(len > 0); |
| 112 | 114 | assert(std.math.isPowerOfTwo(alignment)); |
| 113 | 115 | |
| ... | ... | @@ -134,6 +136,9 @@ const CAllocator = struct { |
| 134 | 136 | len_align: u29, |
| 135 | 137 | return_address: usize, |
| 136 | 138 | ) Allocator.Error!usize { |
| 139 | _ = allocator; | |
| 140 | _ = buf_align; | |
| 141 | _ = return_address; | |
| 137 | 142 | if (new_len == 0) { |
| 138 | 143 | alignedFree(buf.ptr); |
| 139 | 144 | return 0; |
| ... | ... | @@ -178,6 +183,9 @@ fn rawCAlloc( |
| 178 | 183 | len_align: u29, |
| 179 | 184 | ret_addr: usize, |
| 180 | 185 | ) Allocator.Error![]u8 { |
| 186 | _ = self; | |
| 187 | _ = len_align; | |
| 188 | _ = ret_addr; | |
| 181 | 189 | assert(ptr_align <= @alignOf(std.c.max_align_t)); |
| 182 | 190 | const ptr = @ptrCast([*]u8, c.malloc(len) orelse return error.OutOfMemory); |
| 183 | 191 | return ptr[0..len]; |
| ... | ... | @@ -191,6 +199,9 @@ fn rawCResize( |
| 191 | 199 | len_align: u29, |
| 192 | 200 | ret_addr: usize, |
| 193 | 201 | ) Allocator.Error!usize { |
| 202 | _ = self; | |
| 203 | _ = old_align; | |
| 204 | _ = ret_addr; | |
| 194 | 205 | if (new_len == 0) { |
| 195 | 206 | c.free(buf.ptr); |
| 196 | 207 | return 0; |
| ... | ... | @@ -231,6 +242,8 @@ pub var next_mmap_addr_hint: ?[*]align(mem.page_size) u8 = null; |
| 231 | 242 | |
| 232 | 243 | const PageAllocator = struct { |
| 233 | 244 | fn alloc(allocator: *Allocator, n: usize, alignment: u29, len_align: u29, ra: usize) error{OutOfMemory}![]u8 { |
| 245 | _ = allocator; | |
| 246 | _ = ra; | |
| 234 | 247 | assert(n > 0); |
| 235 | 248 | const aligned_len = mem.alignForward(n, mem.page_size); |
| 236 | 249 | |
| ... | ... | @@ -334,6 +347,9 @@ const PageAllocator = struct { |
| 334 | 347 | len_align: u29, |
| 335 | 348 | return_address: usize, |
| 336 | 349 | ) Allocator.Error!usize { |
| 350 | _ = allocator; | |
| 351 | _ = buf_align; | |
| 352 | _ = return_address; | |
| 337 | 353 | const new_size_aligned = mem.alignForward(new_size, mem.page_size); |
| 338 | 354 | |
| 339 | 355 | if (builtin.os.tag == .windows) { |
| ... | ... | @@ -482,6 +498,8 @@ const WasmPageAllocator = struct { |
| 482 | 498 | } |
| 483 | 499 | |
| 484 | 500 | fn alloc(allocator: *Allocator, len: usize, alignment: u29, len_align: u29, ra: usize) error{OutOfMemory}![]u8 { |
| 501 | _ = allocator; | |
| 502 | _ = ra; | |
| 485 | 503 | const page_count = nPages(len); |
| 486 | 504 | const page_idx = try allocPages(page_count, alignment); |
| 487 | 505 | return @intToPtr([*]u8, page_idx * mem.page_size)[0..alignPageAllocLen(page_count * mem.page_size, len, len_align)]; |
| ... | ... | @@ -542,6 +560,9 @@ const WasmPageAllocator = struct { |
| 542 | 560 | len_align: u29, |
| 543 | 561 | return_address: usize, |
| 544 | 562 | ) error{OutOfMemory}!usize { |
| 563 | _ = allocator; | |
| 564 | _ = buf_align; | |
| 565 | _ = return_address; | |
| 545 | 566 | const aligned_len = mem.alignForward(buf.len, mem.page_size); |
| 546 | 567 | if (new_len > aligned_len) return error.OutOfMemory; |
| 547 | 568 | const current_n = nPages(aligned_len); |
| ... | ... | @@ -588,6 +609,7 @@ pub const HeapAllocator = switch (builtin.os.tag) { |
| 588 | 609 | len_align: u29, |
| 589 | 610 | return_address: usize, |
| 590 | 611 | ) error{OutOfMemory}![]u8 { |
| 612 | _ = return_address; | |
| 591 | 613 | const self = @fieldParentPtr(HeapAllocator, "allocator", allocator); |
| 592 | 614 | |
| 593 | 615 | const amt = n + ptr_align - 1 + @sizeOf(usize); |
| ... | ... | @@ -622,6 +644,8 @@ pub const HeapAllocator = switch (builtin.os.tag) { |
| 622 | 644 | len_align: u29, |
| 623 | 645 | return_address: usize, |
| 624 | 646 | ) error{OutOfMemory}!usize { |
| 647 | _ = buf_align; | |
| 648 | _ = return_address; | |
| 625 | 649 | const self = @fieldParentPtr(HeapAllocator, "allocator", allocator); |
| 626 | 650 | if (new_size == 0) { |
| 627 | 651 | os.windows.HeapFree(self.heap_handle.?, 0, @intToPtr(*c_void, getRecordPtr(buf).*)); |
| ... | ... | @@ -694,6 +718,8 @@ pub const FixedBufferAllocator = struct { |
| 694 | 718 | } |
| 695 | 719 | |
| 696 | 720 | fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29, ra: usize) ![]u8 { |
| 721 | _ = len_align; | |
| 722 | _ = ra; | |
| 697 | 723 | const self = @fieldParentPtr(FixedBufferAllocator, "allocator", allocator); |
| 698 | 724 | const adjust_off = mem.alignPointerOffset(self.buffer.ptr + self.end_index, ptr_align) orelse |
| 699 | 725 | return error.OutOfMemory; |
| ... | ... | @@ -716,6 +742,8 @@ pub const FixedBufferAllocator = struct { |
| 716 | 742 | len_align: u29, |
| 717 | 743 | return_address: usize, |
| 718 | 744 | ) Allocator.Error!usize { |
| 745 | _ = buf_align; | |
| 746 | _ = return_address; | |
| 719 | 747 | const self = @fieldParentPtr(FixedBufferAllocator, "allocator", allocator); |
| 720 | 748 | assert(self.ownsSlice(buf)); // sanity check |
| 721 | 749 | |
| ... | ... | @@ -766,6 +794,8 @@ pub const ThreadSafeFixedBufferAllocator = blk: { |
| 766 | 794 | } |
| 767 | 795 | |
| 768 | 796 | fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29, ra: usize) ![]u8 { |
| 797 | _ = len_align; | |
| 798 | _ = ra; | |
| 769 | 799 | const self = @fieldParentPtr(ThreadSafeFixedBufferAllocator, "allocator", allocator); |
| 770 | 800 | var end_index = @atomicLoad(usize, &self.end_index, builtin.AtomicOrder.SeqCst); |
| 771 | 801 | while (true) { |
lib/std/heap/arena_allocator.zig+5| ... | ... | @@ -66,6 +66,8 @@ pub const ArenaAllocator = struct { |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29, ra: usize) ![]u8 { |
| 69 | _ = len_align; | |
| 70 | _ = ra; | |
| 69 | 71 | const self = @fieldParentPtr(ArenaAllocator, "allocator", allocator); |
| 70 | 72 | |
| 71 | 73 | var cur_node = if (self.state.buffer_list.first) |first_node| first_node else try self.createNode(0, n + ptr_align); |
| ... | ... | @@ -95,6 +97,9 @@ pub const ArenaAllocator = struct { |
| 95 | 97 | } |
| 96 | 98 | |
| 97 | 99 | fn resize(allocator: *Allocator, buf: []u8, buf_align: u29, new_len: usize, len_align: u29, ret_addr: usize) Allocator.Error!usize { |
| 100 | _ = buf_align; | |
| 101 | _ = len_align; | |
| 102 | _ = ret_addr; | |
| 98 | 103 | const self = @fieldParentPtr(ArenaAllocator, "allocator", allocator); |
| 99 | 104 | |
| 100 | 105 | const cur_node = self.state.buffer_list.first orelse return error.OutOfMemory; |
lib/std/heap/log_to_writer_allocator.zig+2-2| ... | ... | @@ -37,9 +37,9 @@ pub fn LogToWriterAllocator(comptime Writer: type) type { |
| 37 | 37 | const self = @fieldParentPtr(Self, "allocator", allocator); |
| 38 | 38 | self.writer.print("alloc : {}", .{len}) catch {}; |
| 39 | 39 | const result = self.parent_allocator.allocFn(self.parent_allocator, len, ptr_align, len_align, ra); |
| 40 | if (result) |buff| { | |
| 40 | if (result) |_| { | |
| 41 | 41 | self.writer.print(" success!\n", .{}) catch {}; |
| 42 | } else |err| { | |
| 42 | } else |_| { | |
| 43 | 43 | self.writer.print(" failure!\n", .{}) catch {}; |
| 44 | 44 | } |
| 45 | 45 | return result; |
lib/std/heap/logging_allocator.zig+1-1| ... | ... | @@ -65,7 +65,7 @@ pub fn ScopedLoggingAllocator( |
| 65 | 65 | ) error{OutOfMemory}![]u8 { |
| 66 | 66 | const self = @fieldParentPtr(Self, "allocator", allocator); |
| 67 | 67 | const result = self.parent_allocator.allocFn(self.parent_allocator, len, ptr_align, len_align, ra); |
| 68 | if (result) |buff| { | |
| 68 | if (result) |_| { | |
| 69 | 69 | logHelper( |
| 70 | 70 | success_log_level, |
| 71 | 71 | "alloc - success - len: {}, ptr_align: {}, len_align: {}", |
lib/std/io.zig+1| ... | ... | @@ -161,6 +161,7 @@ pub const null_writer = @as(NullWriter, .{ .context = {} }); |
| 161 | 161 | |
| 162 | 162 | const NullWriter = Writer(void, error{}, dummyWrite); |
| 163 | 163 | fn dummyWrite(context: void, data: []const u8) error{}!usize { |
| 164 | _ = context; | |
| 164 | 165 | return data.len; |
| 165 | 166 | } |
| 166 | 167 |
lib/std/io/bit_reader.zig+1-1| ... | ... | @@ -149,7 +149,7 @@ pub fn BitReader(endian: builtin.Endian, comptime ReaderType: type) type { |
| 149 | 149 | var out_bits_total = @as(usize, 0); |
| 150 | 150 | //@NOTE: I'm not sure this is a good idea, maybe alignToByte should be forced |
| 151 | 151 | if (self.bit_count > 0) { |
| 152 | for (buffer) |*b, i| { | |
| 152 | for (buffer) |*b| { | |
| 153 | 153 | b.* = try self.readBits(u8, u8_bit_count, &out_bits); |
| 154 | 154 | out_bits_total += out_bits; |
| 155 | 155 | } |
lib/std/io/bit_writer.zig+1-1| ... | ... | @@ -128,7 +128,7 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type { |
| 128 | 128 | pub fn write(self: *Self, buffer: []const u8) Error!usize { |
| 129 | 129 | // TODO: I'm not sure this is a good idea, maybe flushBits should be forced |
| 130 | 130 | if (self.bit_count > 0) { |
| 131 | for (buffer) |b, i| | |
| 131 | for (buffer) |b| | |
| 132 | 132 | try self.writeBits(b, u8_bit_count); |
| 133 | 133 | return buffer.len; |
| 134 | 134 | } |
lib/std/json.zig+8-6| ... | ... | @@ -1221,11 +1221,11 @@ test "json.token premature object close" { |
| 1221 | 1221 | pub fn validate(s: []const u8) bool { |
| 1222 | 1222 | var p = StreamingParser.init(); |
| 1223 | 1223 | |
| 1224 | for (s) |c, i| { | |
| 1224 | for (s) |c| { | |
| 1225 | 1225 | var token1: ?Token = undefined; |
| 1226 | 1226 | var token2: ?Token = undefined; |
| 1227 | 1227 | |
| 1228 | p.feed(c, &token1, &token2) catch |err| { | |
| 1228 | p.feed(c, &token1, &token2) catch { | |
| 1229 | 1229 | return false; |
| 1230 | 1230 | }; |
| 1231 | 1231 | } |
| ... | ... | @@ -1410,7 +1410,7 @@ fn parsedEqual(a: anytype, b: @TypeOf(a)) bool { |
| 1410 | 1410 | if (a == null or b == null) return false; |
| 1411 | 1411 | return parsedEqual(a.?, b.?); |
| 1412 | 1412 | }, |
| 1413 | .Union => |unionInfo| { | |
| 1413 | .Union => { | |
| 1414 | 1414 | if (info.tag_type) |UnionTag| { |
| 1415 | 1415 | const tag_a = std.meta.activeTag(a); |
| 1416 | 1416 | const tag_b = std.meta.activeTag(b); |
| ... | ... | @@ -1771,7 +1771,7 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options: |
| 1771 | 1771 | const source_slice = stringToken.slice(tokens.slice, tokens.i - 1); |
| 1772 | 1772 | switch (stringToken.escapes) { |
| 1773 | 1773 | .None => return allocator.dupe(u8, source_slice), |
| 1774 | .Some => |some_escapes| { | |
| 1774 | .Some => { | |
| 1775 | 1775 | const output = try allocator.alloc(u8, stringToken.decodedLength()); |
| 1776 | 1776 | errdefer allocator.free(output); |
| 1777 | 1777 | try unescapeValidString(output, source_slice); |
| ... | ... | @@ -2391,7 +2391,7 @@ pub const Parser = struct { |
| 2391 | 2391 | const slice = s.slice(input, i); |
| 2392 | 2392 | switch (s.escapes) { |
| 2393 | 2393 | .None => return Value{ .String = if (p.copy_strings) try allocator.dupe(u8, slice) else slice }, |
| 2394 | .Some => |some_escapes| { | |
| 2394 | .Some => { | |
| 2395 | 2395 | const output = try allocator.alloc(u8, s.decodedLength()); |
| 2396 | 2396 | errdefer allocator.free(output); |
| 2397 | 2397 | try unescapeValidString(output, slice); |
| ... | ... | @@ -2401,6 +2401,7 @@ pub const Parser = struct { |
| 2401 | 2401 | } |
| 2402 | 2402 | |
| 2403 | 2403 | fn parseNumber(p: *Parser, n: std.meta.TagPayload(Token, Token.Number), input: []const u8, i: usize) !Value { |
| 2404 | _ = p; | |
| 2404 | 2405 | return if (n.is_integer) |
| 2405 | 2406 | Value{ |
| 2406 | 2407 | .Integer = std.fmt.parseInt(i64, n.slice(input, i), 10) catch |e| switch (e) { |
| ... | ... | @@ -2815,7 +2816,7 @@ pub fn stringify( |
| 2815 | 2816 | if (child_options.whitespace) |*child_whitespace| { |
| 2816 | 2817 | child_whitespace.indent_level += 1; |
| 2817 | 2818 | } |
| 2818 | inline for (S.fields) |Field, field_i| { | |
| 2819 | inline for (S.fields) |Field| { | |
| 2819 | 2820 | // don't include void fields |
| 2820 | 2821 | if (Field.field_type == void) continue; |
| 2821 | 2822 | |
| ... | ... | @@ -3114,6 +3115,7 @@ test "stringify struct with custom stringifier" { |
| 3114 | 3115 | options: StringifyOptions, |
| 3115 | 3116 | out_stream: anytype, |
| 3116 | 3117 | ) !void { |
| 3118 | _ = value; | |
| 3117 | 3119 | try out_stream.writeAll("[\"something special\","); |
| 3118 | 3120 | try stringify(42, options, out_stream); |
| 3119 | 3121 | try out_stream.writeByte(']'); |
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 | 198 | var reader = std.io.fixedBufferStream(encoded); |
| 199 | 199 | var i: usize = 0; |
| 200 | 200 | while (i < N) : (i += 1) { |
| 201 | const v1 = try readILEB128(T, reader.reader()); | |
| 201 | _ = try readILEB128(T, reader.reader()); | |
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
| ... | ... | @@ -206,7 +206,7 @@ fn test_read_uleb128_seq(comptime T: type, comptime N: usize, encoded: []const u |
| 206 | 206 | var reader = std.io.fixedBufferStream(encoded); |
| 207 | 207 | var i: usize = 0; |
| 208 | 208 | while (i < N) : (i += 1) { |
| 209 | const v1 = try readULEB128(T, reader.reader()); | |
| 209 | _ = try readULEB128(T, reader.reader()); | |
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | 212 | |
| ... | ... | @@ -309,7 +309,6 @@ fn test_write_leb128(value: anytype) !void { |
| 309 | 309 | const B = std.meta.Int(signedness, larger_type_bits); |
| 310 | 310 | |
| 311 | 311 | const bytes_needed = bn: { |
| 312 | const S = std.meta.Int(signedness, @sizeOf(T) * 8); | |
| 313 | 312 | if (@typeInfo(T).Int.bits <= 7) break :bn @as(u16, 1); |
| 314 | 313 | |
| 315 | 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 | 359 | } |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | var first = list.popFirst(); // {2, 3, 4, 5} | |
| 363 | var last = list.pop(); // {2, 3, 4} | |
| 362 | _ = list.popFirst(); // {2, 3, 4, 5} | |
| 363 | _ = list.pop(); // {2, 3, 4} | |
| 364 | 364 | list.remove(&three); // {2, 4} |
| 365 | 365 | |
| 366 | 366 | try testing.expect(list.first.?.data == 2); |
lib/std/math/big/int.zig+4-2| ... | ... | @@ -458,6 +458,7 @@ pub const Mutable = struct { |
| 458 | 458 | /// If `allocator` is provided, it will be used for temporary storage to improve |
| 459 | 459 | /// multiplication performance. `error.OutOfMemory` is handled with a fallback algorithm. |
| 460 | 460 | pub fn sqrNoAlias(rma: *Mutable, a: Const, opt_allocator: ?*Allocator) void { |
| 461 | _ = opt_allocator; | |
| 461 | 462 | assert(rma.limbs.ptr != a.limbs.ptr); // illegal aliasing |
| 462 | 463 | |
| 463 | 464 | mem.set(Limb, rma.limbs, 0); |
| ... | ... | @@ -676,6 +677,7 @@ pub const Mutable = struct { |
| 676 | 677 | /// |
| 677 | 678 | /// `limbs_buffer` is used for temporary storage during the operation. |
| 678 | 679 | pub fn gcdNoAlias(rma: *Mutable, x: Const, y: Const, limbs_buffer: *std.ArrayList(Limb)) !void { |
| 680 | _ = limbs_buffer; | |
| 679 | 681 | assert(rma.limbs.ptr != x.limbs.ptr); // illegal aliasing |
| 680 | 682 | assert(rma.limbs.ptr != y.limbs.ptr); // illegal aliasing |
| 681 | 683 | return gcdLehmer(rma, x, y, allocator); |
| ... | ... | @@ -1141,6 +1143,7 @@ pub const Const = struct { |
| 1141 | 1143 | options: std.fmt.FormatOptions, |
| 1142 | 1144 | out_stream: anytype, |
| 1143 | 1145 | ) !void { |
| 1146 | _ = options; | |
| 1144 | 1147 | comptime var radix = 10; |
| 1145 | 1148 | comptime var case: std.fmt.Case = .lower; |
| 1146 | 1149 | |
| ... | ... | @@ -1618,6 +1621,7 @@ pub const Managed = struct { |
| 1618 | 1621 | /// Converts self to a string in the requested base. Memory is allocated from the provided |
| 1619 | 1622 | /// allocator and not the one present in self. |
| 1620 | 1623 | pub fn toString(self: Managed, allocator: *Allocator, base: u8, case: std.fmt.Case) ![]u8 { |
| 1624 | _ = allocator; | |
| 1621 | 1625 | if (base < 2 or base > 16) return error.InvalidBase; |
| 1622 | 1626 | return self.toConst().toStringAlloc(self.allocator, base, case); |
| 1623 | 1627 | } |
| ... | ... | @@ -2000,8 +2004,6 @@ fn llmulacc_karatsuba(allocator: *Allocator, r: []Limb, x: []const Limb, y: []co |
| 2000 | 2004 | } else { |
| 2001 | 2005 | llsub(j1, y0[0..y0_len], y1[0..y1_len]); |
| 2002 | 2006 | } |
| 2003 | const j0_len = llnormalize(j0); | |
| 2004 | const j1_len = llnormalize(j1); | |
| 2005 | 2007 | if (x_cmp == y_cmp) { |
| 2006 | 2008 | mem.set(Limb, tmp[0..length], 0); |
| 2007 | 2009 | llmulacc(allocator, tmp, j0, j1); |
lib/std/math/big/rational.zig-1| ... | ... | @@ -204,7 +204,6 @@ pub const Rational = struct { |
| 204 | 204 | const esize = math.floatExponentBits(T); |
| 205 | 205 | const ebias = (1 << (esize - 1)) - 1; |
| 206 | 206 | const emin = 1 - ebias; |
| 207 | const emax = ebias; | |
| 208 | 207 | |
| 209 | 208 | if (self.p.eqZero()) { |
| 210 | 209 | return 0; |
lib/std/math/complex/ldexp.zig+1-1| ... | ... | @@ -12,8 +12,8 @@ |
| 12 | 12 | const std = @import("../../std.zig"); |
| 13 | 13 | const debug = std.debug; |
| 14 | 14 | const math = std.math; |
| 15 | const cmath = math.complex; | |
| 16 | 15 | const testing = std.testing; |
| 16 | const cmath = math.complex; | |
| 17 | 17 | const Complex = cmath.Complex; |
| 18 | 18 | |
| 19 | 19 | /// Returns exp(z) scaled to avoid overflow. |
lib/std/math/expm1.zig-4| ... | ... | @@ -316,16 +316,12 @@ test "math.expm1_64" { |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | test "math.expm1_32.special" { |
| 319 | const epsilon = 0.000001; | |
| 320 | ||
| 321 | 319 | try expect(math.isPositiveInf(expm1_32(math.inf(f32)))); |
| 322 | 320 | try expect(expm1_32(-math.inf(f32)) == -1.0); |
| 323 | 321 | try expect(math.isNan(expm1_32(math.nan(f32)))); |
| 324 | 322 | } |
| 325 | 323 | |
| 326 | 324 | test "math.expm1_64.special" { |
| 327 | const epsilon = 0.000001; | |
| 328 | ||
| 329 | 325 | try expect(math.isPositiveInf(expm1_64(math.inf(f64)))); |
| 330 | 326 | try expect(expm1_64(-math.inf(f64)) == -1.0); |
| 331 | 327 | try expect(math.isNan(expm1_64(math.nan(f64)))); |
lib/std/math/modf.zig+2-5| ... | ... | @@ -12,6 +12,7 @@ |
| 12 | 12 | const std = @import("../std.zig"); |
| 13 | 13 | const math = std.math; |
| 14 | 14 | const expect = std.testing.expect; |
| 15 | const expectEqual = std.testing.expectEqual; | |
| 15 | 16 | const maxInt = std.math.maxInt; |
| 16 | 17 | |
| 17 | 18 | fn modf_result(comptime T: type) type { |
| ... | ... | @@ -131,11 +132,7 @@ test "math.modf" { |
| 131 | 132 | const a = modf(@as(f32, 1.0)); |
| 132 | 133 | const b = modf32(1.0); |
| 133 | 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 | ||
| 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); | |
| 135 | try expectEqual(a, b); | |
| 139 | 136 | } |
| 140 | 137 | |
| 141 | 138 | test "math.modf32" { |
lib/std/mem.zig+5| ... | ... | @@ -139,6 +139,11 @@ var failAllocator = Allocator{ |
| 139 | 139 | .resizeFn = Allocator.noResize, |
| 140 | 140 | }; |
| 141 | 141 | fn failAllocatorAlloc(self: *Allocator, n: usize, alignment: u29, len_align: u29, ra: usize) Allocator.Error![]u8 { |
| 142 | _ = self; | |
| 143 | _ = n; | |
| 144 | _ = alignment; | |
| 145 | _ = len_align; | |
| 146 | _ = ra; | |
| 142 | 147 | return error.OutOfMemory; |
| 143 | 148 | } |
| 144 | 149 |
lib/std/mem/Allocator.zig+4| ... | ... | @@ -55,6 +55,10 @@ pub fn noResize( |
| 55 | 55 | len_align: u29, |
| 56 | 56 | ret_addr: usize, |
| 57 | 57 | ) Error!usize { |
| 58 | _ = self; | |
| 59 | _ = buf_align; | |
| 60 | _ = len_align; | |
| 61 | _ = ret_addr; | |
| 58 | 62 | if (new_len > buf.len) |
| 59 | 63 | return error.OutOfMemory; |
| 60 | 64 | return new_len; |
lib/std/meta.zig+1-7| ... | ... | @@ -654,7 +654,6 @@ pub fn TagPayload(comptime U: type, tag: Tag(U)) type { |
| 654 | 654 | try testing.expect(trait.is(.Union)(U)); |
| 655 | 655 | |
| 656 | 656 | const info = @typeInfo(U).Union; |
| 657 | const tag_info = @typeInfo(Tag(U)).Enum; | |
| 658 | 657 | |
| 659 | 658 | inline for (info.fields) |field_info| { |
| 660 | 659 | if (comptime mem.eql(u8, field_info.name, @tagName(tag))) |
| ... | ... | @@ -757,12 +756,6 @@ test "std.meta.eql" { |
| 757 | 756 | .c = "12345".*, |
| 758 | 757 | }; |
| 759 | 758 | |
| 760 | const s_2 = S{ | |
| 761 | .a = 1, | |
| 762 | .b = 123.3, | |
| 763 | .c = "54321".*, | |
| 764 | }; | |
| 765 | ||
| 766 | 759 | var s_3 = S{ |
| 767 | 760 | .a = 134, |
| 768 | 761 | .b = 123.3, |
| ... | ... | @@ -850,6 +843,7 @@ pub const refAllDecls = @compileError("refAllDecls has been moved from std.meta |
| 850 | 843 | pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const Decl { |
| 851 | 844 | const S = struct { |
| 852 | 845 | fn declNameLessThan(context: void, lhs: *const Decl, rhs: *const Decl) bool { |
| 846 | _ = context; | |
| 853 | 847 | return mem.lessThan(u8, lhs.name, rhs.name); |
| 854 | 848 | } |
| 855 | 849 | }; |
lib/std/meta/trailer_flags.zig+3-3| ... | ... | @@ -96,18 +96,18 @@ pub fn TrailerFlags(comptime Fields: type) type { |
| 96 | 96 | pub fn ptr(self: Self, p: [*]align(@alignOf(Fields)) u8, comptime field: FieldEnum) *Field(field) { |
| 97 | 97 | if (@sizeOf(Field(field)) == 0) |
| 98 | 98 | return undefined; |
| 99 | const off = self.offset(p, field); | |
| 99 | const off = self.offset(field); | |
| 100 | 100 | return @ptrCast(*Field(field), @alignCast(@alignOf(Field(field)), p + off)); |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | pub fn ptrConst(self: Self, p: [*]align(@alignOf(Fields)) const u8, comptime field: FieldEnum) *const Field(field) { |
| 104 | 104 | if (@sizeOf(Field(field)) == 0) |
| 105 | 105 | return undefined; |
| 106 | const off = self.offset(p, field); | |
| 106 | const off = self.offset(field); | |
| 107 | 107 | return @ptrCast(*const Field(field), @alignCast(@alignOf(Field(field)), p + off)); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | pub fn offset(self: Self, p: [*]align(@alignOf(Fields)) const u8, comptime field: FieldEnum) usize { | |
| 110 | pub fn offset(self: Self, comptime field: FieldEnum) usize { | |
| 111 | 111 | var off: usize = 0; |
| 112 | 112 | inline for (@typeInfo(Fields).Struct.fields) |field_info, i| { |
| 113 | 113 | const active = (self.bits & (1 << i)) != 0; |
lib/std/multi_array_list.zig+3-2| ... | ... | @@ -92,6 +92,7 @@ pub fn MultiArrayList(comptime S: type) type { |
| 92 | 92 | } |
| 93 | 93 | const Sort = struct { |
| 94 | 94 | fn lessThan(trash: *i32, lhs: Data, rhs: Data) bool { |
| 95 | _ = trash; | |
| 95 | 96 | return lhs.alignment > rhs.alignment; |
| 96 | 97 | } |
| 97 | 98 | }; |
| ... | ... | @@ -221,7 +222,7 @@ pub fn MultiArrayList(comptime S: type) type { |
| 221 | 222 | /// retain list ordering. |
| 222 | 223 | pub fn swapRemove(self: *Self, index: usize) void { |
| 223 | 224 | const slices = self.slice(); |
| 224 | inline for (fields) |field_info, i| { | |
| 225 | inline for (fields) |_, i| { | |
| 225 | 226 | const field_slice = slices.items(@intToEnum(Field, i)); |
| 226 | 227 | field_slice[index] = field_slice[self.len - 1]; |
| 227 | 228 | field_slice[self.len - 1] = undefined; |
| ... | ... | @@ -233,7 +234,7 @@ pub fn MultiArrayList(comptime S: type) type { |
| 233 | 234 | /// after it to preserve order. |
| 234 | 235 | pub fn orderedRemove(self: *Self, index: usize) void { |
| 235 | 236 | const slices = self.slice(); |
| 236 | inline for (fields) |field_info, field_index| { | |
| 237 | inline for (fields) |_, field_index| { | |
| 237 | 238 | const field_slice = slices.items(@intToEnum(Field, field_index)); |
| 238 | 239 | var i = index; |
| 239 | 240 | while (i < self.len - 1) : (i += 1) { |
lib/std/net.zig+7| ... | ... | @@ -270,6 +270,8 @@ pub const Ip4Address = extern struct { |
| 270 | 270 | options: std.fmt.FormatOptions, |
| 271 | 271 | out_stream: anytype, |
| 272 | 272 | ) !void { |
| 273 | _ = fmt; | |
| 274 | _ = options; | |
| 273 | 275 | const bytes = @ptrCast(*const [4]u8, &self.sa.addr); |
| 274 | 276 | try std.fmt.format(out_stream, "{}.{}.{}.{}:{}", .{ |
| 275 | 277 | bytes[0], |
| ... | ... | @@ -281,6 +283,7 @@ pub const Ip4Address = extern struct { |
| 281 | 283 | } |
| 282 | 284 | |
| 283 | 285 | pub fn getOsSockLen(self: Ip4Address) os.socklen_t { |
| 286 | _ = self; | |
| 284 | 287 | return @sizeOf(os.sockaddr_in); |
| 285 | 288 | } |
| 286 | 289 | }; |
| ... | ... | @@ -556,6 +559,8 @@ pub const Ip6Address = extern struct { |
| 556 | 559 | options: std.fmt.FormatOptions, |
| 557 | 560 | out_stream: anytype, |
| 558 | 561 | ) !void { |
| 562 | _ = fmt; | |
| 563 | _ = options; | |
| 559 | 564 | const port = mem.bigToNative(u16, self.sa.port); |
| 560 | 565 | if (mem.eql(u8, self.sa.addr[0..12], &[_]u8{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff })) { |
| 561 | 566 | try std.fmt.format(out_stream, "[::ffff:{}.{}.{}.{}]:{}", .{ |
| ... | ... | @@ -598,6 +603,7 @@ pub const Ip6Address = extern struct { |
| 598 | 603 | } |
| 599 | 604 | |
| 600 | 605 | pub fn getOsSockLen(self: Ip6Address) os.socklen_t { |
| 606 | _ = self; | |
| 601 | 607 | return @sizeOf(os.sockaddr_in6); |
| 602 | 608 | } |
| 603 | 609 | }; |
| ... | ... | @@ -1062,6 +1068,7 @@ fn IN6_IS_ADDR_SITELOCAL(a: [16]u8) bool { |
| 1062 | 1068 | |
| 1063 | 1069 | // Parameters `b` and `a` swapped to make this descending. |
| 1064 | 1070 | fn addrCmpLessThan(context: void, b: LookupAddr, a: LookupAddr) bool { |
| 1071 | _ = context; | |
| 1065 | 1072 | return a.sortkey < b.sortkey; |
| 1066 | 1073 | } |
| 1067 | 1074 |
lib/std/once.zig+1| ... | ... | @@ -61,6 +61,7 @@ test "Once executes its function just once" { |
| 61 | 61 | for (threads) |*handle| { |
| 62 | 62 | handle.* = try std.Thread.spawn(struct { |
| 63 | 63 | fn thread_fn(x: u8) void { |
| 64 | _ = x; | |
| 64 | 65 | global_once.call(); |
| 65 | 66 | } |
| 66 | 67 | }.thread_fn, 0); |
lib/std/os.zig+13-3| ... | ... | @@ -1164,6 +1164,7 @@ fn openOptionsFromFlags(flags: u32) windows.OpenFileOptions { |
| 1164 | 1164 | /// TODO currently, this function does not handle all flag combinations |
| 1165 | 1165 | /// or makes use of perm argument. |
| 1166 | 1166 | pub fn openW(file_path_w: []const u16, flags: u32, perm: mode_t) OpenError!fd_t { |
| 1167 | _ = perm; | |
| 1167 | 1168 | var options = openOptionsFromFlags(flags); |
| 1168 | 1169 | options.dir = std.fs.cwd().fd; |
| 1169 | 1170 | return windows.OpenFile(file_path_w, options) catch |err| switch (err) { |
| ... | ... | @@ -1273,6 +1274,7 @@ pub fn openatZ(dir_fd: fd_t, file_path: [*:0]const u8, flags: u32, mode: mode_t) |
| 1273 | 1274 | /// TODO currently, this function does not handle all flag combinations |
| 1274 | 1275 | /// or makes use of perm argument. |
| 1275 | 1276 | pub fn openatW(dir_fd: fd_t, file_path_w: []const u16, flags: u32, mode: mode_t) OpenError!fd_t { |
| 1277 | _ = mode; | |
| 1276 | 1278 | var options = openOptionsFromFlags(flags); |
| 1277 | 1279 | options.dir = dir_fd; |
| 1278 | 1280 | return windows.OpenFile(file_path_w, options) catch |err| switch (err) { |
| ... | ... | @@ -2169,6 +2171,7 @@ pub fn mkdirat(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirError!v |
| 2169 | 2171 | pub const mkdiratC = @compileError("deprecated: renamed to mkdiratZ"); |
| 2170 | 2172 | |
| 2171 | 2173 | pub fn mkdiratWasi(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirError!void { |
| 2174 | _ = mode; | |
| 2172 | 2175 | switch (wasi.path_create_directory(dir_fd, sub_dir_path.ptr, sub_dir_path.len)) { |
| 2173 | 2176 | wasi.ESUCCESS => return, |
| 2174 | 2177 | wasi.EACCES => return error.AccessDenied, |
| ... | ... | @@ -2216,6 +2219,7 @@ pub fn mkdiratZ(dir_fd: fd_t, sub_dir_path: [*:0]const u8, mode: u32) MakeDirErr |
| 2216 | 2219 | } |
| 2217 | 2220 | |
| 2218 | 2221 | pub fn mkdiratW(dir_fd: fd_t, sub_path_w: []const u16, mode: u32) MakeDirError!void { |
| 2222 | _ = mode; | |
| 2219 | 2223 | const sub_dir_handle = windows.OpenFile(sub_path_w, .{ |
| 2220 | 2224 | .dir = dir_fd, |
| 2221 | 2225 | .access_mask = windows.GENERIC_READ | windows.SYNCHRONIZE, |
| ... | ... | @@ -2291,6 +2295,7 @@ pub fn mkdirZ(dir_path: [*:0]const u8, mode: u32) MakeDirError!void { |
| 2291 | 2295 | |
| 2292 | 2296 | /// Windows-only. Same as `mkdir` but the parameters is WTF16 encoded. |
| 2293 | 2297 | pub fn mkdirW(dir_path_w: []const u16, mode: u32) MakeDirError!void { |
| 2298 | _ = mode; | |
| 2294 | 2299 | const sub_dir_handle = windows.OpenFile(dir_path_w, .{ |
| 2295 | 2300 | .dir = std.fs.cwd().fd, |
| 2296 | 2301 | .access_mask = windows.GENERIC_READ | windows.SYNCHRONIZE, |
| ... | ... | @@ -3868,6 +3873,7 @@ pub fn accessZ(path: [*:0]const u8, mode: u32) AccessError!void { |
| 3868 | 3873 | /// Otherwise use `access` or `accessC`. |
| 3869 | 3874 | /// TODO currently this ignores `mode`. |
| 3870 | 3875 | pub fn accessW(path: [*:0]const u16, mode: u32) windows.GetFileAttributesError!void { |
| 3876 | _ = mode; | |
| 3871 | 3877 | const ret = try windows.GetFileAttributesW(path); |
| 3872 | 3878 | if (ret != windows.INVALID_FILE_ATTRIBUTES) { |
| 3873 | 3879 | return; |
| ... | ... | @@ -3918,6 +3924,8 @@ pub fn faccessatZ(dirfd: fd_t, path: [*:0]const u8, mode: u32, flags: u32) Acces |
| 3918 | 3924 | /// is NtDll-prefixed, null-terminated, WTF-16 encoded. |
| 3919 | 3925 | /// TODO currently this ignores `mode` and `flags` |
| 3920 | 3926 | pub fn faccessatW(dirfd: fd_t, sub_path_w: [*:0]const u16, mode: u32, flags: u32) AccessError!void { |
| 3927 | _ = mode; | |
| 3928 | _ = flags; | |
| 3921 | 3929 | if (sub_path_w[0] == '.' and sub_path_w[1] == 0) { |
| 3922 | 3930 | return; |
| 3923 | 3931 | } |
| ... | ... | @@ -4895,6 +4903,8 @@ pub fn res_mkquery( |
| 4895 | 4903 | newrr: ?[*]const u8, |
| 4896 | 4904 | buf: []u8, |
| 4897 | 4905 | ) usize { |
| 4906 | _ = data; | |
| 4907 | _ = newrr; | |
| 4898 | 4908 | // This implementation is ported from musl libc. |
| 4899 | 4909 | // A more idiomatic "ziggy" implementation would be welcome. |
| 4900 | 4910 | var name = dname; |
| ... | ... | @@ -5341,7 +5351,7 @@ pub fn sendfile( |
| 5341 | 5351 | ENXIO => return error.Unseekable, |
| 5342 | 5352 | ESPIPE => return error.Unseekable, |
| 5343 | 5353 | else => |err| { |
| 5344 | const discard = unexpectedErrno(err); | |
| 5354 | unexpectedErrno(err) catch {}; | |
| 5345 | 5355 | break :sf; |
| 5346 | 5356 | }, |
| 5347 | 5357 | } |
| ... | ... | @@ -5422,7 +5432,7 @@ pub fn sendfile( |
| 5422 | 5432 | EPIPE => return error.BrokenPipe, |
| 5423 | 5433 | |
| 5424 | 5434 | else => { |
| 5425 | const discard = unexpectedErrno(err); | |
| 5435 | unexpectedErrno(err) catch {}; | |
| 5426 | 5436 | if (amt != 0) { |
| 5427 | 5437 | return amt; |
| 5428 | 5438 | } else { |
| ... | ... | @@ -5484,7 +5494,7 @@ pub fn sendfile( |
| 5484 | 5494 | EPIPE => return error.BrokenPipe, |
| 5485 | 5495 | |
| 5486 | 5496 | else => { |
| 5487 | const discard = unexpectedErrno(err); | |
| 5497 | unexpectedErrno(err) catch {}; | |
| 5488 | 5498 | if (amt != 0) { |
| 5489 | 5499 | return amt; |
| 5490 | 5500 | } else { |
lib/std/os/bits/linux.zig+1-1| ... | ... | @@ -1286,7 +1286,7 @@ pub const CAP_BLOCK_SUSPEND = 36; |
| 1286 | 1286 | pub const CAP_AUDIT_READ = 37; |
| 1287 | 1287 | pub const CAP_LAST_CAP = CAP_AUDIT_READ; |
| 1288 | 1288 | |
| 1289 | pub fn cap_valid(u8: x) bool { | |
| 1289 | pub fn cap_valid(x: u8) bool { | |
| 1290 | 1290 | return x >= 0 and x <= CAP_LAST_CAP; |
| 1291 | 1291 | } |
| 1292 | 1292 |
lib/std/os/linux.zig+2-1| ... | ... | @@ -70,6 +70,7 @@ fn splitValueLE64(val: i64) [2]u32 { |
| 70 | 70 | }; |
| 71 | 71 | } |
| 72 | 72 | fn splitValueBE64(val: i64) [2]u32 { |
| 73 | const u = @bitCast(u64, val); | |
| 73 | 74 | return [2]u32{ |
| 74 | 75 | @truncate(u32, u >> 32), |
| 75 | 76 | @truncate(u32, u), |
| ... | ... | @@ -1022,7 +1023,7 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize |
| 1022 | 1023 | for (msgvec[0..kvlen]) |*msg, i| { |
| 1023 | 1024 | var size: i32 = 0; |
| 1024 | 1025 | const msg_iovlen = @intCast(usize, msg.msg_hdr.msg_iovlen); // kernel side this is treated as unsigned |
| 1025 | for (msg.msg_hdr.msg_iov[0..msg_iovlen]) |iov, j| { | |
| 1026 | for (msg.msg_hdr.msg_iov[0..msg_iovlen]) |iov| { | |
| 1026 | 1027 | if (iov.iov_len > std.math.maxInt(i32) or @addWithOverflow(i32, size, @intCast(i32, iov.iov_len), &size)) { |
| 1027 | 1028 | // batch-send all messages up to the current message |
| 1028 | 1029 | if (next_unsent < i) { |
lib/std/os/linux/bpf.zig+2-2| ... | ... | @@ -1513,7 +1513,7 @@ pub fn map_create(map_type: MapType, key_size: u32, value_size: u32, max_entries |
| 1513 | 1513 | EINVAL => error.MapTypeOrAttrInvalid, |
| 1514 | 1514 | ENOMEM => error.SystemResources, |
| 1515 | 1515 | EPERM => error.AccessDenied, |
| 1516 | else => |err| unexpectedErrno(rc), | |
| 1516 | else => |err| unexpectedErrno(err), | |
| 1517 | 1517 | }; |
| 1518 | 1518 | } |
| 1519 | 1519 | |
| ... | ... | @@ -1539,7 +1539,7 @@ pub fn map_lookup_elem(fd: fd_t, key: []const u8, value: []u8) !void { |
| 1539 | 1539 | EINVAL => return error.FieldInAttrNeedsZeroing, |
| 1540 | 1540 | ENOENT => return error.NotFound, |
| 1541 | 1541 | EPERM => return error.AccessDenied, |
| 1542 | else => |err| return unexpectedErrno(rc), | |
| 1542 | else => |err| return unexpectedErrno(err), | |
| 1543 | 1543 | } |
| 1544 | 1544 | } |
| 1545 | 1545 |
lib/std/os/linux/io_uring.zig+6-3| ... | ... | @@ -284,6 +284,7 @@ pub const IO_Uring = struct { |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | fn copy_cqes_ready(self: *IO_Uring, cqes: []io_uring_cqe, wait_nr: u32) u32 { |
| 287 | _ = wait_nr; | |
| 287 | 288 | const ready = self.cq_ready(); |
| 288 | 289 | const count = std.math.min(cqes.len, ready); |
| 289 | 290 | var head = self.cq.head.*; |
| ... | ... | @@ -320,6 +321,7 @@ pub const IO_Uring = struct { |
| 320 | 321 | /// Not idempotent, calling more than once will result in other CQEs being lost. |
| 321 | 322 | /// Matches the implementation of cqe_seen() in liburing. |
| 322 | 323 | pub fn cqe_seen(self: *IO_Uring, cqe: *io_uring_cqe) void { |
| 324 | _ = cqe; | |
| 323 | 325 | self.cq_advance(1); |
| 324 | 326 | } |
| 325 | 327 | |
| ... | ... | @@ -728,6 +730,7 @@ pub const CompletionQueue = struct { |
| 728 | 730 | } |
| 729 | 731 | |
| 730 | 732 | pub fn deinit(self: *CompletionQueue) void { |
| 733 | _ = self; | |
| 731 | 734 | // A no-op since we now share the mmap with the submission queue. |
| 732 | 735 | // Here for symmetry with the submission queue, and for any future feature support. |
| 733 | 736 | } |
| ... | ... | @@ -1272,12 +1275,12 @@ test "accept/connect/send/recv" { |
| 1272 | 1275 | |
| 1273 | 1276 | var accept_addr: os.sockaddr = undefined; |
| 1274 | 1277 | 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); | |
| 1278 | _ = try ring.accept(0xaaaaaaaa, server, &accept_addr, &accept_addr_len, 0); | |
| 1276 | 1279 | try testing.expectEqual(@as(u32, 1), try ring.submit()); |
| 1277 | 1280 | |
| 1278 | 1281 | const client = try os.socket(address.any.family, os.SOCK_STREAM | os.SOCK_CLOEXEC, 0); |
| 1279 | 1282 | defer os.close(client); |
| 1280 | const connect = try ring.connect(0xcccccccc, client, &address.any, address.getOsSockLen()); | |
| 1283 | _ = try ring.connect(0xcccccccc, client, &address.any, address.getOsSockLen()); | |
| 1281 | 1284 | try testing.expectEqual(@as(u32, 1), try ring.submit()); |
| 1282 | 1285 | |
| 1283 | 1286 | var cqe_accept = try ring.copy_cqe(); |
| ... | ... | @@ -1305,7 +1308,7 @@ test "accept/connect/send/recv" { |
| 1305 | 1308 | |
| 1306 | 1309 | const send = try ring.send(0xeeeeeeee, client, buffer_send[0..], 0); |
| 1307 | 1310 | send.flags |= linux.IOSQE_IO_LINK; |
| 1308 | const recv = try ring.recv(0xffffffff, cqe_accept.res, buffer_recv[0..], 0); | |
| 1311 | _ = try ring.recv(0xffffffff, cqe_accept.res, buffer_recv[0..], 0); | |
| 1309 | 1312 | try testing.expectEqual(@as(u32, 2), try ring.submit()); |
| 1310 | 1313 | |
| 1311 | 1314 | const cqe_send = try ring.copy_cqe(); |
lib/std/os/linux/mips.zig+2-1| ... | ... | @@ -31,7 +31,8 @@ pub fn syscall_pipe(fd: *[2]i32) usize { |
| 31 | 31 | \\ sw $3, 4($4) |
| 32 | 32 | \\ 2: |
| 33 | 33 | : [ret] "={$2}" (-> usize) |
| 34 | : [number] "{$2}" (@enumToInt(SYS.pipe)) | |
| 34 | : [number] "{$2}" (@enumToInt(SYS.pipe)), | |
| 35 | [fd] "{$4}" (fd) | |
| 35 | 36 | : "memory", "cc", "$7" |
| 36 | 37 | ); |
| 37 | 38 | } |
lib/std/os/linux/vdso.zig-1| ... | ... | @@ -15,7 +15,6 @@ pub fn lookup(vername: []const u8, name: []const u8) usize { |
| 15 | 15 | |
| 16 | 16 | const eh = @intToPtr(*elf.Ehdr, vdso_addr); |
| 17 | 17 | var ph_addr: usize = vdso_addr + eh.e_phoff; |
| 18 | const ph = @intToPtr(*elf.Phdr, ph_addr); | |
| 19 | 18 | |
| 20 | 19 | var maybe_dynv: ?[*]usize = null; |
| 21 | 20 | var base: usize = maxInt(usize); |
lib/std/os/test.zig+4| ... | ... | @@ -353,6 +353,7 @@ test "spawn threads" { |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | fn start1(ctx: void) u8 { |
| 356 | _ = ctx; | |
| 356 | 357 | return 0; |
| 357 | 358 | } |
| 358 | 359 | |
| ... | ... | @@ -379,6 +380,7 @@ test "thread local storage" { |
| 379 | 380 | |
| 380 | 381 | threadlocal var x: i32 = 1234; |
| 381 | 382 | fn testTls(context: void) !void { |
| 383 | _ = context; | |
| 382 | 384 | if (x != 1234) return error.TlsBadStartValue; |
| 383 | 385 | x += 1; |
| 384 | 386 | if (x != 1235) return error.TlsBadEndValue; |
| ... | ... | @@ -425,6 +427,7 @@ const IterFnError = error{ |
| 425 | 427 | }; |
| 426 | 428 | |
| 427 | 429 | fn iter_fn(info: *dl_phdr_info, size: usize, counter: *usize) IterFnError!void { |
| 430 | _ = size; | |
| 428 | 431 | // Count how many libraries are loaded |
| 429 | 432 | counter.* += @as(usize, 1); |
| 430 | 433 | |
| ... | ... | @@ -731,6 +734,7 @@ test "sigaction" { |
| 731 | 734 | |
| 732 | 735 | const S = struct { |
| 733 | 736 | fn handler(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_void) callconv(.C) void { |
| 737 | _ = ctx_ptr; | |
| 734 | 738 | // Check that we received the correct signal. |
| 735 | 739 | switch (native_os) { |
| 736 | 740 | .netbsd => { |
lib/std/os/uefi.zig+1| ... | ... | @@ -37,6 +37,7 @@ pub const Guid = extern struct { |
| 37 | 37 | options: std.fmt.FormatOptions, |
| 38 | 38 | writer: anytype, |
| 39 | 39 | ) !void { |
| 40 | _ = options; | |
| 40 | 41 | if (f.len == 0) { |
| 41 | 42 | return std.fmt.format(writer, "{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x:0>12}", .{ |
| 42 | 43 | self.time_low, |
lib/std/os/uefi/protocols/managed_network_protocol.zig+1| ... | ... | @@ -35,6 +35,7 @@ pub const ManagedNetworkProtocol = extern struct { |
| 35 | 35 | /// Translates an IP multicast address to a hardware (MAC) multicast address. |
| 36 | 36 | /// This function may be unsupported in some MNP implementations. |
| 37 | 37 | pub fn mcastIpToMac(self: *const ManagedNetworkProtocol, ipv6flag: bool, ipaddress: *const c_void, mac_address: *MacAddress) Status { |
| 38 | _ = mac_address; | |
| 38 | 39 | return self._mcast_ip_to_mac(self, ipv6flag, ipaddress); |
| 39 | 40 | } |
| 40 | 41 |
lib/std/os/windows.zig-1| ... | ... | @@ -1156,7 +1156,6 @@ pub fn GetFinalPathNameByHandle( |
| 1156 | 1156 | &mount_points_struct.MountPoints[0], |
| 1157 | 1157 | )[0..mount_points_struct.NumberOfMountPoints]; |
| 1158 | 1158 | |
| 1159 | var found: bool = false; | |
| 1160 | 1159 | for (mount_points) |mount_point| { |
| 1161 | 1160 | const symlink = @ptrCast( |
| 1162 | 1161 | [*]const u16, |
lib/std/packed_int_array.zig+1| ... | ... | @@ -194,6 +194,7 @@ pub fn PackedIntArrayEndian(comptime Int: type, comptime endian: Endian, comptim |
| 194 | 194 | |
| 195 | 195 | ///Returns the number of elements in the packed array |
| 196 | 196 | pub fn len(self: Self) usize { |
| 197 | _ = self; | |
| 197 | 198 | return int_count; |
| 198 | 199 | } |
| 199 | 200 |
lib/std/pdb.zig+4-1| ... | ... | @@ -594,6 +594,7 @@ pub const Pdb = struct { |
| 594 | 594 | error.InvalidValue => return error.InvalidDebugInfo, |
| 595 | 595 | else => |e| return e, |
| 596 | 596 | }; |
| 597 | _ = version; | |
| 597 | 598 | sect_cont_offset += @sizeOf(u32); |
| 598 | 599 | } |
| 599 | 600 | while (sect_cont_offset != section_contrib_size) { |
| ... | ... | @@ -617,6 +618,7 @@ pub const Pdb = struct { |
| 617 | 618 | // Parse the InfoStreamHeader. |
| 618 | 619 | const version = try reader.readIntLittle(u32); |
| 619 | 620 | const signature = try reader.readIntLittle(u32); |
| 621 | _ = signature; | |
| 620 | 622 | const age = try reader.readIntLittle(u32); |
| 621 | 623 | const guid = try reader.readBytesNoEof(16); |
| 622 | 624 | |
| ... | ... | @@ -673,6 +675,7 @@ pub const Pdb = struct { |
| 673 | 675 | } |
| 674 | 676 | |
| 675 | 677 | pub fn getSymbolName(self: *Pdb, module: *Module, address: u64) ?[]const u8 { |
| 678 | _ = self; | |
| 676 | 679 | std.debug.assert(module.populated); |
| 677 | 680 | |
| 678 | 681 | var symbol_i: usize = 0; |
| ... | ... | @@ -904,7 +907,7 @@ const Msf = struct { |
| 904 | 907 | // These streams are not used, but still participate in the file |
| 905 | 908 | // and must be taken into account when resolving stream indices. |
| 906 | 909 | const Nil = 0xFFFFFFFF; |
| 907 | for (stream_sizes) |*s, i| { | |
| 910 | for (stream_sizes) |*s| { | |
| 908 | 911 | const size = try directory.reader().readIntLittle(u32); |
| 909 | 912 | s.* = if (size == Nil) 0 else blockCountFromSize(size, superblock.BlockSize); |
| 910 | 913 | } |
lib/std/priority_dequeue.zig+1-1| ... | ... | @@ -428,7 +428,7 @@ pub fn PriorityDequeue(comptime T: type) type { |
| 428 | 428 | warn("{}, ", .{e}); |
| 429 | 429 | } |
| 430 | 430 | warn("array: ", .{}); |
| 431 | for (self.items) |e, i| { | |
| 431 | for (self.items) |e| { | |
| 432 | 432 | warn("{}, ", .{e}); |
| 433 | 433 | } |
| 434 | 434 | warn("len: {} ", .{self.len}); |
lib/std/priority_queue.zig+1-1| ... | ... | @@ -249,7 +249,7 @@ pub fn PriorityQueue(comptime T: type) type { |
| 249 | 249 | warn("{}, ", .{e}); |
| 250 | 250 | } |
| 251 | 251 | warn("array: ", .{}); |
| 252 | for (self.items) |e, i| { | |
| 252 | for (self.items) |e| { | |
| 253 | 253 | warn("{}, ", .{e}); |
| 254 | 254 | } |
| 255 | 255 | warn("len: {} ", .{self.len}); |
lib/std/process.zig+2| ... | ... | @@ -419,6 +419,7 @@ pub const ArgIteratorWindows = struct { |
| 419 | 419 | }; |
| 420 | 420 | } |
| 421 | 421 | fn emitBackslashes(self: *ArgIteratorWindows, buf: *std.ArrayList(u16), emit_count: usize) !void { |
| 422 | _ = self; | |
| 422 | 423 | var i: usize = 0; |
| 423 | 424 | while (i < emit_count) : (i += 1) { |
| 424 | 425 | try buf.append(std.mem.nativeToLittle(u16, '\\')); |
| ... | ... | @@ -748,6 +749,7 @@ pub fn getSelfExeSharedLibPaths(allocator: *Allocator) error{OutOfMemory}![][:0] |
| 748 | 749 | } |
| 749 | 750 | try os.dl_iterate_phdr(&paths, error{OutOfMemory}, struct { |
| 750 | 751 | fn callback(info: *os.dl_phdr_info, size: usize, list: *List) !void { |
| 752 | _ = size; | |
| 751 | 753 | const name = info.dlpi_name orelse return; |
| 752 | 754 | if (name[0] == '/') { |
| 753 | 755 | const item = try list.allocator.dupeZ(u8, mem.spanZ(name)); |
lib/std/rand/ziggurat.zig+1-1| ... | ... | @@ -175,5 +175,5 @@ test "exp dist sanity" { |
| 175 | 175 | test "table gen" { |
| 176 | 176 | if (please_windows_dont_oom) return error.SkipZigTest; |
| 177 | 177 | |
| 178 | const table = NormDist; | |
| 178 | _ = NormDist; | |
| 179 | 179 | } |
lib/std/sort.zig+4| ... | ... | @@ -37,9 +37,11 @@ pub fn binarySearch( |
| 37 | 37 | test "binarySearch" { |
| 38 | 38 | const S = struct { |
| 39 | 39 | fn order_u32(context: void, lhs: u32, rhs: u32) math.Order { |
| 40 | _ = context; | |
| 40 | 41 | return math.order(lhs, rhs); |
| 41 | 42 | } |
| 42 | 43 | fn order_i32(context: void, lhs: i32, rhs: i32) math.Order { |
| 44 | _ = context; | |
| 43 | 45 | return math.order(lhs, rhs); |
| 44 | 46 | } |
| 45 | 47 | }; |
| ... | ... | @@ -1133,6 +1135,7 @@ fn swap( |
| 1133 | 1135 | pub fn asc(comptime T: type) fn (void, T, T) bool { |
| 1134 | 1136 | const impl = struct { |
| 1135 | 1137 | fn inner(context: void, a: T, b: T) bool { |
| 1138 | _ = context; | |
| 1136 | 1139 | return a < b; |
| 1137 | 1140 | } |
| 1138 | 1141 | }; |
| ... | ... | @@ -1144,6 +1147,7 @@ pub fn asc(comptime T: type) fn (void, T, T) bool { |
| 1144 | 1147 | pub fn desc(comptime T: type) fn (void, T, T) bool { |
| 1145 | 1148 | const impl = struct { |
| 1146 | 1149 | fn inner(context: void, a: T, b: T) bool { |
| 1150 | _ = context; | |
| 1147 | 1151 | return a > b; |
| 1148 | 1152 | } |
| 1149 | 1153 | }; |
lib/std/special/c.zig+2| ... | ... | @@ -160,6 +160,7 @@ fn strncmp(_l: [*:0]const u8, _r: [*:0]const u8, _n: usize) callconv(.C) c_int { |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | fn strerror(errnum: c_int) callconv(.C) [*:0]const u8 { |
| 163 | _ = errnum; | |
| 163 | 164 | return "TODO strerror implementation"; |
| 164 | 165 | } |
| 165 | 166 | |
| ... | ... | @@ -173,6 +174,7 @@ test "strncmp" { |
| 173 | 174 | // Avoid dragging in the runtime safety mechanisms into this .o file, |
| 174 | 175 | // unless we're trying to test this file. |
| 175 | 176 | pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { |
| 177 | _ = error_return_trace; | |
| 176 | 178 | if (builtin.is_test) { |
| 177 | 179 | @setCold(true); |
| 178 | 180 | std.debug.panic("{s}", .{msg}); |
lib/std/special/compiler_rt.zig+1| ... | ... | @@ -602,6 +602,7 @@ pub usingnamespace @import("compiler_rt/atomics.zig"); |
| 602 | 602 | // Avoid dragging in the runtime safety mechanisms into this .o file, |
| 603 | 603 | // unless we're trying to test this file. |
| 604 | 604 | pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { |
| 605 | _ = error_return_trace; | |
| 605 | 606 | @setCold(true); |
| 606 | 607 | if (is_test) { |
| 607 | 608 | std.debug.panic("{s}", .{msg}); |
lib/std/special/compiler_rt/addXf3.zig-5| ... | ... | @@ -83,7 +83,6 @@ fn addXf3(comptime T: type, a: T, b: T) T { |
| 83 | 83 | |
| 84 | 84 | const signBit = (@as(Z, 1) << (significandBits + exponentBits)); |
| 85 | 85 | const maxExponent = ((1 << exponentBits) - 1); |
| 86 | const exponentBias = (maxExponent >> 1); | |
| 87 | 86 | |
| 88 | 87 | const implicitBit = (@as(Z, 1) << significandBits); |
| 89 | 88 | const quietBit = implicitBit >> 1; |
| ... | ... | @@ -98,10 +97,6 @@ fn addXf3(comptime T: type, a: T, b: T) T { |
| 98 | 97 | const aAbs = aRep & absMask; |
| 99 | 98 | const bAbs = bRep & absMask; |
| 100 | 99 | |
| 101 | const negative = (aRep & signBit) != 0; | |
| 102 | const exponent = @intCast(i32, aAbs >> significandBits) - exponentBias; | |
| 103 | const significand = (aAbs & significandMask) | implicitBit; | |
| 104 | ||
| 105 | 100 | const infRep = @bitCast(Z, std.math.inf(T)); |
| 106 | 101 | |
| 107 | 102 | // Detect if a or b is zero, infinity, or NaN. |
lib/std/special/compiler_rt/atomics.zig+11| ... | ... | @@ -80,18 +80,21 @@ var spinlocks: SpinlockTable = SpinlockTable{}; |
| 80 | 80 | // Those work on any object no matter the pointer alignment nor its size. |
| 81 | 81 | |
| 82 | 82 | fn __atomic_load(size: u32, src: [*]u8, dest: [*]u8, model: i32) callconv(.C) void { |
| 83 | _ = model; | |
| 83 | 84 | var sl = spinlocks.get(@ptrToInt(src)); |
| 84 | 85 | defer sl.release(); |
| 85 | 86 | @memcpy(dest, src, size); |
| 86 | 87 | } |
| 87 | 88 | |
| 88 | 89 | fn __atomic_store(size: u32, dest: [*]u8, src: [*]u8, model: i32) callconv(.C) void { |
| 90 | _ = model; | |
| 89 | 91 | var sl = spinlocks.get(@ptrToInt(dest)); |
| 90 | 92 | defer sl.release(); |
| 91 | 93 | @memcpy(dest, src, size); |
| 92 | 94 | } |
| 93 | 95 | |
| 94 | 96 | fn __atomic_exchange(size: u32, ptr: [*]u8, val: [*]u8, old: [*]u8, model: i32) callconv(.C) void { |
| 97 | _ = model; | |
| 95 | 98 | var sl = spinlocks.get(@ptrToInt(ptr)); |
| 96 | 99 | defer sl.release(); |
| 97 | 100 | @memcpy(old, ptr, size); |
| ... | ... | @@ -106,6 +109,8 @@ fn __atomic_compare_exchange( |
| 106 | 109 | success: i32, |
| 107 | 110 | failure: i32, |
| 108 | 111 | ) callconv(.C) i32 { |
| 112 | _ = success; | |
| 113 | _ = failure; | |
| 109 | 114 | var sl = spinlocks.get(@ptrToInt(ptr)); |
| 110 | 115 | defer sl.release(); |
| 111 | 116 | for (ptr[0..size]) |b, i| { |
| ... | ... | @@ -135,6 +140,7 @@ comptime { |
| 135 | 140 | fn atomicLoadFn(comptime T: type) fn (*T, i32) callconv(.C) T { |
| 136 | 141 | return struct { |
| 137 | 142 | fn atomic_load_N(src: *T, model: i32) callconv(.C) T { |
| 143 | _ = model; | |
| 138 | 144 | if (@sizeOf(T) > largest_atomic_size) { |
| 139 | 145 | var sl = spinlocks.get(@ptrToInt(src)); |
| 140 | 146 | defer sl.release(); |
| ... | ... | @@ -162,6 +168,7 @@ comptime { |
| 162 | 168 | fn atomicStoreFn(comptime T: type) fn (*T, T, i32) callconv(.C) void { |
| 163 | 169 | return struct { |
| 164 | 170 | fn atomic_store_N(dst: *T, value: T, model: i32) callconv(.C) void { |
| 171 | _ = model; | |
| 165 | 172 | if (@sizeOf(T) > largest_atomic_size) { |
| 166 | 173 | var sl = spinlocks.get(@ptrToInt(dst)); |
| 167 | 174 | defer sl.release(); |
| ... | ... | @@ -189,6 +196,7 @@ comptime { |
| 189 | 196 | fn atomicExchangeFn(comptime T: type) fn (*T, T, i32) callconv(.C) T { |
| 190 | 197 | return struct { |
| 191 | 198 | fn atomic_exchange_N(ptr: *T, val: T, model: i32) callconv(.C) T { |
| 199 | _ = model; | |
| 192 | 200 | if (@sizeOf(T) > largest_atomic_size) { |
| 193 | 201 | var sl = spinlocks.get(@ptrToInt(ptr)); |
| 194 | 202 | defer sl.release(); |
| ... | ... | @@ -218,6 +226,8 @@ comptime { |
| 218 | 226 | fn atomicCompareExchangeFn(comptime T: type) fn (*T, *T, T, i32, i32) callconv(.C) i32 { |
| 219 | 227 | return struct { |
| 220 | 228 | fn atomic_compare_exchange_N(ptr: *T, expected: *T, desired: T, success: i32, failure: i32) callconv(.C) i32 { |
| 229 | _ = success; | |
| 230 | _ = failure; | |
| 221 | 231 | if (@sizeOf(T) > largest_atomic_size) { |
| 222 | 232 | var sl = spinlocks.get(@ptrToInt(ptr)); |
| 223 | 233 | defer sl.release(); |
| ... | ... | @@ -255,6 +265,7 @@ comptime { |
| 255 | 265 | fn fetchFn(comptime T: type, comptime op: builtin.AtomicRmwOp) fn (*T, T, i32) callconv(.C) T { |
| 256 | 266 | return struct { |
| 257 | 267 | pub fn fetch_op_N(ptr: *T, val: T, model: i32) callconv(.C) T { |
| 268 | _ = model; | |
| 258 | 269 | if (@sizeOf(T) > largest_atomic_size) { |
| 259 | 270 | var sl = spinlocks.get(@ptrToInt(ptr)); |
| 260 | 271 | defer sl.release(); |
lib/std/special/compiler_rt/comparedf2_test.zig+1-1| ... | ... | @@ -100,7 +100,7 @@ const test_vectors = init: { |
| 100 | 100 | }; |
| 101 | 101 | |
| 102 | 102 | test "compare f64" { |
| 103 | for (test_vectors) |vector, i| { | |
| 103 | for (test_vectors) |vector| { | |
| 104 | 104 | try std.testing.expect(test__cmpdf2(vector)); |
| 105 | 105 | } |
| 106 | 106 | } |
lib/std/special/compiler_rt/comparesf2_test.zig+1-1| ... | ... | @@ -100,7 +100,7 @@ const test_vectors = init: { |
| 100 | 100 | }; |
| 101 | 101 | |
| 102 | 102 | test "compare f32" { |
| 103 | for (test_vectors) |vector, i| { | |
| 103 | for (test_vectors) |vector| { | |
| 104 | 104 | try std.testing.expect(test__cmpsf2(vector)); |
| 105 | 105 | } |
| 106 | 106 | } |
lib/std/special/compiler_rt/divtf3.zig-1| ... | ... | @@ -12,7 +12,6 @@ const wideMultiply = @import("divdf3.zig").wideMultiply; |
| 12 | 12 | pub fn __divtf3(a: f128, b: f128) callconv(.C) f128 { |
| 13 | 13 | @setRuntimeSafety(builtin.is_test); |
| 14 | 14 | const Z = std.meta.Int(.unsigned, 128); |
| 15 | const SignedZ = std.meta.Int(.signed, 128); | |
| 16 | 15 | |
| 17 | 16 | const significandBits = std.math.floatMantissaBits(f128); |
| 18 | 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 | 46 | const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).Float.bits); |
| 47 | 47 | const srcSigBits = std.math.floatMantissaBits(src_t); |
| 48 | 48 | const dstSigBits = std.math.floatMantissaBits(dst_t); |
| 49 | const SrcShift = std.math.Log2Int(src_rep_t); | |
| 50 | 49 | const DstShift = std.math.Log2Int(dst_rep_t); |
| 51 | 50 | |
| 52 | 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 | 16 | else => unreachable, |
| 17 | 17 | }; |
| 18 | 18 | const typeWidth = @typeInfo(rep_t).Int.bits; |
| 19 | const srep_t = @import("std").meta.Int(.signed, typeWidth); | |
| 20 | 19 | const significandBits = switch (fp_t) { |
| 21 | 20 | f32 => 23, |
| 22 | 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 | 50 | const srcSigBits = std.math.floatMantissaBits(src_t); |
| 51 | 51 | const dstSigBits = std.math.floatMantissaBits(dst_t); |
| 52 | 52 | const SrcShift = std.math.Log2Int(src_rep_t); |
| 53 | const DstShift = std.math.Log2Int(dst_rep_t); | |
| 54 | 53 | |
| 55 | 54 | // Various constants whose values follow from the type parameters. |
| 56 | 55 | // Any reasonable optimizer will fold and propagate all of these. |
lib/std/special/ssp.zig+2| ... | ... | @@ -27,6 +27,8 @@ extern fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8 |
| 27 | 27 | |
| 28 | 28 | // Avoid dragging in the runtime safety mechanisms into this .o file. |
| 29 | 29 | pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { |
| 30 | _ = msg; | |
| 31 | _ = error_return_trace; | |
| 30 | 32 | @setCold(true); |
| 31 | 33 | if (@hasDecl(std.os, "abort")) |
| 32 | 34 | std.os.abort(); |
lib/std/target.zig+1-1| ... | ... | @@ -157,7 +157,7 @@ pub const Target = struct { |
| 157 | 157 | pub fn format( |
| 158 | 158 | self: WindowsVersion, |
| 159 | 159 | comptime fmt: []const u8, |
| 160 | options: std.fmt.FormatOptions, | |
| 160 | _: std.fmt.FormatOptions, | |
| 161 | 161 | out_stream: anytype, |
| 162 | 162 | ) !void { |
| 163 | 163 | if (fmt.len > 0 and fmt[0] == 's') { |
lib/std/testing.zig-1| ... | ... | @@ -191,7 +191,6 @@ test "expectEqual.union(enum)" { |
| 191 | 191 | }; |
| 192 | 192 | |
| 193 | 193 | const a10 = T{ .a = 10 }; |
| 194 | const a20 = T{ .a = 20 }; | |
| 195 | 194 | |
| 196 | 195 | try expectEqual(a10, a10); |
| 197 | 196 | } |
lib/std/unicode.zig+1-1| ... | ... | @@ -210,7 +210,7 @@ pub fn utf8ValidateSlice(s: []const u8) bool { |
| 210 | 210 | return false; |
| 211 | 211 | } |
| 212 | 212 | i += cp_len; |
| 213 | } else |err| { | |
| 213 | } else |_| { | |
| 214 | 214 | return false; |
| 215 | 215 | } |
| 216 | 216 | } |
lib/std/unicode/throughput_test.zig-2| ... | ... | @@ -47,8 +47,6 @@ fn benchmarkCodepointCount(buf: []const u8) !ResultCount { |
| 47 | 47 | pub fn main() !void { |
| 48 | 48 | const stdout = std.io.getStdOut().writer(); |
| 49 | 49 | |
| 50 | const args = try std.process.argsAlloc(std.heap.page_allocator); | |
| 51 | ||
| 52 | 50 | try stdout.print("short ASCII strings\n", .{}); |
| 53 | 51 | { |
| 54 | 52 | const result = try benchmarkCodepointCount("abc"); |
lib/std/x/net/ip.zig+2| ... | ... | @@ -53,6 +53,8 @@ pub const Address = union(enum) { |
| 53 | 53 | opts: fmt.FormatOptions, |
| 54 | 54 | writer: anytype, |
| 55 | 55 | ) !void { |
| 56 | _ = opts; | |
| 57 | _ = layout; | |
| 56 | 58 | switch (self) { |
| 57 | 59 | .ipv4 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }), |
| 58 | 60 | .ipv6 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }), |
lib/std/x/os/io.zig-1| ... | ... | @@ -122,7 +122,6 @@ test "reactor/linux: drive async tcp client/listener pair" { |
| 122 | 122 | |
| 123 | 123 | const IPv4 = std.x.os.IPv4; |
| 124 | 124 | const IPv6 = std.x.os.IPv6; |
| 125 | const Socket = std.x.os.Socket; | |
| 126 | 125 | |
| 127 | 126 | const reactor = try Reactor.init(.{ .close_on_exec = true }); |
| 128 | 127 | defer reactor.deinit(); |
lib/std/x/os/net.zig+2| ... | ... | @@ -143,6 +143,7 @@ pub const IPv4 = extern struct { |
| 143 | 143 | opts: fmt.FormatOptions, |
| 144 | 144 | writer: anytype, |
| 145 | 145 | ) !void { |
| 146 | _ = opts; | |
| 146 | 147 | if (comptime layout.len != 0 and layout[0] != 's') { |
| 147 | 148 | @compileError("Unsupported format specifier for IPv4 type '" ++ layout ++ "'."); |
| 148 | 149 | } |
| ... | ... | @@ -352,6 +353,7 @@ pub const IPv6 = extern struct { |
| 352 | 353 | opts: fmt.FormatOptions, |
| 353 | 354 | writer: anytype, |
| 354 | 355 | ) !void { |
| 356 | _ = opts; | |
| 355 | 357 | const specifier = comptime &[_]u8{if (layout.len == 0) 'x' else switch (layout[0]) { |
| 356 | 358 | 'x', 'X' => |specifier| specifier, |
| 357 | 359 | 's' => 'x', |
lib/std/x/os/socket.zig+4-2| ... | ... | @@ -117,7 +117,7 @@ pub const Socket = struct { |
| 117 | 117 | }; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | /// Returns the number of bytes that make up the `sockaddr` equivalent to the address. | |
| 120 | /// Returns the number of bytes that make up the `sockaddr` equivalent to the address. | |
| 121 | 121 | pub fn getNativeSize(self: Socket.Address) u32 { |
| 122 | 122 | return switch (self) { |
| 123 | 123 | .ipv4 => @sizeOf(os.sockaddr_in), |
| ... | ... | @@ -132,6 +132,8 @@ pub const Socket = struct { |
| 132 | 132 | opts: fmt.FormatOptions, |
| 133 | 133 | writer: anytype, |
| 134 | 134 | ) !void { |
| 135 | _ = opts; | |
| 136 | _ = layout; | |
| 135 | 137 | switch (self) { |
| 136 | 138 | .ipv4 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }), |
| 137 | 139 | .ipv6 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }), |
| ... | ... | @@ -280,7 +282,7 @@ pub const Socket = struct { |
| 280 | 282 | /// |
| 281 | 283 | /// Microsoft's documentation and glibc denote the fields to be unsigned |
| 282 | 284 | /// short's on Windows, whereas glibc and musl denote the fields to be |
| 283 | /// int's on every other platform. | |
| 285 | /// int's on every other platform. | |
| 284 | 286 | pub const Linger = extern struct { |
| 285 | 287 | pub const Field = switch (native_os.tag) { |
| 286 | 288 | .windows => c_ushort, |
lib/std/x/os/socket_windows.zig+7-3| ... | ... | @@ -292,6 +292,7 @@ pub fn Mixin(comptime Socket: type) type { |
| 292 | 292 | /// with a set of flags specified. It returns the number of bytes that were |
| 293 | 293 | /// read into the buffer provided. |
| 294 | 294 | pub fn readMessage(self: Socket, msg: *Socket.Message, flags: u32) !usize { |
| 295 | _ = flags; | |
| 295 | 296 | const call = try windows.loadWinsockExtensionFunction(ws2_32.LPFN_WSARECVMSG, self.fd, ws2_32.WSAID_WSARECVMSG); |
| 296 | 297 | |
| 297 | 298 | var num_bytes: u32 = undefined; |
| ... | ... | @@ -367,16 +368,19 @@ pub fn Mixin(comptime Socket: type) type { |
| 367 | 368 | |
| 368 | 369 | /// Query and return the latest cached error on the socket. |
| 369 | 370 | pub fn getError(self: Socket) !void { |
| 371 | _ = self; | |
| 370 | 372 | return {}; |
| 371 | 373 | } |
| 372 | 374 | |
| 373 | 375 | /// Query the read buffer size of the socket. |
| 374 | 376 | pub fn getReadBufferSize(self: Socket) !u32 { |
| 377 | _ = self; | |
| 375 | 378 | return 0; |
| 376 | 379 | } |
| 377 | 380 | |
| 378 | 381 | /// Query the write buffer size of the socket. |
| 379 | 382 | pub fn getWriteBufferSize(self: Socket) !u32 { |
| 383 | _ = self; | |
| 380 | 384 | return 0; |
| 381 | 385 | } |
| 382 | 386 | |
| ... | ... | @@ -406,7 +410,7 @@ pub fn Mixin(comptime Socket: type) type { |
| 406 | 410 | |
| 407 | 411 | /// On connection-oriented sockets, have keep-alive messages be sent periodically. The timing in which keep-alive |
| 408 | 412 | /// messages are sent are dependant on operating system settings. It returns `error.UnsupportedSocketOption` if |
| 409 | /// the host does not support periodically sending keep-alive messages on connection-oriented sockets. | |
| 413 | /// the host does not support periodically sending keep-alive messages on connection-oriented sockets. | |
| 410 | 414 | pub fn setKeepAlive(self: Socket, enabled: bool) !void { |
| 411 | 415 | return self.setOption(ws2_32.SOL_SOCKET, ws2_32.SO_KEEPALIVE, mem.asBytes(&@as(u32, @boolToInt(enabled)))); |
| 412 | 416 | } |
| ... | ... | @@ -438,7 +442,7 @@ pub fn Mixin(comptime Socket: type) type { |
| 438 | 442 | |
| 439 | 443 | /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is |
| 440 | 444 | /// set on a non-blocking socket. |
| 441 | /// | |
| 445 | /// | |
| 442 | 446 | /// Set a timeout on the socket that is to occur if no messages are successfully written |
| 443 | 447 | /// to its bound destination after a specified number of milliseconds. A subsequent write |
| 444 | 448 | /// to the socket will thereafter return `error.WouldBlock` should the timeout be exceeded. |
| ... | ... | @@ -448,7 +452,7 @@ pub fn Mixin(comptime Socket: type) type { |
| 448 | 452 | |
| 449 | 453 | /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is |
| 450 | 454 | /// set on a non-blocking socket. |
| 451 | /// | |
| 455 | /// | |
| 452 | 456 | /// Set a timeout on the socket that is to occur if no messages are successfully read |
| 453 | 457 | /// from its bound destination after a specified number of milliseconds. A subsequent |
| 454 | 458 | /// read from the socket will thereafter return `error.WouldBlock` should the timeout be |
lib/std/zig/ast.zig+1-1| ... | ... | @@ -1866,7 +1866,7 @@ pub const Tree = struct { |
| 1866 | 1866 | } |
| 1867 | 1867 | |
| 1868 | 1868 | fn fullStructInit(tree: Tree, info: full.StructInit.Ast) full.StructInit { |
| 1869 | const token_tags = tree.tokens.items(.tag); | |
| 1869 | _ = tree; | |
| 1870 | 1870 | var result: full.StructInit = .{ |
| 1871 | 1871 | .ast = info, |
| 1872 | 1872 | }; |
lib/std/zig/c_builtins.zig+2| ... | ... | @@ -136,6 +136,7 @@ pub inline fn __builtin_strcmp(s1: [*c]const u8, s2: [*c]const u8) c_int { |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | pub inline fn __builtin_object_size(ptr: ?*const c_void, ty: c_int) usize { |
| 139 | _ = ptr; | |
| 139 | 140 | // clang semantics match gcc's: https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html |
| 140 | 141 | // If it is not possible to determine which objects ptr points to at compile time, |
| 141 | 142 | // __builtin_object_size should return (size_t) -1 for type 0 or 1 and (size_t) 0 |
| ... | ... | @@ -186,6 +187,7 @@ pub inline fn __builtin_memcpy( |
| 186 | 187 | /// The return value of __builtin_expect is `expr`. `c` is the expected value |
| 187 | 188 | /// of `expr` and is used as a hint to the compiler in C. Here it is unused. |
| 188 | 189 | pub inline fn __builtin_expect(expr: c_long, c: c_long) c_long { |
| 190 | _ = c; | |
| 189 | 191 | return expr; |
| 190 | 192 | } |
| 191 | 193 |
lib/std/zig/fmt.zig+2| ... | ... | @@ -8,6 +8,7 @@ pub fn formatId( |
| 8 | 8 | options: std.fmt.FormatOptions, |
| 9 | 9 | writer: anytype, |
| 10 | 10 | ) !void { |
| 11 | _ = fmt; | |
| 11 | 12 | if (isValidId(bytes)) { |
| 12 | 13 | return writer.writeAll(bytes); |
| 13 | 14 | } |
| ... | ... | @@ -41,6 +42,7 @@ pub fn formatEscapes( |
| 41 | 42 | options: std.fmt.FormatOptions, |
| 42 | 43 | writer: anytype, |
| 43 | 44 | ) !void { |
| 45 | _ = options; | |
| 44 | 46 | for (bytes) |byte| switch (byte) { |
| 45 | 47 | '\n' => try writer.writeAll("\\n"), |
| 46 | 48 | '\r' => try writer.writeAll("\\r"), |
lib/std/zig/parse.zig+26-26| ... | ... | @@ -586,7 +586,7 @@ const Parser = struct { |
| 586 | 586 | const thread_local_token = p.eatToken(.keyword_threadlocal); |
| 587 | 587 | const var_decl = try p.parseVarDecl(); |
| 588 | 588 | if (var_decl != 0) { |
| 589 | const semicolon_token = try p.expectToken(.semicolon); | |
| 589 | _ = try p.expectToken(.semicolon); | |
| 590 | 590 | return var_decl; |
| 591 | 591 | } |
| 592 | 592 | if (thread_local_token != null) { |
| ... | ... | @@ -614,7 +614,7 @@ const Parser = struct { |
| 614 | 614 | fn expectUsingNamespace(p: *Parser) !Node.Index { |
| 615 | 615 | const usingnamespace_token = p.assertToken(.keyword_usingnamespace); |
| 616 | 616 | const expr = try p.expectExpr(); |
| 617 | const semicolon_token = try p.expectToken(.semicolon); | |
| 617 | _ = try p.expectToken(.semicolon); | |
| 618 | 618 | return p.addNode(.{ |
| 619 | 619 | .tag = .@"usingnamespace", |
| 620 | 620 | .main_token = usingnamespace_token, |
| ... | ... | @@ -647,7 +647,7 @@ const Parser = struct { |
| 647 | 647 | const align_expr = try p.parseByteAlign(); |
| 648 | 648 | const section_expr = try p.parseLinkSection(); |
| 649 | 649 | const callconv_expr = try p.parseCallconv(); |
| 650 | const bang_token = p.eatToken(.bang); | |
| 650 | _ = p.eatToken(.bang); | |
| 651 | 651 | |
| 652 | 652 | const return_type_expr = try p.parseTypeExpr(); |
| 653 | 653 | if (return_type_expr == 0) { |
| ... | ... | @@ -775,7 +775,7 @@ const Parser = struct { |
| 775 | 775 | |
| 776 | 776 | /// ContainerField <- KEYWORD_comptime? IDENTIFIER (COLON (KEYWORD_anytype / TypeExpr) ByteAlign?)? (EQUAL Expr)? |
| 777 | 777 | fn expectContainerField(p: *Parser) !Node.Index { |
| 778 | const comptime_token = p.eatToken(.keyword_comptime); | |
| 778 | _ = p.eatToken(.keyword_comptime); | |
| 779 | 779 | const name_token = p.assertToken(.identifier); |
| 780 | 780 | |
| 781 | 781 | var align_expr: Node.Index = 0; |
| ... | ... | @@ -967,7 +967,7 @@ const Parser = struct { |
| 967 | 967 | _ = try p.expectToken(.l_paren); |
| 968 | 968 | const condition = try p.expectExpr(); |
| 969 | 969 | _ = try p.expectToken(.r_paren); |
| 970 | const then_payload = try p.parsePtrPayload(); | |
| 970 | _ = try p.parsePtrPayload(); | |
| 971 | 971 | |
| 972 | 972 | // TODO propose to change the syntax so that semicolons are always required |
| 973 | 973 | // inside if statements, even if there is an `else`. |
| ... | ... | @@ -992,7 +992,7 @@ const Parser = struct { |
| 992 | 992 | else_required = true; |
| 993 | 993 | break :blk assign_expr; |
| 994 | 994 | }; |
| 995 | const else_token = p.eatToken(.keyword_else) orelse { | |
| 995 | _ = p.eatToken(.keyword_else) orelse { | |
| 996 | 996 | if (else_required) { |
| 997 | 997 | try p.warn(.expected_semi_or_else); |
| 998 | 998 | } |
| ... | ... | @@ -1005,7 +1005,7 @@ const Parser = struct { |
| 1005 | 1005 | }, |
| 1006 | 1006 | }); |
| 1007 | 1007 | }; |
| 1008 | const else_payload = try p.parsePayload(); | |
| 1008 | _ = try p.parsePayload(); | |
| 1009 | 1009 | const else_expr = try p.expectStatement(); |
| 1010 | 1010 | return p.addNode(.{ |
| 1011 | 1011 | .tag = .@"if", |
| ... | ... | @@ -1087,7 +1087,7 @@ const Parser = struct { |
| 1087 | 1087 | else_required = true; |
| 1088 | 1088 | break :blk assign_expr; |
| 1089 | 1089 | }; |
| 1090 | const else_token = p.eatToken(.keyword_else) orelse { | |
| 1090 | _ = p.eatToken(.keyword_else) orelse { | |
| 1091 | 1091 | if (else_required) { |
| 1092 | 1092 | try p.warn(.expected_semi_or_else); |
| 1093 | 1093 | } |
| ... | ... | @@ -1122,7 +1122,7 @@ const Parser = struct { |
| 1122 | 1122 | _ = try p.expectToken(.l_paren); |
| 1123 | 1123 | const condition = try p.expectExpr(); |
| 1124 | 1124 | _ = try p.expectToken(.r_paren); |
| 1125 | const then_payload = try p.parsePtrPayload(); | |
| 1125 | _ = try p.parsePtrPayload(); | |
| 1126 | 1126 | const cont_expr = try p.parseWhileContinueExpr(); |
| 1127 | 1127 | |
| 1128 | 1128 | // TODO propose to change the syntax so that semicolons are always required |
| ... | ... | @@ -1162,7 +1162,7 @@ const Parser = struct { |
| 1162 | 1162 | else_required = true; |
| 1163 | 1163 | break :blk assign_expr; |
| 1164 | 1164 | }; |
| 1165 | const else_token = p.eatToken(.keyword_else) orelse { | |
| 1165 | _ = p.eatToken(.keyword_else) orelse { | |
| 1166 | 1166 | if (else_required) { |
| 1167 | 1167 | try p.warn(.expected_semi_or_else); |
| 1168 | 1168 | } |
| ... | ... | @@ -1189,7 +1189,7 @@ const Parser = struct { |
| 1189 | 1189 | }); |
| 1190 | 1190 | } |
| 1191 | 1191 | }; |
| 1192 | const else_payload = try p.parsePayload(); | |
| 1192 | _ = try p.parsePayload(); | |
| 1193 | 1193 | const else_expr = try p.expectStatement(); |
| 1194 | 1194 | return p.addNode(.{ |
| 1195 | 1195 | .tag = .@"while", |
| ... | ... | @@ -1550,7 +1550,7 @@ const Parser = struct { |
| 1550 | 1550 | }, |
| 1551 | 1551 | .l_bracket => switch (p.token_tags[p.tok_i + 1]) { |
| 1552 | 1552 | .asterisk => { |
| 1553 | const lbracket = p.nextToken(); | |
| 1553 | _ = p.nextToken(); | |
| 1554 | 1554 | const asterisk = p.nextToken(); |
| 1555 | 1555 | var sentinel: Node.Index = 0; |
| 1556 | 1556 | prefix: { |
| ... | ... | @@ -1907,7 +1907,7 @@ const Parser = struct { |
| 1907 | 1907 | if (found_payload == 0) try p.warn(.expected_loop_payload); |
| 1908 | 1908 | |
| 1909 | 1909 | const then_expr = try p.expectExpr(); |
| 1910 | const else_token = p.eatToken(.keyword_else) orelse { | |
| 1910 | _ = p.eatToken(.keyword_else) orelse { | |
| 1911 | 1911 | return p.addNode(.{ |
| 1912 | 1912 | .tag = .for_simple, |
| 1913 | 1913 | .main_token = for_token, |
| ... | ... | @@ -1938,11 +1938,11 @@ const Parser = struct { |
| 1938 | 1938 | _ = try p.expectToken(.l_paren); |
| 1939 | 1939 | const condition = try p.expectExpr(); |
| 1940 | 1940 | _ = try p.expectToken(.r_paren); |
| 1941 | const then_payload = try p.parsePtrPayload(); | |
| 1941 | _ = try p.parsePtrPayload(); | |
| 1942 | 1942 | const cont_expr = try p.parseWhileContinueExpr(); |
| 1943 | 1943 | |
| 1944 | 1944 | const then_expr = try p.expectExpr(); |
| 1945 | const else_token = p.eatToken(.keyword_else) orelse { | |
| 1945 | _ = p.eatToken(.keyword_else) orelse { | |
| 1946 | 1946 | if (cont_expr == 0) { |
| 1947 | 1947 | return p.addNode(.{ |
| 1948 | 1948 | .tag = .while_simple, |
| ... | ... | @@ -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 | 1970 | const else_expr = try p.expectExpr(); |
| 1971 | 1971 | return p.addNode(.{ |
| 1972 | 1972 | .tag = .@"while", |
| ... | ... | @@ -2104,7 +2104,7 @@ const Parser = struct { |
| 2104 | 2104 | /// FnCallArguments <- LPAREN ExprList RPAREN |
| 2105 | 2105 | /// ExprList <- (Expr COMMA)* Expr? |
| 2106 | 2106 | fn parseSuffixExpr(p: *Parser) !Node.Index { |
| 2107 | if (p.eatToken(.keyword_async)) |async_token| { | |
| 2107 | if (p.eatToken(.keyword_async)) |_| { | |
| 2108 | 2108 | var res = try p.expectPrimaryTypeExpr(); |
| 2109 | 2109 | while (true) { |
| 2110 | 2110 | const node = try p.parseSuffixOp(res); |
| ... | ... | @@ -2565,8 +2565,8 @@ const Parser = struct { |
| 2565 | 2565 | p.tok_i += 2; |
| 2566 | 2566 | while (true) { |
| 2567 | 2567 | if (p.eatToken(.r_brace)) |_| break; |
| 2568 | const doc_comment = try p.eatDocComments(); | |
| 2569 | const identifier = try p.expectToken(.identifier); | |
| 2568 | _ = try p.eatDocComments(); | |
| 2569 | _ = try p.expectToken(.identifier); | |
| 2570 | 2570 | switch (p.token_tags[p.tok_i]) { |
| 2571 | 2571 | .comma => p.tok_i += 1, |
| 2572 | 2572 | .r_brace => { |
| ... | ... | @@ -2634,7 +2634,7 @@ const Parser = struct { |
| 2634 | 2634 | if (found_payload == 0) try p.warn(.expected_loop_payload); |
| 2635 | 2635 | |
| 2636 | 2636 | const then_expr = try p.expectTypeExpr(); |
| 2637 | const else_token = p.eatToken(.keyword_else) orelse { | |
| 2637 | _ = p.eatToken(.keyword_else) orelse { | |
| 2638 | 2638 | return p.addNode(.{ |
| 2639 | 2639 | .tag = .for_simple, |
| 2640 | 2640 | .main_token = for_token, |
| ... | ... | @@ -2665,11 +2665,11 @@ const Parser = struct { |
| 2665 | 2665 | _ = try p.expectToken(.l_paren); |
| 2666 | 2666 | const condition = try p.expectExpr(); |
| 2667 | 2667 | _ = try p.expectToken(.r_paren); |
| 2668 | const then_payload = try p.parsePtrPayload(); | |
| 2668 | _ = try p.parsePtrPayload(); | |
| 2669 | 2669 | const cont_expr = try p.parseWhileContinueExpr(); |
| 2670 | 2670 | |
| 2671 | 2671 | const then_expr = try p.expectTypeExpr(); |
| 2672 | const else_token = p.eatToken(.keyword_else) orelse { | |
| 2672 | _ = p.eatToken(.keyword_else) orelse { | |
| 2673 | 2673 | if (cont_expr == 0) { |
| 2674 | 2674 | return p.addNode(.{ |
| 2675 | 2675 | .tag = .while_simple, |
| ... | ... | @@ -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 | 2697 | const else_expr = try p.expectTypeExpr(); |
| 2698 | 2698 | return p.addNode(.{ |
| 2699 | 2699 | .tag = .@"while", |
| ... | ... | @@ -3570,12 +3570,12 @@ const Parser = struct { |
| 3570 | 3570 | _ = try p.expectToken(.l_paren); |
| 3571 | 3571 | const condition = try p.expectExpr(); |
| 3572 | 3572 | _ = try p.expectToken(.r_paren); |
| 3573 | const then_payload = try p.parsePtrPayload(); | |
| 3573 | _ = try p.parsePtrPayload(); | |
| 3574 | 3574 | |
| 3575 | 3575 | const then_expr = try bodyParseFn(p); |
| 3576 | 3576 | if (then_expr == 0) return p.fail(.invalid_token); |
| 3577 | 3577 | |
| 3578 | const else_token = p.eatToken(.keyword_else) orelse return p.addNode(.{ | |
| 3578 | _ = p.eatToken(.keyword_else) orelse return p.addNode(.{ | |
| 3579 | 3579 | .tag = .if_simple, |
| 3580 | 3580 | .main_token = if_token, |
| 3581 | 3581 | .data = .{ |
| ... | ... | @@ -3583,7 +3583,7 @@ const Parser = struct { |
| 3583 | 3583 | .rhs = then_expr, |
| 3584 | 3584 | }, |
| 3585 | 3585 | }); |
| 3586 | const else_payload = try p.parsePayload(); | |
| 3586 | _ = try p.parsePayload(); | |
| 3587 | 3587 | const else_expr = try bodyParseFn(p); |
| 3588 | 3588 | if (else_expr == 0) return p.fail(.invalid_token); |
| 3589 | 3589 |
lib/std/zig/parser_test.zig-1| ... | ... | @@ -5201,7 +5201,6 @@ fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *b |
| 5201 | 5201 | defer tree.deinit(allocator); |
| 5202 | 5202 | |
| 5203 | 5203 | for (tree.errors) |parse_error| { |
| 5204 | const token_start = tree.tokens.items(.start)[parse_error.token]; | |
| 5205 | 5204 | const loc = tree.tokenLocation(0, parse_error.token); |
| 5206 | 5205 | try stderr.print("(memory buffer):{d}:{d}: error: ", .{ loc.line + 1, loc.column + 1 }); |
| 5207 | 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 | 1086 | } |
| 1087 | 1087 | |
| 1088 | 1088 | if (while_node.ast.else_expr != 0) { |
| 1089 | const first_else_expr_tok = tree.firstToken(while_node.ast.else_expr); | |
| 1090 | ||
| 1091 | 1089 | if (indent_then_expr) { |
| 1092 | 1090 | ais.pushIndent(); |
| 1093 | 1091 | try renderExpression(gpa, ais, tree, while_node.ast.then_expr, .newline); |
| ... | ... | @@ -1133,7 +1131,6 @@ fn renderContainerField( |
| 1133 | 1131 | field: ast.full.ContainerField, |
| 1134 | 1132 | space: Space, |
| 1135 | 1133 | ) Error!void { |
| 1136 | const main_tokens = tree.nodes.items(.main_token); | |
| 1137 | 1134 | if (field.comptime_token) |t| { |
| 1138 | 1135 | try renderToken(ais, tree, t, .space); // comptime |
| 1139 | 1136 | } |
| ... | ... | @@ -1519,7 +1516,6 @@ fn renderBlock( |
| 1519 | 1516 | ) Error!void { |
| 1520 | 1517 | const token_tags = tree.tokens.items(.tag); |
| 1521 | 1518 | const node_tags = tree.nodes.items(.tag); |
| 1522 | const nodes_data = tree.nodes.items(.data); | |
| 1523 | 1519 | const lbrace = tree.nodes.items(.main_token)[block_node]; |
| 1524 | 1520 | |
| 1525 | 1521 | if (token_tags[lbrace - 1] == .colon and |
| ... | ... | @@ -1617,7 +1613,6 @@ fn renderArrayInit( |
| 1617 | 1613 | space: Space, |
| 1618 | 1614 | ) Error!void { |
| 1619 | 1615 | const token_tags = tree.tokens.items(.tag); |
| 1620 | const token_starts = tree.tokens.items(.start); | |
| 1621 | 1616 | |
| 1622 | 1617 | if (array_init.ast.type_expr == 0) { |
| 1623 | 1618 | try renderToken(ais, tree, array_init.ast.lbrace - 1, .none); // . |
| ... | ... | @@ -2046,7 +2041,6 @@ fn renderCall( |
| 2046 | 2041 | space: Space, |
| 2047 | 2042 | ) Error!void { |
| 2048 | 2043 | const token_tags = tree.tokens.items(.tag); |
| 2049 | const main_tokens = tree.nodes.items(.main_token); | |
| 2050 | 2044 | |
| 2051 | 2045 | if (call.async_token) |async_token| { |
| 2052 | 2046 | try renderToken(ais, tree, async_token, .space); |
lib/std/zig/system.zig+3-9| ... | ... | @@ -200,6 +200,7 @@ pub const NativePaths = struct { |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | fn appendArray(self: *NativePaths, array: *ArrayList([:0]u8), s: []const u8) !void { |
| 203 | _ = self; | |
| 203 | 204 | const item = try array.allocator.dupeZ(u8, s); |
| 204 | 205 | errdefer array.allocator.free(item); |
| 205 | 206 | try array.append(item); |
| ... | ... | @@ -332,7 +333,7 @@ pub const NativeTargetInfo = struct { |
| 332 | 333 | if (std.builtin.Version.parse(buf[0 .. len - 1])) |ver| { |
| 333 | 334 | os.version_range.semver.min = ver; |
| 334 | 335 | os.version_range.semver.max = ver; |
| 335 | } else |err| { | |
| 336 | } else |_| { | |
| 336 | 337 | return error.OSVersionDetectionFail; |
| 337 | 338 | } |
| 338 | 339 | }, |
| ... | ... | @@ -478,13 +479,6 @@ pub const NativeTargetInfo = struct { |
| 478 | 479 | } |
| 479 | 480 | const ld_info_list = ld_info_list_buffer[0..ld_info_list_len]; |
| 480 | 481 | |
| 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 | 482 | // Best case scenario: the executable is dynamically linked, and we can iterate |
| 489 | 483 | // over our own shared objects and find a dynamic linker. |
| 490 | 484 | self_exe: { |
| ... | ... | @@ -838,7 +832,7 @@ pub const NativeTargetInfo = struct { |
| 838 | 832 | |
| 839 | 833 | if (dynstr) |ds| { |
| 840 | 834 | 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); | |
| 835 | const strtab_read_len = try preadMin(file, &strtab_buf, ds.offset, strtab_len); | |
| 842 | 836 | const strtab = strtab_buf[0..strtab_read_len]; |
| 843 | 837 | // TODO this pointer cast should not be necessary |
| 844 | 838 | const rpoff_usize = std.math.cast(usize, rpoff) catch |err| switch (err) { |
lib/std/zig/system/macos.zig+2-2| ... | ... | @@ -68,10 +68,10 @@ pub fn detect(target_os: *Target.Os) !void { |
| 68 | 68 | return; |
| 69 | 69 | } |
| 70 | 70 | continue; |
| 71 | } else |err| { | |
| 71 | } else |_| { | |
| 72 | 72 | return error.OSVersionDetectionFail; |
| 73 | 73 | } |
| 74 | } else |err| { | |
| 74 | } else |_| { | |
| 75 | 75 | return error.OSVersionDetectionFail; |
| 76 | 76 | } |
| 77 | 77 | } |
lib/std/zig/system/x86.zig+1| ... | ... | @@ -28,6 +28,7 @@ inline fn hasMask(input: u32, mask: u32) bool { |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | pub fn detectNativeCpuAndFeatures(arch: Target.Cpu.Arch, os: Target.Os, cross_target: CrossTarget) Target.Cpu { |
| 31 | _ = cross_target; | |
| 31 | 32 | var cpu = Target.Cpu{ |
| 32 | 33 | .arch = arch, |
| 33 | 34 | .model = Target.Cpu.Model.generic(arch), |
lib/std/zig/tokenizer.zig-1| ... | ... | @@ -416,7 +416,6 @@ pub const Tokenizer = struct { |
| 416 | 416 | self.pending_invalid_token = null; |
| 417 | 417 | return token; |
| 418 | 418 | } |
| 419 | const start_index = self.index; | |
| 420 | 419 | var state: State = .start; |
| 421 | 420 | var result = Token{ |
| 422 | 421 | .tag = .eof, |
src/AstGen.zig+415-323| ... | ... | @@ -206,7 +206,6 @@ pub const ResultLoc = union(enum) { |
| 206 | 206 | }; |
| 207 | 207 | |
| 208 | 208 | fn strategy(rl: ResultLoc, block_scope: *GenZir) Strategy { |
| 209 | var elide_store_to_block_ptr_instructions = false; | |
| 210 | 209 | switch (rl) { |
| 211 | 210 | // In this branch there will not be any store_to_block_ptr instructions. |
| 212 | 211 | .discard, .none, .none_or_ref, .ty, .ref => return .{ |
| ... | ... | @@ -482,61 +481,61 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr |
| 482 | 481 | |
| 483 | 482 | .assign => { |
| 484 | 483 | try assign(gz, scope, node); |
| 485 | return rvalue(gz, scope, rl, .void_value, node); | |
| 484 | return rvalue(gz, rl, .void_value, node); | |
| 486 | 485 | }, |
| 487 | 486 | |
| 488 | 487 | .assign_bit_shift_left => { |
| 489 | 488 | try assignShift(gz, scope, node, .shl); |
| 490 | return rvalue(gz, scope, rl, .void_value, node); | |
| 489 | return rvalue(gz, rl, .void_value, node); | |
| 491 | 490 | }, |
| 492 | 491 | .assign_bit_shift_right => { |
| 493 | 492 | try assignShift(gz, scope, node, .shr); |
| 494 | return rvalue(gz, scope, rl, .void_value, node); | |
| 493 | return rvalue(gz, rl, .void_value, node); | |
| 495 | 494 | }, |
| 496 | 495 | |
| 497 | 496 | .assign_bit_and => { |
| 498 | 497 | try assignOp(gz, scope, node, .bit_and); |
| 499 | return rvalue(gz, scope, rl, .void_value, node); | |
| 498 | return rvalue(gz, rl, .void_value, node); | |
| 500 | 499 | }, |
| 501 | 500 | .assign_bit_or => { |
| 502 | 501 | try assignOp(gz, scope, node, .bit_or); |
| 503 | return rvalue(gz, scope, rl, .void_value, node); | |
| 502 | return rvalue(gz, rl, .void_value, node); | |
| 504 | 503 | }, |
| 505 | 504 | .assign_bit_xor => { |
| 506 | 505 | try assignOp(gz, scope, node, .xor); |
| 507 | return rvalue(gz, scope, rl, .void_value, node); | |
| 506 | return rvalue(gz, rl, .void_value, node); | |
| 508 | 507 | }, |
| 509 | 508 | .assign_div => { |
| 510 | 509 | try assignOp(gz, scope, node, .div); |
| 511 | return rvalue(gz, scope, rl, .void_value, node); | |
| 510 | return rvalue(gz, rl, .void_value, node); | |
| 512 | 511 | }, |
| 513 | 512 | .assign_sub => { |
| 514 | 513 | try assignOp(gz, scope, node, .sub); |
| 515 | return rvalue(gz, scope, rl, .void_value, node); | |
| 514 | return rvalue(gz, rl, .void_value, node); | |
| 516 | 515 | }, |
| 517 | 516 | .assign_sub_wrap => { |
| 518 | 517 | try assignOp(gz, scope, node, .subwrap); |
| 519 | return rvalue(gz, scope, rl, .void_value, node); | |
| 518 | return rvalue(gz, rl, .void_value, node); | |
| 520 | 519 | }, |
| 521 | 520 | .assign_mod => { |
| 522 | 521 | try assignOp(gz, scope, node, .mod_rem); |
| 523 | return rvalue(gz, scope, rl, .void_value, node); | |
| 522 | return rvalue(gz, rl, .void_value, node); | |
| 524 | 523 | }, |
| 525 | 524 | .assign_add => { |
| 526 | 525 | try assignOp(gz, scope, node, .add); |
| 527 | return rvalue(gz, scope, rl, .void_value, node); | |
| 526 | return rvalue(gz, rl, .void_value, node); | |
| 528 | 527 | }, |
| 529 | 528 | .assign_add_wrap => { |
| 530 | 529 | try assignOp(gz, scope, node, .addwrap); |
| 531 | return rvalue(gz, scope, rl, .void_value, node); | |
| 530 | return rvalue(gz, rl, .void_value, node); | |
| 532 | 531 | }, |
| 533 | 532 | .assign_mul => { |
| 534 | 533 | try assignOp(gz, scope, node, .mul); |
| 535 | return rvalue(gz, scope, rl, .void_value, node); | |
| 534 | return rvalue(gz, rl, .void_value, node); | |
| 536 | 535 | }, |
| 537 | 536 | .assign_mul_wrap => { |
| 538 | 537 | try assignOp(gz, scope, node, .mulwrap); |
| 539 | return rvalue(gz, scope, rl, .void_value, node); | |
| 538 | return rvalue(gz, rl, .void_value, node); | |
| 540 | 539 | }, |
| 541 | 540 | |
| 542 | 541 | // zig fmt: off |
| ... | ... | @@ -598,10 +597,10 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr |
| 598 | 597 | .asm_simple => return asmExpr(gz, scope, rl, node, tree.asmSimple(node)), |
| 599 | 598 | .@"asm" => return asmExpr(gz, scope, rl, node, tree.asmFull(node)), |
| 600 | 599 | |
| 601 | .string_literal => return stringLiteral(gz, scope, rl, node), | |
| 602 | .multiline_string_literal => return multilineStringLiteral(gz, scope, rl, node), | |
| 600 | .string_literal => return stringLiteral(gz, rl, node), | |
| 601 | .multiline_string_literal => return multilineStringLiteral(gz, rl, node), | |
| 603 | 602 | |
| 604 | .integer_literal => return integerLiteral(gz, scope, rl, node), | |
| 603 | .integer_literal => return integerLiteral(gz, rl, node), | |
| 605 | 604 | // zig fmt: on |
| 606 | 605 | |
| 607 | 606 | .builtin_call_two, .builtin_call_two_comma => { |
| ... | ... | @@ -641,7 +640,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr |
| 641 | 640 | }, |
| 642 | 641 | .@"return" => return ret(gz, scope, node), |
| 643 | 642 | .field_access => return fieldAccess(gz, scope, rl, node), |
| 644 | .float_literal => return floatLiteral(gz, scope, rl, node), | |
| 643 | .float_literal => return floatLiteral(gz, rl, node), | |
| 645 | 644 | |
| 646 | 645 | .if_simple => return ifExpr(gz, scope, rl, node, tree.ifSimple(node)), |
| 647 | 646 | .@"if" => return ifExpr(gz, scope, rl, node, tree.ifFull(node)), |
| ... | ... | @@ -660,7 +659,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr |
| 660 | 659 | .lhs = lhs, |
| 661 | 660 | .start = start, |
| 662 | 661 | }); |
| 663 | return rvalue(gz, scope, rl, result, node); | |
| 662 | return rvalue(gz, rl, result, node); | |
| 664 | 663 | }, |
| 665 | 664 | .slice => { |
| 666 | 665 | const lhs = try expr(gz, scope, .ref, node_datas[node].lhs); |
| ... | ... | @@ -672,7 +671,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr |
| 672 | 671 | .start = start, |
| 673 | 672 | .end = end, |
| 674 | 673 | }); |
| 675 | return rvalue(gz, scope, rl, result, node); | |
| 674 | return rvalue(gz, rl, result, node); | |
| 676 | 675 | }, |
| 677 | 676 | .slice_sentinel => { |
| 678 | 677 | const lhs = try expr(gz, scope, .ref, node_datas[node].lhs); |
| ... | ... | @@ -686,7 +685,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr |
| 686 | 685 | .end = end, |
| 687 | 686 | .sentinel = sentinel, |
| 688 | 687 | }); |
| 689 | return rvalue(gz, scope, rl, result, node); | |
| 688 | return rvalue(gz, rl, result, node); | |
| 690 | 689 | }, |
| 691 | 690 | |
| 692 | 691 | .deref => { |
| ... | ... | @@ -695,22 +694,22 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr |
| 695 | 694 | .ref, .none_or_ref => return lhs, |
| 696 | 695 | else => { |
| 697 | 696 | const result = try gz.addUnNode(.load, lhs, node); |
| 698 | return rvalue(gz, scope, rl, result, node); | |
| 697 | return rvalue(gz, rl, result, node); | |
| 699 | 698 | }, |
| 700 | 699 | } |
| 701 | 700 | }, |
| 702 | 701 | .address_of => { |
| 703 | 702 | const result = try expr(gz, scope, .ref, node_datas[node].lhs); |
| 704 | return rvalue(gz, scope, rl, result, node); | |
| 703 | return rvalue(gz, rl, result, node); | |
| 705 | 704 | }, |
| 706 | .undefined_literal => return rvalue(gz, scope, rl, .undef, node), | |
| 707 | .true_literal => return rvalue(gz, scope, rl, .bool_true, node), | |
| 708 | .false_literal => return rvalue(gz, scope, rl, .bool_false, node), | |
| 709 | .null_literal => return rvalue(gz, scope, rl, .null_value, node), | |
| 705 | .undefined_literal => return rvalue(gz, rl, .undef, node), | |
| 706 | .true_literal => return rvalue(gz, rl, .bool_true, node), | |
| 707 | .false_literal => return rvalue(gz, rl, .bool_false, node), | |
| 708 | .null_literal => return rvalue(gz, rl, .null_value, node), | |
| 710 | 709 | .optional_type => { |
| 711 | 710 | const operand = try typeExpr(gz, scope, node_datas[node].lhs); |
| 712 | 711 | const result = try gz.addUnNode(.optional_type, operand, node); |
| 713 | return rvalue(gz, scope, rl, result, node); | |
| 712 | return rvalue(gz, rl, result, node); | |
| 714 | 713 | }, |
| 715 | 714 | .unwrap_optional => switch (rl) { |
| 716 | 715 | .ref => return gz.addUnNode( |
| ... | ... | @@ -718,7 +717,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr |
| 718 | 717 | try expr(gz, scope, .ref, node_datas[node].lhs), |
| 719 | 718 | node, |
| 720 | 719 | ), |
| 721 | else => return rvalue(gz, scope, rl, try gz.addUnNode( | |
| 720 | else => return rvalue(gz, rl, try gz.addUnNode( | |
| 722 | 721 | .optional_payload_safe, |
| 723 | 722 | try expr(gz, scope, .none, node_datas[node].lhs), |
| 724 | 723 | node, |
| ... | ... | @@ -738,13 +737,13 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr |
| 738 | 737 | const statements = tree.extra_data[node_datas[node].lhs..node_datas[node].rhs]; |
| 739 | 738 | return blockExpr(gz, scope, rl, node, statements); |
| 740 | 739 | }, |
| 741 | .enum_literal => return simpleStrTok(gz, scope, rl, main_tokens[node], node, .enum_literal), | |
| 742 | .error_value => return simpleStrTok(gz, scope, rl, node_datas[node].rhs, node, .error_value), | |
| 743 | .anyframe_literal => return rvalue(gz, scope, rl, .anyframe_type, node), | |
| 740 | .enum_literal => return simpleStrTok(gz, rl, main_tokens[node], node, .enum_literal), | |
| 741 | .error_value => return simpleStrTok(gz, rl, node_datas[node].rhs, node, .error_value), | |
| 742 | .anyframe_literal => return rvalue(gz, rl, .anyframe_type, node), | |
| 744 | 743 | .anyframe_type => { |
| 745 | 744 | const return_type = try typeExpr(gz, scope, node_datas[node].rhs); |
| 746 | 745 | const result = try gz.addUnNode(.anyframe_type, return_type, node); |
| 747 | return rvalue(gz, scope, rl, result, node); | |
| 746 | return rvalue(gz, rl, result, node); | |
| 748 | 747 | }, |
| 749 | 748 | .@"catch" => { |
| 750 | 749 | const catch_token = main_tokens[node]; |
| ... | ... | @@ -838,14 +837,14 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr |
| 838 | 837 | .grouped_expression => return expr(gz, scope, rl, node_datas[node].lhs), |
| 839 | 838 | .array_type => return arrayType(gz, scope, rl, node), |
| 840 | 839 | .array_type_sentinel => return arrayTypeSentinel(gz, scope, rl, node), |
| 841 | .char_literal => return charLiteral(gz, scope, rl, node), | |
| 842 | .error_set_decl => return errorSetDecl(gz, scope, rl, node), | |
| 840 | .char_literal => return charLiteral(gz, rl, node), | |
| 841 | .error_set_decl => return errorSetDecl(gz, rl, node), | |
| 843 | 842 | .array_access => return arrayAccess(gz, scope, rl, node), |
| 844 | 843 | .@"comptime" => return comptimeExprAst(gz, scope, rl, node), |
| 845 | 844 | .@"switch", .switch_comma => return switchExpr(gz, scope, rl, node), |
| 846 | 845 | |
| 847 | 846 | .@"nosuspend" => return nosuspendExpr(gz, scope, rl, node), |
| 848 | .@"suspend" => return suspendExpr(gz, scope, rl, node), | |
| 847 | .@"suspend" => return suspendExpr(gz, scope, node), | |
| 849 | 848 | .@"await" => return awaitExpr(gz, scope, rl, node), |
| 850 | 849 | .@"resume" => return resumeExpr(gz, scope, rl, node), |
| 851 | 850 | |
| ... | ... | @@ -905,7 +904,6 @@ fn nosuspendExpr( |
| 905 | 904 | node: ast.Node.Index, |
| 906 | 905 | ) InnerError!Zir.Inst.Ref { |
| 907 | 906 | const astgen = gz.astgen; |
| 908 | const gpa = astgen.gpa; | |
| 909 | 907 | const tree = astgen.tree; |
| 910 | 908 | const node_datas = tree.nodes.items(.data); |
| 911 | 909 | const body_node = node_datas[node].lhs; |
| ... | ... | @@ -918,13 +916,12 @@ fn nosuspendExpr( |
| 918 | 916 | gz.nosuspend_node = node; |
| 919 | 917 | const result = try expr(gz, scope, rl, body_node); |
| 920 | 918 | gz.nosuspend_node = 0; |
| 921 | return rvalue(gz, scope, rl, result, node); | |
| 919 | return rvalue(gz, rl, result, node); | |
| 922 | 920 | } |
| 923 | 921 | |
| 924 | 922 | fn suspendExpr( |
| 925 | 923 | gz: *GenZir, |
| 926 | 924 | scope: *Scope, |
| 927 | rl: ResultLoc, | |
| 928 | 925 | node: ast.Node.Index, |
| 929 | 926 | ) InnerError!Zir.Inst.Ref { |
| 930 | 927 | const astgen = gz.astgen; |
| ... | ... | @@ -980,7 +977,7 @@ fn awaitExpr( |
| 980 | 977 | const operand = try expr(gz, scope, .none, rhs_node); |
| 981 | 978 | const tag: Zir.Inst.Tag = if (gz.nosuspend_node != 0) .await_nosuspend else .@"await"; |
| 982 | 979 | const result = try gz.addUnNode(tag, operand, node); |
| 983 | return rvalue(gz, scope, rl, result, node); | |
| 980 | return rvalue(gz, rl, result, node); | |
| 984 | 981 | } |
| 985 | 982 | |
| 986 | 983 | fn resumeExpr( |
| ... | ... | @@ -995,7 +992,7 @@ fn resumeExpr( |
| 995 | 992 | const rhs_node = node_datas[node].lhs; |
| 996 | 993 | const operand = try expr(gz, scope, .none, rhs_node); |
| 997 | 994 | const result = try gz.addUnNode(.@"resume", operand, node); |
| 998 | return rvalue(gz, scope, rl, result, node); | |
| 995 | return rvalue(gz, rl, result, node); | |
| 999 | 996 | } |
| 1000 | 997 | |
| 1001 | 998 | fn fnProtoExpr( |
| ... | ... | @@ -1101,7 +1098,7 @@ fn fnProtoExpr( |
| 1101 | 1098 | .is_test = false, |
| 1102 | 1099 | .is_extern = false, |
| 1103 | 1100 | }); |
| 1104 | return rvalue(gz, scope, rl, result, fn_proto.ast.proto_node); | |
| 1101 | return rvalue(gz, rl, result, fn_proto.ast.proto_node); | |
| 1105 | 1102 | } |
| 1106 | 1103 | |
| 1107 | 1104 | fn arrayInitExpr( |
| ... | ... | @@ -1113,7 +1110,6 @@ fn arrayInitExpr( |
| 1113 | 1110 | ) InnerError!Zir.Inst.Ref { |
| 1114 | 1111 | const astgen = gz.astgen; |
| 1115 | 1112 | const tree = astgen.tree; |
| 1116 | const gpa = astgen.gpa; | |
| 1117 | 1113 | const node_tags = tree.nodes.items(.tag); |
| 1118 | 1114 | const main_tokens = tree.nodes.items(.main_token); |
| 1119 | 1115 | |
| ... | ... | @@ -1173,32 +1169,32 @@ fn arrayInitExpr( |
| 1173 | 1169 | }, |
| 1174 | 1170 | .ref => { |
| 1175 | 1171 | if (types.array != .none) { |
| 1176 | return arrayInitExprRlTy(gz, scope, rl, node, array_init.ast.elements, types.array, types.elem, .array_init_ref); | |
| 1172 | return arrayInitExprRlTy(gz, scope, node, array_init.ast.elements, types.elem, .array_init_ref); | |
| 1177 | 1173 | } else { |
| 1178 | return arrayInitExprRlNone(gz, scope, rl, node, array_init.ast.elements, .array_init_anon_ref); | |
| 1174 | return arrayInitExprRlNone(gz, scope, node, array_init.ast.elements, .array_init_anon_ref); | |
| 1179 | 1175 | } |
| 1180 | 1176 | }, |
| 1181 | 1177 | .none, .none_or_ref => { |
| 1182 | 1178 | if (types.array != .none) { |
| 1183 | return arrayInitExprRlTy(gz, scope, rl, node, array_init.ast.elements, types.array, types.elem, .array_init); | |
| 1179 | return arrayInitExprRlTy(gz, scope, node, array_init.ast.elements, types.elem, .array_init); | |
| 1184 | 1180 | } else { |
| 1185 | return arrayInitExprRlNone(gz, scope, rl, node, array_init.ast.elements, .array_init_anon); | |
| 1181 | return arrayInitExprRlNone(gz, scope, node, array_init.ast.elements, .array_init_anon); | |
| 1186 | 1182 | } |
| 1187 | 1183 | }, |
| 1188 | 1184 | .ty => |ty_inst| { |
| 1189 | 1185 | if (types.array != .none) { |
| 1190 | const result = try arrayInitExprRlTy(gz, scope, rl, node, array_init.ast.elements, types.array, types.elem, .array_init); | |
| 1191 | return rvalue(gz, scope, rl, result, node); | |
| 1186 | const result = try arrayInitExprRlTy(gz, scope, node, array_init.ast.elements, types.elem, .array_init); | |
| 1187 | return rvalue(gz, rl, result, node); | |
| 1192 | 1188 | } else { |
| 1193 | 1189 | const elem_type = try gz.addUnNode(.elem_type, ty_inst, node); |
| 1194 | return arrayInitExprRlTy(gz, scope, rl, node, array_init.ast.elements, ty_inst, elem_type, .array_init); | |
| 1190 | return arrayInitExprRlTy(gz, scope, node, array_init.ast.elements, elem_type, .array_init); | |
| 1195 | 1191 | } |
| 1196 | 1192 | }, |
| 1197 | 1193 | .ptr, .inferred_ptr => |ptr_inst| { |
| 1198 | return arrayInitExprRlPtr(gz, scope, rl, node, array_init.ast.elements, ptr_inst); | |
| 1194 | return arrayInitExprRlPtr(gz, scope, node, array_init.ast.elements, ptr_inst); | |
| 1199 | 1195 | }, |
| 1200 | 1196 | .block_ptr => |block_gz| { |
| 1201 | return arrayInitExprRlPtr(gz, scope, rl, node, array_init.ast.elements, block_gz.rl_ptr); | |
| 1197 | return arrayInitExprRlPtr(gz, scope, node, array_init.ast.elements, block_gz.rl_ptr); | |
| 1202 | 1198 | }, |
| 1203 | 1199 | } |
| 1204 | 1200 | } |
| ... | ... | @@ -1206,7 +1202,6 @@ fn arrayInitExpr( |
| 1206 | 1202 | fn arrayInitExprRlNone( |
| 1207 | 1203 | gz: *GenZir, |
| 1208 | 1204 | scope: *Scope, |
| 1209 | rl: ResultLoc, | |
| 1210 | 1205 | node: ast.Node.Index, |
| 1211 | 1206 | elements: []const ast.Node.Index, |
| 1212 | 1207 | tag: Zir.Inst.Tag, |
| ... | ... | @@ -1229,10 +1224,8 @@ fn arrayInitExprRlNone( |
| 1229 | 1224 | fn arrayInitExprRlTy( |
| 1230 | 1225 | gz: *GenZir, |
| 1231 | 1226 | scope: *Scope, |
| 1232 | rl: ResultLoc, | |
| 1233 | 1227 | node: ast.Node.Index, |
| 1234 | 1228 | elements: []const ast.Node.Index, |
| 1235 | array_ty_inst: Zir.Inst.Ref, | |
| 1236 | 1229 | elem_ty_inst: Zir.Inst.Ref, |
| 1237 | 1230 | tag: Zir.Inst.Tag, |
| 1238 | 1231 | ) InnerError!Zir.Inst.Ref { |
| ... | ... | @@ -1257,7 +1250,6 @@ fn arrayInitExprRlTy( |
| 1257 | 1250 | fn arrayInitExprRlPtr( |
| 1258 | 1251 | gz: *GenZir, |
| 1259 | 1252 | scope: *Scope, |
| 1260 | rl: ResultLoc, | |
| 1261 | 1253 | node: ast.Node.Index, |
| 1262 | 1254 | elements: []const ast.Node.Index, |
| 1263 | 1255 | result_ptr: Zir.Inst.Ref, |
| ... | ... | @@ -1293,11 +1285,10 @@ fn structInitExpr( |
| 1293 | 1285 | ) InnerError!Zir.Inst.Ref { |
| 1294 | 1286 | const astgen = gz.astgen; |
| 1295 | 1287 | const tree = astgen.tree; |
| 1296 | const gpa = astgen.gpa; | |
| 1297 | 1288 | |
| 1298 | 1289 | if (struct_init.ast.fields.len == 0) { |
| 1299 | 1290 | if (struct_init.ast.type_expr == 0) { |
| 1300 | return rvalue(gz, scope, rl, .empty_struct, node); | |
| 1291 | return rvalue(gz, rl, .empty_struct, node); | |
| 1301 | 1292 | } |
| 1302 | 1293 | array: { |
| 1303 | 1294 | const node_tags = tree.nodes.items(.tag); |
| ... | ... | @@ -1319,15 +1310,17 @@ fn structInitExpr( |
| 1319 | 1310 | break :blk try gz.addArrayTypeSentinel(.zero_usize, elem_type, sentinel); |
| 1320 | 1311 | }; |
| 1321 | 1312 | const result = try gz.addUnNode(.struct_init_empty, array_type_inst, node); |
| 1322 | return rvalue(gz, scope, rl, result, node); | |
| 1313 | return rvalue(gz, rl, result, node); | |
| 1323 | 1314 | } |
| 1324 | 1315 | } |
| 1325 | 1316 | const ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr); |
| 1326 | 1317 | const result = try gz.addUnNode(.struct_init_empty, ty_inst, node); |
| 1327 | return rvalue(gz, scope, rl, result, node); | |
| 1318 | return rvalue(gz, rl, result, node); | |
| 1328 | 1319 | } |
| 1329 | 1320 | switch (rl) { |
| 1330 | 1321 | .discard => { |
| 1322 | if (struct_init.ast.type_expr != 0) | |
| 1323 | _ = try typeExpr(gz, scope, struct_init.ast.type_expr); | |
| 1331 | 1324 | for (struct_init.ast.fields) |field_init| { |
| 1332 | 1325 | _ = try expr(gz, scope, .discard, field_init); |
| 1333 | 1326 | } |
| ... | ... | @@ -1336,36 +1329,35 @@ fn structInitExpr( |
| 1336 | 1329 | .ref => { |
| 1337 | 1330 | if (struct_init.ast.type_expr != 0) { |
| 1338 | 1331 | const ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr); |
| 1339 | return structInitExprRlTy(gz, scope, rl, node, struct_init, ty_inst, .struct_init_ref); | |
| 1332 | return structInitExprRlTy(gz, scope, node, struct_init, ty_inst, .struct_init_ref); | |
| 1340 | 1333 | } else { |
| 1341 | return structInitExprRlNone(gz, scope, rl, node, struct_init, .struct_init_anon_ref); | |
| 1334 | return structInitExprRlNone(gz, scope, node, struct_init, .struct_init_anon_ref); | |
| 1342 | 1335 | } |
| 1343 | 1336 | }, |
| 1344 | 1337 | .none, .none_or_ref => { |
| 1345 | 1338 | if (struct_init.ast.type_expr != 0) { |
| 1346 | 1339 | const ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr); |
| 1347 | return structInitExprRlTy(gz, scope, rl, node, struct_init, ty_inst, .struct_init); | |
| 1340 | return structInitExprRlTy(gz, scope, node, struct_init, ty_inst, .struct_init); | |
| 1348 | 1341 | } else { |
| 1349 | return structInitExprRlNone(gz, scope, rl, node, struct_init, .struct_init_anon); | |
| 1342 | return structInitExprRlNone(gz, scope, node, struct_init, .struct_init_anon); | |
| 1350 | 1343 | } |
| 1351 | 1344 | }, |
| 1352 | 1345 | .ty => |ty_inst| { |
| 1353 | 1346 | if (struct_init.ast.type_expr == 0) { |
| 1354 | return structInitExprRlTy(gz, scope, rl, node, struct_init, ty_inst, .struct_init); | |
| 1347 | return structInitExprRlTy(gz, scope, node, struct_init, ty_inst, .struct_init); | |
| 1355 | 1348 | } |
| 1356 | 1349 | const inner_ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr); |
| 1357 | const result = try structInitExprRlTy(gz, scope, rl, node, struct_init, inner_ty_inst, .struct_init); | |
| 1358 | return rvalue(gz, scope, rl, result, node); | |
| 1350 | const result = try structInitExprRlTy(gz, scope, node, struct_init, inner_ty_inst, .struct_init); | |
| 1351 | return rvalue(gz, rl, result, node); | |
| 1359 | 1352 | }, |
| 1360 | .ptr, .inferred_ptr => |ptr_inst| return structInitExprRlPtr(gz, scope, rl, node, struct_init, ptr_inst), | |
| 1361 | .block_ptr => |block_gz| return structInitExprRlPtr(gz, scope, rl, node, struct_init, block_gz.rl_ptr), | |
| 1353 | .ptr, .inferred_ptr => |ptr_inst| return structInitExprRlPtr(gz, scope, node, struct_init, ptr_inst), | |
| 1354 | .block_ptr => |block_gz| return structInitExprRlPtr(gz, scope, node, struct_init, block_gz.rl_ptr), | |
| 1362 | 1355 | } |
| 1363 | 1356 | } |
| 1364 | 1357 | |
| 1365 | 1358 | fn structInitExprRlNone( |
| 1366 | 1359 | gz: *GenZir, |
| 1367 | 1360 | scope: *Scope, |
| 1368 | rl: ResultLoc, | |
| 1369 | 1361 | node: ast.Node.Index, |
| 1370 | 1362 | struct_init: ast.full.StructInit, |
| 1371 | 1363 | tag: Zir.Inst.Tag, |
| ... | ... | @@ -1400,7 +1392,6 @@ fn structInitExprRlNone( |
| 1400 | 1392 | fn structInitExprRlPtr( |
| 1401 | 1393 | gz: *GenZir, |
| 1402 | 1394 | scope: *Scope, |
| 1403 | rl: ResultLoc, | |
| 1404 | 1395 | node: ast.Node.Index, |
| 1405 | 1396 | struct_init: ast.full.StructInit, |
| 1406 | 1397 | result_ptr: Zir.Inst.Ref, |
| ... | ... | @@ -1412,6 +1403,9 @@ fn structInitExprRlPtr( |
| 1412 | 1403 | const field_ptr_list = try gpa.alloc(Zir.Inst.Index, struct_init.ast.fields.len); |
| 1413 | 1404 | defer gpa.free(field_ptr_list); |
| 1414 | 1405 | |
| 1406 | if (struct_init.ast.type_expr != 0) | |
| 1407 | _ = try typeExpr(gz, scope, struct_init.ast.type_expr); | |
| 1408 | ||
| 1415 | 1409 | for (struct_init.ast.fields) |field_init, i| { |
| 1416 | 1410 | const name_token = tree.firstToken(field_init) - 2; |
| 1417 | 1411 | const str_index = try astgen.identAsString(name_token); |
| ... | ... | @@ -1432,7 +1426,6 @@ fn structInitExprRlPtr( |
| 1432 | 1426 | fn structInitExprRlTy( |
| 1433 | 1427 | gz: *GenZir, |
| 1434 | 1428 | scope: *Scope, |
| 1435 | rl: ResultLoc, | |
| 1436 | 1429 | node: ast.Node.Index, |
| 1437 | 1430 | struct_init: ast.full.StructInit, |
| 1438 | 1431 | ty_inst: Zir.Inst.Ref, |
| ... | ... | @@ -1657,8 +1650,8 @@ fn blockExpr( |
| 1657 | 1650 | return labeledBlockExpr(gz, scope, rl, block_node, statements, .block); |
| 1658 | 1651 | } |
| 1659 | 1652 | |
| 1660 | try blockExprStmts(gz, scope, block_node, statements); | |
| 1661 | return rvalue(gz, scope, rl, .void_value, block_node); | |
| 1653 | try blockExprStmts(gz, scope, statements); | |
| 1654 | return rvalue(gz, rl, .void_value, block_node); | |
| 1662 | 1655 | } |
| 1663 | 1656 | |
| 1664 | 1657 | fn checkLabelRedefinition(astgen: *AstGen, parent_scope: *Scope, label: ast.TokenIndex) !void { |
| ... | ... | @@ -1670,9 +1663,6 @@ fn checkLabelRedefinition(astgen: *AstGen, parent_scope: *Scope, label: ast.Toke |
| 1670 | 1663 | const gen_zir = scope.cast(GenZir).?; |
| 1671 | 1664 | if (gen_zir.label) |prev_label| { |
| 1672 | 1665 | if (try astgen.tokenIdentEql(label, prev_label.token)) { |
| 1673 | const tree = astgen.tree; | |
| 1674 | const main_tokens = tree.nodes.items(.main_token); | |
| 1675 | ||
| 1676 | 1666 | const label_name = try astgen.identifierTokenString(label); |
| 1677 | 1667 | return astgen.failTokNotes(label, "redefinition of label '{s}'", .{ |
| 1678 | 1668 | label_name, |
| ... | ... | @@ -1735,7 +1725,7 @@ fn labeledBlockExpr( |
| 1735 | 1725 | defer block_scope.labeled_breaks.deinit(astgen.gpa); |
| 1736 | 1726 | defer block_scope.labeled_store_to_block_ptr_list.deinit(astgen.gpa); |
| 1737 | 1727 | |
| 1738 | try blockExprStmts(&block_scope, &block_scope.base, block_node, statements); | |
| 1728 | try blockExprStmts(&block_scope, &block_scope.base, statements); | |
| 1739 | 1729 | |
| 1740 | 1730 | if (!block_scope.label.?.used) { |
| 1741 | 1731 | return astgen.failTok(label_token, "unused block label", .{}); |
| ... | ... | @@ -1771,21 +1761,15 @@ fn labeledBlockExpr( |
| 1771 | 1761 | const block_ref = gz.indexToRef(block_inst); |
| 1772 | 1762 | switch (rl) { |
| 1773 | 1763 | .ref => return block_ref, |
| 1774 | else => return rvalue(gz, parent_scope, rl, block_ref, block_node), | |
| 1764 | else => return rvalue(gz, rl, block_ref, block_node), | |
| 1775 | 1765 | } |
| 1776 | 1766 | }, |
| 1777 | 1767 | } |
| 1778 | 1768 | } |
| 1779 | 1769 | |
| 1780 | fn blockExprStmts( | |
| 1781 | gz: *GenZir, | |
| 1782 | parent_scope: *Scope, | |
| 1783 | node: ast.Node.Index, | |
| 1784 | statements: []const ast.Node.Index, | |
| 1785 | ) !void { | |
| 1770 | fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const ast.Node.Index) !void { | |
| 1786 | 1771 | const astgen = gz.astgen; |
| 1787 | 1772 | const tree = astgen.tree; |
| 1788 | const main_tokens = tree.nodes.items(.main_token); | |
| 1789 | 1773 | const node_tags = tree.nodes.items(.tag); |
| 1790 | 1774 | |
| 1791 | 1775 | var block_arena = std.heap.ArenaAllocator.init(gz.astgen.gpa); |
| ... | ... | @@ -1800,8 +1784,8 @@ fn blockExprStmts( |
| 1800 | 1784 | .simple_var_decl => scope = try varDecl(gz, scope, statement, &block_arena.allocator, tree.simpleVarDecl(statement)), |
| 1801 | 1785 | .aligned_var_decl => scope = try varDecl(gz, scope, statement, &block_arena.allocator, tree.alignedVarDecl(statement)), |
| 1802 | 1786 | |
| 1803 | .@"defer" => scope = try deferStmt(gz, scope, statement, &block_arena.allocator, .defer_normal), | |
| 1804 | .@"errdefer" => scope = try deferStmt(gz, scope, statement, &block_arena.allocator, .defer_error), | |
| 1787 | .@"defer" => scope = try makeDeferScope(scope, statement, &block_arena.allocator, .defer_normal), | |
| 1788 | .@"errdefer" => scope = try makeDeferScope(scope, statement, &block_arena.allocator, .defer_error), | |
| 1805 | 1789 | |
| 1806 | 1790 | .assign => try assign(gz, scope, statement), |
| 1807 | 1791 | |
| ... | ... | @@ -1826,6 +1810,7 @@ fn blockExprStmts( |
| 1826 | 1810 | } |
| 1827 | 1811 | |
| 1828 | 1812 | try genDefers(gz, parent_scope, scope, .none); |
| 1813 | try checkUsed(gz, parent_scope, scope); | |
| 1829 | 1814 | } |
| 1830 | 1815 | |
| 1831 | 1816 | fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: ast.Node.Index) InnerError!void { |
| ... | ... | @@ -2119,6 +2104,7 @@ fn genDefers( |
| 2119 | 2104 | inner_scope: *Scope, |
| 2120 | 2105 | err_code: Zir.Inst.Ref, |
| 2121 | 2106 | ) InnerError!void { |
| 2107 | _ = err_code; | |
| 2122 | 2108 | const astgen = gz.astgen; |
| 2123 | 2109 | const tree = astgen.tree; |
| 2124 | 2110 | const node_datas = tree.nodes.items(.data); |
| ... | ... | @@ -2154,8 +2140,49 @@ fn genDefers( |
| 2154 | 2140 | } |
| 2155 | 2141 | } |
| 2156 | 2142 | |
| 2157 | fn deferStmt( | |
| 2143 | fn checkUsed( | |
| 2158 | 2144 | gz: *GenZir, |
| 2145 | outer_scope: *Scope, | |
| 2146 | inner_scope: *Scope, | |
| 2147 | ) InnerError!void { | |
| 2148 | const astgen = gz.astgen; | |
| 2149 | ||
| 2150 | var scope = inner_scope; | |
| 2151 | while (scope != outer_scope) { | |
| 2152 | switch (scope.tag) { | |
| 2153 | .gen_zir => scope = scope.cast(GenZir).?.parent, | |
| 2154 | .local_val => { | |
| 2155 | const s = scope.cast(Scope.LocalVal).?; | |
| 2156 | switch (s.used) { | |
| 2157 | .used => {}, | |
| 2158 | .fn_param => return astgen.failTok(s.token_src, "unused function parameter", .{}), | |
| 2159 | .constant => return astgen.failTok(s.token_src, "unused local constant", .{}), | |
| 2160 | .variable => unreachable, | |
| 2161 | .loop_index => unreachable, | |
| 2162 | .capture => return astgen.failTok(s.token_src, "unused capture", .{}), | |
| 2163 | } | |
| 2164 | scope = s.parent; | |
| 2165 | }, | |
| 2166 | .local_ptr => { | |
| 2167 | const s = scope.cast(Scope.LocalPtr).?; | |
| 2168 | switch (s.used) { | |
| 2169 | .used => {}, | |
| 2170 | .fn_param => unreachable, | |
| 2171 | .constant => return astgen.failTok(s.token_src, "unused local constant", .{}), | |
| 2172 | .variable => return astgen.failTok(s.token_src, "unused local variable", .{}), | |
| 2173 | .loop_index => return astgen.failTok(s.token_src, "unused loop index capture", .{}), | |
| 2174 | .capture => unreachable, | |
| 2175 | } | |
| 2176 | scope = s.parent; | |
| 2177 | }, | |
| 2178 | .defer_normal, .defer_error => scope = scope.cast(Scope.Defer).?.parent, | |
| 2179 | .namespace => unreachable, | |
| 2180 | .top => unreachable, | |
| 2181 | } | |
| 2182 | } | |
| 2183 | } | |
| 2184 | ||
| 2185 | fn makeDeferScope( | |
| 2159 | 2186 | scope: *Scope, |
| 2160 | 2187 | node: ast.Node.Index, |
| 2161 | 2188 | block_arena: *Allocator, |
| ... | ... | @@ -2274,6 +2301,7 @@ fn varDecl( |
| 2274 | 2301 | .name = ident_name, |
| 2275 | 2302 | .inst = init_inst, |
| 2276 | 2303 | .token_src = name_token, |
| 2304 | .used = .constant, | |
| 2277 | 2305 | }; |
| 2278 | 2306 | return &sub_scope.base; |
| 2279 | 2307 | } |
| ... | ... | @@ -2341,6 +2369,7 @@ fn varDecl( |
| 2341 | 2369 | .name = ident_name, |
| 2342 | 2370 | .inst = init_inst, |
| 2343 | 2371 | .token_src = name_token, |
| 2372 | .used = .constant, | |
| 2344 | 2373 | }; |
| 2345 | 2374 | return &sub_scope.base; |
| 2346 | 2375 | } |
| ... | ... | @@ -2369,7 +2398,8 @@ fn varDecl( |
| 2369 | 2398 | .name = ident_name, |
| 2370 | 2399 | .ptr = init_scope.rl_ptr, |
| 2371 | 2400 | .token_src = name_token, |
| 2372 | .is_comptime = true, | |
| 2401 | .maybe_comptime = true, | |
| 2402 | .used = .constant, | |
| 2373 | 2403 | }; |
| 2374 | 2404 | return &sub_scope.base; |
| 2375 | 2405 | }, |
| ... | ... | @@ -2414,7 +2444,7 @@ fn varDecl( |
| 2414 | 2444 | resolve_inferred_alloc = alloc; |
| 2415 | 2445 | break :a .{ .alloc = alloc, .result_loc = .{ .inferred_ptr = alloc } }; |
| 2416 | 2446 | }; |
| 2417 | const init_inst = try expr(gz, scope, var_data.result_loc, var_decl.ast.init_node); | |
| 2447 | _ = try expr(gz, scope, var_data.result_loc, var_decl.ast.init_node); | |
| 2418 | 2448 | if (resolve_inferred_alloc != .none) { |
| 2419 | 2449 | _ = try gz.addUnNode(.resolve_inferred_alloc, resolve_inferred_alloc, node); |
| 2420 | 2450 | } |
| ... | ... | @@ -2425,7 +2455,8 @@ fn varDecl( |
| 2425 | 2455 | .name = ident_name, |
| 2426 | 2456 | .ptr = var_data.alloc, |
| 2427 | 2457 | .token_src = name_token, |
| 2428 | .is_comptime = is_comptime, | |
| 2458 | .maybe_comptime = is_comptime, | |
| 2459 | .used = .variable, | |
| 2429 | 2460 | }; |
| 2430 | 2461 | return &sub_scope.base; |
| 2431 | 2462 | }, |
| ... | ... | @@ -2441,7 +2472,6 @@ fn emitDbgNode(gz: *GenZir, node: ast.Node.Index) !void { |
| 2441 | 2472 | |
| 2442 | 2473 | const astgen = gz.astgen; |
| 2443 | 2474 | const tree = astgen.tree; |
| 2444 | const node_tags = tree.nodes.items(.tag); | |
| 2445 | 2475 | const token_starts = tree.tokens.items(.start); |
| 2446 | 2476 | const decl_start = token_starts[tree.firstToken(gz.decl_node_index)]; |
| 2447 | 2477 | const node_start = token_starts[tree.firstToken(node)]; |
| ... | ... | @@ -2530,7 +2560,7 @@ fn boolNot(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) Inne |
| 2530 | 2560 | |
| 2531 | 2561 | const operand = try expr(gz, scope, bool_rl, node_datas[node].lhs); |
| 2532 | 2562 | const result = try gz.addUnNode(.bool_not, operand, node); |
| 2533 | return rvalue(gz, scope, rl, result, node); | |
| 2563 | return rvalue(gz, rl, result, node); | |
| 2534 | 2564 | } |
| 2535 | 2565 | |
| 2536 | 2566 | fn bitNot(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerError!Zir.Inst.Ref { |
| ... | ... | @@ -2540,7 +2570,7 @@ fn bitNot(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) Inner |
| 2540 | 2570 | |
| 2541 | 2571 | const operand = try expr(gz, scope, .none, node_datas[node].lhs); |
| 2542 | 2572 | const result = try gz.addUnNode(.bit_not, operand, node); |
| 2543 | return rvalue(gz, scope, rl, result, node); | |
| 2573 | return rvalue(gz, rl, result, node); | |
| 2544 | 2574 | } |
| 2545 | 2575 | |
| 2546 | 2576 | fn negation( |
| ... | ... | @@ -2556,7 +2586,7 @@ fn negation( |
| 2556 | 2586 | |
| 2557 | 2587 | const operand = try expr(gz, scope, .none, node_datas[node].lhs); |
| 2558 | 2588 | const result = try gz.addUnNode(tag, operand, node); |
| 2559 | return rvalue(gz, scope, rl, result, node); | |
| 2589 | return rvalue(gz, rl, result, node); | |
| 2560 | 2590 | } |
| 2561 | 2591 | |
| 2562 | 2592 | fn ptrType( |
| ... | ... | @@ -2566,9 +2596,6 @@ fn ptrType( |
| 2566 | 2596 | node: ast.Node.Index, |
| 2567 | 2597 | ptr_info: ast.full.PtrType, |
| 2568 | 2598 | ) InnerError!Zir.Inst.Ref { |
| 2569 | const astgen = gz.astgen; | |
| 2570 | const tree = astgen.tree; | |
| 2571 | ||
| 2572 | 2599 | const elem_type = try typeExpr(gz, scope, ptr_info.ast.child_type); |
| 2573 | 2600 | |
| 2574 | 2601 | const simple = ptr_info.ast.align_node == 0 and |
| ... | ... | @@ -2585,7 +2612,7 @@ fn ptrType( |
| 2585 | 2612 | .elem_type = elem_type, |
| 2586 | 2613 | }, |
| 2587 | 2614 | } }); |
| 2588 | return rvalue(gz, scope, rl, result, node); | |
| 2615 | return rvalue(gz, rl, result, node); | |
| 2589 | 2616 | } |
| 2590 | 2617 | |
| 2591 | 2618 | var sentinel_ref: Zir.Inst.Ref = .none; |
| ... | ... | @@ -2645,7 +2672,7 @@ fn ptrType( |
| 2645 | 2672 | } }); |
| 2646 | 2673 | gz.instructions.appendAssumeCapacity(new_index); |
| 2647 | 2674 | |
| 2648 | return rvalue(gz, scope, rl, result, node); | |
| 2675 | return rvalue(gz, rl, result, node); | |
| 2649 | 2676 | } |
| 2650 | 2677 | |
| 2651 | 2678 | fn arrayType(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !Zir.Inst.Ref { |
| ... | ... | @@ -2665,7 +2692,7 @@ fn arrayType(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !Z |
| 2665 | 2692 | const elem_type = try typeExpr(gz, scope, node_datas[node].rhs); |
| 2666 | 2693 | |
| 2667 | 2694 | const result = try gz.addBin(.array_type, len, elem_type); |
| 2668 | return rvalue(gz, scope, rl, result, node); | |
| 2695 | return rvalue(gz, rl, result, node); | |
| 2669 | 2696 | } |
| 2670 | 2697 | |
| 2671 | 2698 | fn arrayTypeSentinel(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !Zir.Inst.Ref { |
| ... | ... | @@ -2687,7 +2714,7 @@ fn arrayTypeSentinel(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.I |
| 2687 | 2714 | const sentinel = try expr(gz, scope, .{ .ty = elem_type }, extra.sentinel); |
| 2688 | 2715 | |
| 2689 | 2716 | const result = try gz.addArrayTypeSentinel(len, elem_type, sentinel); |
| 2690 | return rvalue(gz, scope, rl, result, node); | |
| 2717 | return rvalue(gz, rl, result, node); | |
| 2691 | 2718 | } |
| 2692 | 2719 | |
| 2693 | 2720 | const WipDecls = struct { |
| ... | ... | @@ -2918,6 +2945,10 @@ fn fnDecl( |
| 2918 | 2945 | const name_token = param.name_token orelse { |
| 2919 | 2946 | return astgen.failNode(param.type_expr, "missing parameter name", .{}); |
| 2920 | 2947 | }; |
| 2948 | if (param.type_expr != 0) | |
| 2949 | _ = try typeExpr(&fn_gz, params_scope, param.type_expr); | |
| 2950 | if (mem.eql(u8, "_", tree.tokenSlice(name_token))) | |
| 2951 | continue; | |
| 2921 | 2952 | const param_name = try astgen.identAsString(name_token); |
| 2922 | 2953 | // Create an arg instruction. This is needed to emit a semantic analysis |
| 2923 | 2954 | // error for shadowing decls. |
| ... | ... | @@ -2930,16 +2961,19 @@ fn fnDecl( |
| 2930 | 2961 | .name = param_name, |
| 2931 | 2962 | .inst = arg_inst, |
| 2932 | 2963 | .token_src = name_token, |
| 2964 | .used = .fn_param, | |
| 2933 | 2965 | }; |
| 2934 | 2966 | params_scope = &sub_scope.base; |
| 2935 | 2967 | |
| 2936 | 2968 | // Additionally put the param name into `string_bytes` and reference it with |
| 2937 | 2969 | // `extra` so that we have access to the data in codegen, for debug info. |
| 2938 | 2970 | const str_index = try astgen.identAsString(name_token); |
| 2939 | astgen.extra.appendAssumeCapacity(str_index); | |
| 2971 | try astgen.extra.append(astgen.gpa, str_index); | |
| 2940 | 2972 | } |
| 2973 | _ = try typeExpr(&fn_gz, params_scope, fn_proto.ast.return_type); | |
| 2941 | 2974 | |
| 2942 | 2975 | _ = try expr(&fn_gz, params_scope, .none, body_node); |
| 2976 | try checkUsed(gz, &fn_gz.base, params_scope); | |
| 2943 | 2977 | } |
| 2944 | 2978 | |
| 2945 | 2979 | const need_implicit_ret = blk: { |
| ... | ... | @@ -3632,7 +3666,7 @@ fn unionDeclInner( |
| 3632 | 3666 | }; |
| 3633 | 3667 | defer block_scope.instructions.deinit(gpa); |
| 3634 | 3668 | |
| 3635 | var namespace: Scope.Namespace = .{ .parent = &gz.base }; | |
| 3669 | var namespace: Scope.Namespace = .{ .parent = scope }; | |
| 3636 | 3670 | defer namespace.decls.deinit(gpa); |
| 3637 | 3671 | |
| 3638 | 3672 | var wip_decls: WipDecls = .{}; |
| ... | ... | @@ -3916,7 +3950,7 @@ fn containerDecl( |
| 3916 | 3950 | assert(arg_inst == .none); |
| 3917 | 3951 | |
| 3918 | 3952 | const result = try structDeclInner(gz, scope, node, container_decl, layout); |
| 3919 | return rvalue(gz, scope, rl, result, node); | |
| 3953 | return rvalue(gz, rl, result, node); | |
| 3920 | 3954 | }, |
| 3921 | 3955 | .keyword_union => { |
| 3922 | 3956 | const layout = if (container_decl.layout_token) |t| switch (token_tags[t]) { |
| ... | ... | @@ -3928,7 +3962,7 @@ fn containerDecl( |
| 3928 | 3962 | const have_auto_enum = container_decl.ast.enum_token != null; |
| 3929 | 3963 | |
| 3930 | 3964 | const result = try unionDeclInner(gz, scope, node, container_decl.ast.members, layout, arg_inst, have_auto_enum); |
| 3931 | return rvalue(gz, scope, rl, result, node); | |
| 3965 | return rvalue(gz, rl, result, node); | |
| 3932 | 3966 | }, |
| 3933 | 3967 | .keyword_enum => { |
| 3934 | 3968 | if (container_decl.layout_token) |t| { |
| ... | ... | @@ -4033,7 +4067,7 @@ fn containerDecl( |
| 4033 | 4067 | }; |
| 4034 | 4068 | defer block_scope.instructions.deinit(gpa); |
| 4035 | 4069 | |
| 4036 | var namespace: Scope.Namespace = .{ .parent = &gz.base }; | |
| 4070 | var namespace: Scope.Namespace = .{ .parent = scope }; | |
| 4037 | 4071 | defer namespace.decls.deinit(gpa); |
| 4038 | 4072 | |
| 4039 | 4073 | var wip_decls: WipDecls = .{}; |
| ... | ... | @@ -4257,20 +4291,18 @@ fn containerDecl( |
| 4257 | 4291 | astgen.extra.appendAssumeCapacity(cur_bit_bag); |
| 4258 | 4292 | astgen.extra.appendSliceAssumeCapacity(fields_data.items); |
| 4259 | 4293 | |
| 4260 | return rvalue(gz, scope, rl, gz.indexToRef(decl_inst), node); | |
| 4294 | return rvalue(gz, rl, gz.indexToRef(decl_inst), node); | |
| 4261 | 4295 | }, |
| 4262 | 4296 | .keyword_opaque => { |
| 4263 | var namespace: Scope.Namespace = .{ .parent = &gz.base }; | |
| 4297 | var namespace: Scope.Namespace = .{ .parent = scope }; | |
| 4264 | 4298 | defer namespace.decls.deinit(gpa); |
| 4265 | 4299 | |
| 4266 | 4300 | var wip_decls: WipDecls = .{}; |
| 4267 | 4301 | defer wip_decls.deinit(gpa); |
| 4268 | 4302 | |
| 4269 | 4303 | for (container_decl.ast.members) |member_node| { |
| 4270 | const member = switch (node_tags[member_node]) { | |
| 4271 | .container_field_init => tree.containerFieldInit(member_node), | |
| 4272 | .container_field_align => tree.containerFieldAlign(member_node), | |
| 4273 | .container_field => tree.containerField(member_node), | |
| 4304 | switch (node_tags[member_node]) { | |
| 4305 | .container_field_init, .container_field_align, .container_field => {}, | |
| 4274 | 4306 | |
| 4275 | 4307 | .fn_decl => { |
| 4276 | 4308 | const fn_proto = node_datas[member_node].lhs; |
| ... | ... | @@ -4391,7 +4423,7 @@ fn containerDecl( |
| 4391 | 4423 | continue; |
| 4392 | 4424 | }, |
| 4393 | 4425 | else => unreachable, |
| 4394 | }; | |
| 4426 | } | |
| 4395 | 4427 | } |
| 4396 | 4428 | { |
| 4397 | 4429 | const empty_slot_count = WipDecls.fields_per_u32 - (wip_decls.decl_index % WipDecls.fields_per_u32); |
| ... | ... | @@ -4420,18 +4452,13 @@ fn containerDecl( |
| 4420 | 4452 | } |
| 4421 | 4453 | astgen.extra.appendSliceAssumeCapacity(wip_decls.payload.items); |
| 4422 | 4454 | |
| 4423 | return rvalue(gz, scope, rl, gz.indexToRef(decl_inst), node); | |
| 4455 | return rvalue(gz, rl, gz.indexToRef(decl_inst), node); | |
| 4424 | 4456 | }, |
| 4425 | 4457 | else => unreachable, |
| 4426 | 4458 | } |
| 4427 | 4459 | } |
| 4428 | 4460 | |
| 4429 | fn errorSetDecl( | |
| 4430 | gz: *GenZir, | |
| 4431 | scope: *Scope, | |
| 4432 | rl: ResultLoc, | |
| 4433 | node: ast.Node.Index, | |
| 4434 | ) InnerError!Zir.Inst.Ref { | |
| 4461 | fn errorSetDecl(gz: *GenZir, rl: ResultLoc, node: ast.Node.Index) InnerError!Zir.Inst.Ref { | |
| 4435 | 4462 | const astgen = gz.astgen; |
| 4436 | 4463 | const gpa = astgen.gpa; |
| 4437 | 4464 | const tree = astgen.tree; |
| ... | ... | @@ -4459,16 +4486,11 @@ fn errorSetDecl( |
| 4459 | 4486 | } |
| 4460 | 4487 | } |
| 4461 | 4488 | |
| 4462 | const tag: Zir.Inst.Tag = switch (gz.anon_name_strategy) { | |
| 4463 | .parent => .error_set_decl, | |
| 4464 | .anon => .error_set_decl_anon, | |
| 4465 | .func => .error_set_decl_func, | |
| 4466 | }; | |
| 4467 | 4489 | const result = try gz.addPlNode(.error_set_decl, node, Zir.Inst.ErrorSetDecl{ |
| 4468 | 4490 | .fields_len = @intCast(u32, field_names.items.len), |
| 4469 | 4491 | }); |
| 4470 | 4492 | try astgen.extra.appendSlice(gpa, field_names.items); |
| 4471 | return rvalue(gz, scope, rl, result, node); | |
| 4493 | return rvalue(gz, rl, result, node); | |
| 4472 | 4494 | } |
| 4473 | 4495 | |
| 4474 | 4496 | fn tryExpr( |
| ... | ... | @@ -4479,7 +4501,6 @@ fn tryExpr( |
| 4479 | 4501 | operand_node: ast.Node.Index, |
| 4480 | 4502 | ) InnerError!Zir.Inst.Ref { |
| 4481 | 4503 | const astgen = parent_gz.astgen; |
| 4482 | const tree = astgen.tree; | |
| 4483 | 4504 | |
| 4484 | 4505 | const fn_block = astgen.fn_block orelse { |
| 4485 | 4506 | return astgen.failNode(node, "invalid 'try' outside function scope", .{}); |
| ... | ... | @@ -4528,12 +4549,11 @@ fn tryExpr( |
| 4528 | 4549 | const unwrapped_payload = try else_scope.addUnNode(err_ops[2], operand, node); |
| 4529 | 4550 | const else_result = switch (rl) { |
| 4530 | 4551 | .ref => unwrapped_payload, |
| 4531 | else => try rvalue(&else_scope, &else_scope.base, block_scope.break_result_loc, unwrapped_payload, node), | |
| 4552 | else => try rvalue(&else_scope, block_scope.break_result_loc, unwrapped_payload, node), | |
| 4532 | 4553 | }; |
| 4533 | 4554 | |
| 4534 | 4555 | return finishThenElseBlock( |
| 4535 | 4556 | parent_gz, |
| 4536 | scope, | |
| 4537 | 4557 | rl, |
| 4538 | 4558 | node, |
| 4539 | 4559 | &block_scope, |
| ... | ... | @@ -4541,8 +4561,6 @@ fn tryExpr( |
| 4541 | 4561 | &else_scope, |
| 4542 | 4562 | condbr, |
| 4543 | 4563 | cond, |
| 4544 | node, | |
| 4545 | node, | |
| 4546 | 4564 | then_result, |
| 4547 | 4565 | else_result, |
| 4548 | 4566 | block, |
| ... | ... | @@ -4603,12 +4621,15 @@ fn orelseCatchExpr( |
| 4603 | 4621 | .name = err_name, |
| 4604 | 4622 | .inst = try then_scope.addUnNode(unwrap_code_op, operand, node), |
| 4605 | 4623 | .token_src = payload, |
| 4624 | .used = .capture, | |
| 4606 | 4625 | }; |
| 4607 | 4626 | break :blk &err_val_scope.base; |
| 4608 | 4627 | }; |
| 4609 | 4628 | |
| 4610 | 4629 | block_scope.break_count += 1; |
| 4611 | 4630 | const then_result = try expr(&then_scope, then_sub_scope, block_scope.break_result_loc, rhs); |
| 4631 | try checkUsed(parent_gz, &then_scope.base, then_sub_scope); | |
| 4632 | ||
| 4612 | 4633 | // We hold off on the break instructions as well as copying the then/else |
| 4613 | 4634 | // instructions into place until we know whether to keep store_to_block_ptr |
| 4614 | 4635 | // instructions or not. |
| ... | ... | @@ -4620,12 +4641,11 @@ fn orelseCatchExpr( |
| 4620 | 4641 | const unwrapped_payload = try else_scope.addUnNode(unwrap_op, operand, node); |
| 4621 | 4642 | const else_result = switch (rl) { |
| 4622 | 4643 | .ref => unwrapped_payload, |
| 4623 | else => try rvalue(&else_scope, &else_scope.base, block_scope.break_result_loc, unwrapped_payload, node), | |
| 4644 | else => try rvalue(&else_scope, block_scope.break_result_loc, unwrapped_payload, node), | |
| 4624 | 4645 | }; |
| 4625 | 4646 | |
| 4626 | 4647 | return finishThenElseBlock( |
| 4627 | 4648 | parent_gz, |
| 4628 | scope, | |
| 4629 | 4649 | rl, |
| 4630 | 4650 | node, |
| 4631 | 4651 | &block_scope, |
| ... | ... | @@ -4633,8 +4653,6 @@ fn orelseCatchExpr( |
| 4633 | 4653 | &else_scope, |
| 4634 | 4654 | condbr, |
| 4635 | 4655 | cond, |
| 4636 | node, | |
| 4637 | node, | |
| 4638 | 4656 | then_result, |
| 4639 | 4657 | else_result, |
| 4640 | 4658 | block, |
| ... | ... | @@ -4645,7 +4663,6 @@ fn orelseCatchExpr( |
| 4645 | 4663 | |
| 4646 | 4664 | fn finishThenElseBlock( |
| 4647 | 4665 | parent_gz: *GenZir, |
| 4648 | parent_scope: *Scope, | |
| 4649 | 4666 | rl: ResultLoc, |
| 4650 | 4667 | node: ast.Node.Index, |
| 4651 | 4668 | block_scope: *GenZir, |
| ... | ... | @@ -4653,8 +4670,6 @@ fn finishThenElseBlock( |
| 4653 | 4670 | else_scope: *GenZir, |
| 4654 | 4671 | condbr: Zir.Inst.Index, |
| 4655 | 4672 | cond: Zir.Inst.Ref, |
| 4656 | then_src: ast.Node.Index, | |
| 4657 | else_src: ast.Node.Index, | |
| 4658 | 4673 | then_result: Zir.Inst.Ref, |
| 4659 | 4674 | else_result: Zir.Inst.Ref, |
| 4660 | 4675 | main_block: Zir.Inst.Index, |
| ... | ... | @@ -4664,7 +4679,6 @@ fn finishThenElseBlock( |
| 4664 | 4679 | // We now have enough information to decide whether the result instruction should |
| 4665 | 4680 | // be communicated via result location pointer or break instructions. |
| 4666 | 4681 | const strat = rl.strategy(block_scope); |
| 4667 | const astgen = block_scope.astgen; | |
| 4668 | 4682 | switch (strat.tag) { |
| 4669 | 4683 | .break_void => { |
| 4670 | 4684 | if (!parent_gz.refIsNoReturn(then_result)) { |
| ... | ... | @@ -4697,7 +4711,7 @@ fn finishThenElseBlock( |
| 4697 | 4711 | const block_ref = parent_gz.indexToRef(main_block); |
| 4698 | 4712 | switch (rl) { |
| 4699 | 4713 | .ref => return block_ref, |
| 4700 | else => return rvalue(parent_gz, parent_scope, rl, block_ref, node), | |
| 4714 | else => return rvalue(parent_gz, rl, block_ref, node), | |
| 4701 | 4715 | } |
| 4702 | 4716 | }, |
| 4703 | 4717 | } |
| ... | ... | @@ -4733,7 +4747,7 @@ fn fieldAccess( |
| 4733 | 4747 | .lhs = try expr(gz, scope, .ref, object_node), |
| 4734 | 4748 | .field_name_start = str_index, |
| 4735 | 4749 | }), |
| 4736 | else => return rvalue(gz, scope, rl, try gz.addPlNode(.field_val, node, Zir.Inst.Field{ | |
| 4750 | else => return rvalue(gz, rl, try gz.addPlNode(.field_val, node, Zir.Inst.Field{ | |
| 4737 | 4751 | .lhs = try expr(gz, scope, .none_or_ref, object_node), |
| 4738 | 4752 | .field_name_start = str_index, |
| 4739 | 4753 | }), node), |
| ... | ... | @@ -4748,7 +4762,6 @@ fn arrayAccess( |
| 4748 | 4762 | ) InnerError!Zir.Inst.Ref { |
| 4749 | 4763 | const astgen = gz.astgen; |
| 4750 | 4764 | const tree = astgen.tree; |
| 4751 | const main_tokens = tree.nodes.items(.main_token); | |
| 4752 | 4765 | const node_datas = tree.nodes.items(.data); |
| 4753 | 4766 | switch (rl) { |
| 4754 | 4767 | .ref => return gz.addBin( |
| ... | ... | @@ -4756,7 +4769,7 @@ fn arrayAccess( |
| 4756 | 4769 | try expr(gz, scope, .ref, node_datas[node].lhs), |
| 4757 | 4770 | try expr(gz, scope, .{ .ty = .usize_type }, node_datas[node].rhs), |
| 4758 | 4771 | ), |
| 4759 | else => return rvalue(gz, scope, rl, try gz.addBin( | |
| 4772 | else => return rvalue(gz, rl, try gz.addBin( | |
| 4760 | 4773 | .elem_val, |
| 4761 | 4774 | try expr(gz, scope, .none_or_ref, node_datas[node].lhs), |
| 4762 | 4775 | try expr(gz, scope, .{ .ty = .usize_type }, node_datas[node].rhs), |
| ... | ... | @@ -4779,12 +4792,11 @@ fn simpleBinOp( |
| 4779 | 4792 | .lhs = try expr(gz, scope, .none, node_datas[node].lhs), |
| 4780 | 4793 | .rhs = try expr(gz, scope, .none, node_datas[node].rhs), |
| 4781 | 4794 | }); |
| 4782 | return rvalue(gz, scope, rl, result, node); | |
| 4795 | return rvalue(gz, rl, result, node); | |
| 4783 | 4796 | } |
| 4784 | 4797 | |
| 4785 | 4798 | fn simpleStrTok( |
| 4786 | 4799 | gz: *GenZir, |
| 4787 | scope: *Scope, | |
| 4788 | 4800 | rl: ResultLoc, |
| 4789 | 4801 | ident_token: ast.TokenIndex, |
| 4790 | 4802 | node: ast.Node.Index, |
| ... | ... | @@ -4793,7 +4805,7 @@ fn simpleStrTok( |
| 4793 | 4805 | const astgen = gz.astgen; |
| 4794 | 4806 | const str_index = try astgen.identAsString(ident_token); |
| 4795 | 4807 | const result = try gz.addStrTok(op_inst_tag, str_index, ident_token); |
| 4796 | return rvalue(gz, scope, rl, result, node); | |
| 4808 | return rvalue(gz, rl, result, node); | |
| 4797 | 4809 | } |
| 4798 | 4810 | |
| 4799 | 4811 | fn boolBinOp( |
| ... | ... | @@ -4819,7 +4831,7 @@ fn boolBinOp( |
| 4819 | 4831 | try rhs_scope.setBoolBrBody(bool_br); |
| 4820 | 4832 | |
| 4821 | 4833 | const block_ref = gz.indexToRef(bool_br); |
| 4822 | return rvalue(gz, scope, rl, block_ref, node); | |
| 4834 | return rvalue(gz, rl, block_ref, node); | |
| 4823 | 4835 | } |
| 4824 | 4836 | |
| 4825 | 4837 | fn ifExpr( |
| ... | ... | @@ -4846,7 +4858,7 @@ fn ifExpr( |
| 4846 | 4858 | inst: Zir.Inst.Ref, |
| 4847 | 4859 | bool_bit: Zir.Inst.Ref, |
| 4848 | 4860 | } = c: { |
| 4849 | if (if_full.error_token) |error_token| { | |
| 4861 | if (if_full.error_token) |_| { | |
| 4850 | 4862 | const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none; |
| 4851 | 4863 | const err_union = try expr(&block_scope, &block_scope.base, cond_rl, if_full.ast.cond_expr); |
| 4852 | 4864 | const tag: Zir.Inst.Tag = if (payload_is_ref) .is_err_ptr else .is_err; |
| ... | ... | @@ -4854,7 +4866,7 @@ fn ifExpr( |
| 4854 | 4866 | .inst = err_union, |
| 4855 | 4867 | .bool_bit = try block_scope.addUnNode(tag, err_union, node), |
| 4856 | 4868 | }; |
| 4857 | } else if (if_full.payload_token) |payload_token| { | |
| 4869 | } else if (if_full.payload_token) |_| { | |
| 4858 | 4870 | const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none; |
| 4859 | 4871 | const optional = try expr(&block_scope, &block_scope.base, cond_rl, if_full.ast.cond_expr); |
| 4860 | 4872 | const tag: Zir.Inst.Tag = if (payload_is_ref) .is_non_null_ptr else .is_non_null; |
| ... | ... | @@ -4883,27 +4895,38 @@ fn ifExpr( |
| 4883 | 4895 | var payload_val_scope: Scope.LocalVal = undefined; |
| 4884 | 4896 | |
| 4885 | 4897 | const then_sub_scope = s: { |
| 4886 | if (if_full.error_token) |error_token| { | |
| 4887 | const tag: Zir.Inst.Tag = if (payload_is_ref) | |
| 4888 | .err_union_payload_unsafe_ptr | |
| 4889 | else | |
| 4890 | .err_union_payload_unsafe; | |
| 4891 | const payload_inst = try then_scope.addUnNode(tag, cond.inst, node); | |
| 4892 | const ident_name = try astgen.identAsString(error_token); | |
| 4893 | payload_val_scope = .{ | |
| 4894 | .parent = &then_scope.base, | |
| 4895 | .gen_zir = &then_scope, | |
| 4896 | .name = ident_name, | |
| 4897 | .inst = payload_inst, | |
| 4898 | .token_src = error_token, | |
| 4899 | }; | |
| 4900 | break :s &payload_val_scope.base; | |
| 4898 | if (if_full.error_token != null) { | |
| 4899 | if (if_full.payload_token) |payload_token| { | |
| 4900 | const tag: Zir.Inst.Tag = if (payload_is_ref) | |
| 4901 | .err_union_payload_unsafe_ptr | |
| 4902 | else | |
| 4903 | .err_union_payload_unsafe; | |
| 4904 | const payload_inst = try then_scope.addUnNode(tag, cond.inst, node); | |
| 4905 | const token_name_index = payload_token + @boolToInt(payload_is_ref); | |
| 4906 | const ident_name = try astgen.identAsString(token_name_index); | |
| 4907 | const token_name_str = tree.tokenSlice(token_name_index); | |
| 4908 | if (mem.eql(u8, "_", token_name_str)) | |
| 4909 | break :s &then_scope.base; | |
| 4910 | payload_val_scope = .{ | |
| 4911 | .parent = &then_scope.base, | |
| 4912 | .gen_zir = &then_scope, | |
| 4913 | .name = ident_name, | |
| 4914 | .inst = payload_inst, | |
| 4915 | .token_src = payload_token, | |
| 4916 | .used = .capture, | |
| 4917 | }; | |
| 4918 | break :s &payload_val_scope.base; | |
| 4919 | } else { | |
| 4920 | break :s &then_scope.base; | |
| 4921 | } | |
| 4901 | 4922 | } else if (if_full.payload_token) |payload_token| { |
| 4902 | 4923 | const ident_token = if (payload_is_ref) payload_token + 1 else payload_token; |
| 4903 | 4924 | const tag: Zir.Inst.Tag = if (payload_is_ref) |
| 4904 | 4925 | .optional_payload_unsafe_ptr |
| 4905 | 4926 | else |
| 4906 | 4927 | .optional_payload_unsafe; |
| 4928 | if (mem.eql(u8, "_", tree.tokenSlice(ident_token))) | |
| 4929 | break :s &then_scope.base; | |
| 4907 | 4930 | const payload_inst = try then_scope.addUnNode(tag, cond.inst, node); |
| 4908 | 4931 | const ident_name = try astgen.identAsString(ident_token); |
| 4909 | 4932 | payload_val_scope = .{ |
| ... | ... | @@ -4912,6 +4935,7 @@ fn ifExpr( |
| 4912 | 4935 | .name = ident_name, |
| 4913 | 4936 | .inst = payload_inst, |
| 4914 | 4937 | .token_src = ident_token, |
| 4938 | .used = .capture, | |
| 4915 | 4939 | }; |
| 4916 | 4940 | break :s &payload_val_scope.base; |
| 4917 | 4941 | } else { |
| ... | ... | @@ -4921,6 +4945,7 @@ fn ifExpr( |
| 4921 | 4945 | |
| 4922 | 4946 | block_scope.break_count += 1; |
| 4923 | 4947 | const then_result = try expr(&then_scope, then_sub_scope, block_scope.break_result_loc, if_full.ast.then_expr); |
| 4948 | try checkUsed(parent_gz, &then_scope.base, then_sub_scope); | |
| 4924 | 4949 | // We hold off on the break instructions as well as copying the then/else |
| 4925 | 4950 | // instructions into place until we know whether to keep store_to_block_ptr |
| 4926 | 4951 | // instructions or not. |
| ... | ... | @@ -4942,21 +4967,27 @@ fn ifExpr( |
| 4942 | 4967 | .err_union_code; |
| 4943 | 4968 | const payload_inst = try else_scope.addUnNode(tag, cond.inst, node); |
| 4944 | 4969 | const ident_name = try astgen.identAsString(error_token); |
| 4970 | const error_token_str = tree.tokenSlice(error_token); | |
| 4971 | if (mem.eql(u8, "_", error_token_str)) | |
| 4972 | break :s &else_scope.base; | |
| 4945 | 4973 | payload_val_scope = .{ |
| 4946 | 4974 | .parent = &else_scope.base, |
| 4947 | 4975 | .gen_zir = &else_scope, |
| 4948 | 4976 | .name = ident_name, |
| 4949 | 4977 | .inst = payload_inst, |
| 4950 | 4978 | .token_src = error_token, |
| 4979 | .used = .capture, | |
| 4951 | 4980 | }; |
| 4952 | 4981 | break :s &payload_val_scope.base; |
| 4953 | 4982 | } else { |
| 4954 | 4983 | break :s &else_scope.base; |
| 4955 | 4984 | } |
| 4956 | 4985 | }; |
| 4986 | const e = try expr(&else_scope, sub_scope, block_scope.break_result_loc, else_node); | |
| 4987 | try checkUsed(parent_gz, &else_scope.base, sub_scope); | |
| 4957 | 4988 | break :blk .{ |
| 4958 | 4989 | .src = else_node, |
| 4959 | .result = try expr(&else_scope, sub_scope, block_scope.break_result_loc, else_node), | |
| 4990 | .result = e, | |
| 4960 | 4991 | }; |
| 4961 | 4992 | } else .{ |
| 4962 | 4993 | .src = if_full.ast.then_expr, |
| ... | ... | @@ -4965,7 +4996,6 @@ fn ifExpr( |
| 4965 | 4996 | |
| 4966 | 4997 | return finishThenElseBlock( |
| 4967 | 4998 | parent_gz, |
| 4968 | scope, | |
| 4969 | 4999 | rl, |
| 4970 | 5000 | node, |
| 4971 | 5001 | &block_scope, |
| ... | ... | @@ -4973,8 +5003,6 @@ fn ifExpr( |
| 4973 | 5003 | &else_scope, |
| 4974 | 5004 | condbr, |
| 4975 | 5005 | cond.bool_bit, |
| 4976 | if_full.ast.then_expr, | |
| 4977 | else_info.src, | |
| 4978 | 5006 | then_result, |
| 4979 | 5007 | else_info.result, |
| 4980 | 5008 | block, |
| ... | ... | @@ -5087,7 +5115,7 @@ fn whileExpr( |
| 5087 | 5115 | inst: Zir.Inst.Ref, |
| 5088 | 5116 | bool_bit: Zir.Inst.Ref, |
| 5089 | 5117 | } = c: { |
| 5090 | if (while_full.error_token) |error_token| { | |
| 5118 | if (while_full.error_token) |_| { | |
| 5091 | 5119 | const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none; |
| 5092 | 5120 | const err_union = try expr(&continue_scope, &continue_scope.base, cond_rl, while_full.ast.cond_expr); |
| 5093 | 5121 | const tag: Zir.Inst.Tag = if (payload_is_ref) .is_err_ptr else .is_err; |
| ... | ... | @@ -5095,7 +5123,7 @@ fn whileExpr( |
| 5095 | 5123 | .inst = err_union, |
| 5096 | 5124 | .bool_bit = try continue_scope.addUnNode(tag, err_union, node), |
| 5097 | 5125 | }; |
| 5098 | } else if (while_full.payload_token) |payload_token| { | |
| 5126 | } else if (while_full.payload_token) |_| { | |
| 5099 | 5127 | const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none; |
| 5100 | 5128 | const optional = try expr(&continue_scope, &continue_scope.base, cond_rl, while_full.ast.cond_expr); |
| 5101 | 5129 | const tag: Zir.Inst.Tag = if (payload_is_ref) .is_non_null_ptr else .is_non_null; |
| ... | ... | @@ -5119,46 +5147,35 @@ fn whileExpr( |
| 5119 | 5147 | try loop_scope.instructions.append(astgen.gpa, cond_block); |
| 5120 | 5148 | try continue_scope.setBlockBody(cond_block); |
| 5121 | 5149 | |
| 5122 | // TODO avoid emitting the continue expr when there | |
| 5123 | // are no jumps to it. This happens when the last statement of a while body is noreturn | |
| 5124 | // and there are no `continue` statements. | |
| 5125 | if (while_full.ast.cont_expr != 0) { | |
| 5126 | _ = try expr(&loop_scope, &loop_scope.base, .{ .ty = .void_type }, while_full.ast.cont_expr); | |
| 5127 | } | |
| 5128 | const repeat_tag: Zir.Inst.Tag = if (is_inline) .repeat_inline else .repeat; | |
| 5129 | _ = try loop_scope.addNode(repeat_tag, node); | |
| 5130 | ||
| 5131 | try loop_scope.setBlockBody(loop_block); | |
| 5132 | loop_scope.break_block = loop_block; | |
| 5133 | loop_scope.continue_block = cond_block; | |
| 5134 | if (while_full.label_token) |label_token| { | |
| 5135 | loop_scope.label = @as(?GenZir.Label, GenZir.Label{ | |
| 5136 | .token = label_token, | |
| 5137 | .block_inst = loop_block, | |
| 5138 | }); | |
| 5139 | } | |
| 5140 | ||
| 5141 | 5150 | var then_scope = parent_gz.makeSubBlock(&continue_scope.base); |
| 5142 | 5151 | defer then_scope.instructions.deinit(astgen.gpa); |
| 5143 | 5152 | |
| 5144 | 5153 | var payload_val_scope: Scope.LocalVal = undefined; |
| 5145 | 5154 | |
| 5146 | 5155 | const then_sub_scope = s: { |
| 5147 | if (while_full.error_token) |error_token| { | |
| 5148 | const tag: Zir.Inst.Tag = if (payload_is_ref) | |
| 5149 | .err_union_payload_unsafe_ptr | |
| 5150 | else | |
| 5151 | .err_union_payload_unsafe; | |
| 5152 | const payload_inst = try then_scope.addUnNode(tag, cond.inst, node); | |
| 5153 | const ident_name = try astgen.identAsString(error_token); | |
| 5154 | payload_val_scope = .{ | |
| 5155 | .parent = &then_scope.base, | |
| 5156 | .gen_zir = &then_scope, | |
| 5157 | .name = ident_name, | |
| 5158 | .inst = payload_inst, | |
| 5159 | .token_src = error_token, | |
| 5160 | }; | |
| 5161 | break :s &payload_val_scope.base; | |
| 5156 | if (while_full.error_token != null) { | |
| 5157 | if (while_full.payload_token) |payload_token| { | |
| 5158 | const tag: Zir.Inst.Tag = if (payload_is_ref) | |
| 5159 | .err_union_payload_unsafe_ptr | |
| 5160 | else | |
| 5161 | .err_union_payload_unsafe; | |
| 5162 | const payload_inst = try then_scope.addUnNode(tag, cond.inst, node); | |
| 5163 | const ident_token = if (payload_is_ref) payload_token + 1 else payload_token; | |
| 5164 | if (mem.eql(u8, "_", tree.tokenSlice(ident_token))) | |
| 5165 | break :s &then_scope.base; | |
| 5166 | const ident_name = try astgen.identAsString(payload_token + @boolToInt(payload_is_ref)); | |
| 5167 | payload_val_scope = .{ | |
| 5168 | .parent = &then_scope.base, | |
| 5169 | .gen_zir = &then_scope, | |
| 5170 | .name = ident_name, | |
| 5171 | .inst = payload_inst, | |
| 5172 | .token_src = payload_token, | |
| 5173 | .used = .capture, | |
| 5174 | }; | |
| 5175 | break :s &payload_val_scope.base; | |
| 5176 | } else { | |
| 5177 | break :s &then_scope.base; | |
| 5178 | } | |
| 5162 | 5179 | } else if (while_full.payload_token) |payload_token| { |
| 5163 | 5180 | const ident_token = if (payload_is_ref) payload_token + 1 else payload_token; |
| 5164 | 5181 | const tag: Zir.Inst.Tag = if (payload_is_ref) |
| ... | ... | @@ -5167,12 +5184,15 @@ fn whileExpr( |
| 5167 | 5184 | .optional_payload_unsafe; |
| 5168 | 5185 | const payload_inst = try then_scope.addUnNode(tag, cond.inst, node); |
| 5169 | 5186 | const ident_name = try astgen.identAsString(ident_token); |
| 5187 | if (mem.eql(u8, "_", tree.tokenSlice(ident_token))) | |
| 5188 | break :s &then_scope.base; | |
| 5170 | 5189 | payload_val_scope = .{ |
| 5171 | 5190 | .parent = &then_scope.base, |
| 5172 | 5191 | .gen_zir = &then_scope, |
| 5173 | 5192 | .name = ident_name, |
| 5174 | 5193 | .inst = payload_inst, |
| 5175 | 5194 | .token_src = ident_token, |
| 5195 | .used = .capture, | |
| 5176 | 5196 | }; |
| 5177 | 5197 | break :s &payload_val_scope.base; |
| 5178 | 5198 | } else { |
| ... | ... | @@ -5180,8 +5200,29 @@ fn whileExpr( |
| 5180 | 5200 | } |
| 5181 | 5201 | }; |
| 5182 | 5202 | |
| 5203 | // This code could be improved to avoid emitting the continue expr when there | |
| 5204 | // are no jumps to it. This happens when the last statement of a while body is noreturn | |
| 5205 | // and there are no `continue` statements. | |
| 5206 | // Tracking issue: https://github.com/ziglang/zig/issues/9185 | |
| 5207 | if (while_full.ast.cont_expr != 0) { | |
| 5208 | _ = try expr(&loop_scope, then_sub_scope, .{ .ty = .void_type }, while_full.ast.cont_expr); | |
| 5209 | } | |
| 5210 | const repeat_tag: Zir.Inst.Tag = if (is_inline) .repeat_inline else .repeat; | |
| 5211 | _ = try loop_scope.addNode(repeat_tag, node); | |
| 5212 | ||
| 5213 | try loop_scope.setBlockBody(loop_block); | |
| 5214 | loop_scope.break_block = loop_block; | |
| 5215 | loop_scope.continue_block = cond_block; | |
| 5216 | if (while_full.label_token) |label_token| { | |
| 5217 | loop_scope.label = @as(?GenZir.Label, GenZir.Label{ | |
| 5218 | .token = label_token, | |
| 5219 | .block_inst = loop_block, | |
| 5220 | }); | |
| 5221 | } | |
| 5222 | ||
| 5183 | 5223 | loop_scope.break_count += 1; |
| 5184 | 5224 | const then_result = try expr(&then_scope, then_sub_scope, loop_scope.break_result_loc, while_full.ast.then_expr); |
| 5225 | try checkUsed(parent_gz, &then_scope.base, then_sub_scope); | |
| 5185 | 5226 | |
| 5186 | 5227 | var else_scope = parent_gz.makeSubBlock(&continue_scope.base); |
| 5187 | 5228 | defer else_scope.instructions.deinit(astgen.gpa); |
| ... | ... | @@ -5200,21 +5241,26 @@ fn whileExpr( |
| 5200 | 5241 | .err_union_code; |
| 5201 | 5242 | const payload_inst = try else_scope.addUnNode(tag, cond.inst, node); |
| 5202 | 5243 | const ident_name = try astgen.identAsString(error_token); |
| 5244 | if (mem.eql(u8, tree.tokenSlice(error_token), "_")) | |
| 5245 | break :s &else_scope.base; | |
| 5203 | 5246 | payload_val_scope = .{ |
| 5204 | 5247 | .parent = &else_scope.base, |
| 5205 | 5248 | .gen_zir = &else_scope, |
| 5206 | 5249 | .name = ident_name, |
| 5207 | 5250 | .inst = payload_inst, |
| 5208 | 5251 | .token_src = error_token, |
| 5252 | .used = .capture, | |
| 5209 | 5253 | }; |
| 5210 | 5254 | break :s &payload_val_scope.base; |
| 5211 | 5255 | } else { |
| 5212 | 5256 | break :s &else_scope.base; |
| 5213 | 5257 | } |
| 5214 | 5258 | }; |
| 5259 | const e = try expr(&else_scope, sub_scope, loop_scope.break_result_loc, else_node); | |
| 5260 | try checkUsed(parent_gz, &else_scope.base, sub_scope); | |
| 5215 | 5261 | break :blk .{ |
| 5216 | 5262 | .src = else_node, |
| 5217 | .result = try expr(&else_scope, sub_scope, loop_scope.break_result_loc, else_node), | |
| 5263 | .result = e, | |
| 5218 | 5264 | }; |
| 5219 | 5265 | } else .{ |
| 5220 | 5266 | .src = while_full.ast.then_expr, |
| ... | ... | @@ -5229,7 +5275,6 @@ fn whileExpr( |
| 5229 | 5275 | const break_tag: Zir.Inst.Tag = if (is_inline) .break_inline else .@"break"; |
| 5230 | 5276 | return finishThenElseBlock( |
| 5231 | 5277 | parent_gz, |
| 5232 | scope, | |
| 5233 | 5278 | rl, |
| 5234 | 5279 | node, |
| 5235 | 5280 | &loop_scope, |
| ... | ... | @@ -5237,8 +5282,6 @@ fn whileExpr( |
| 5237 | 5282 | &else_scope, |
| 5238 | 5283 | condbr, |
| 5239 | 5284 | cond.bool_bit, |
| 5240 | while_full.ast.then_expr, | |
| 5241 | else_info.src, | |
| 5242 | 5285 | then_result, |
| 5243 | 5286 | else_info.result, |
| 5244 | 5287 | loop_block, |
| ... | ... | @@ -5345,6 +5388,7 @@ fn forExpr( |
| 5345 | 5388 | .name = name_str_index, |
| 5346 | 5389 | .inst = payload_inst, |
| 5347 | 5390 | .token_src = ident, |
| 5391 | .used = .capture, | |
| 5348 | 5392 | }; |
| 5349 | 5393 | payload_sub_scope = &payload_val_scope.base; |
| 5350 | 5394 | } else if (is_ptr) { |
| ... | ... | @@ -5367,13 +5411,15 @@ fn forExpr( |
| 5367 | 5411 | .name = index_name, |
| 5368 | 5412 | .ptr = index_ptr, |
| 5369 | 5413 | .token_src = index_token, |
| 5370 | .is_comptime = parent_gz.force_comptime, | |
| 5414 | .maybe_comptime = is_inline, | |
| 5415 | .used = .loop_index, | |
| 5371 | 5416 | }; |
| 5372 | 5417 | break :blk &index_scope.base; |
| 5373 | 5418 | }; |
| 5374 | 5419 | |
| 5375 | 5420 | loop_scope.break_count += 1; |
| 5376 | 5421 | const then_result = try expr(&then_scope, then_sub_scope, loop_scope.break_result_loc, for_full.ast.then_expr); |
| 5422 | try checkUsed(parent_gz, &then_scope.base, then_sub_scope); | |
| 5377 | 5423 | |
| 5378 | 5424 | var else_scope = parent_gz.makeSubBlock(&cond_scope.base); |
| 5379 | 5425 | defer else_scope.instructions.deinit(astgen.gpa); |
| ... | ... | @@ -5402,7 +5448,6 @@ fn forExpr( |
| 5402 | 5448 | const break_tag: Zir.Inst.Tag = if (is_inline) .break_inline else .@"break"; |
| 5403 | 5449 | return finishThenElseBlock( |
| 5404 | 5450 | parent_gz, |
| 5405 | scope, | |
| 5406 | 5451 | rl, |
| 5407 | 5452 | node, |
| 5408 | 5453 | &loop_scope, |
| ... | ... | @@ -5410,8 +5455,6 @@ fn forExpr( |
| 5410 | 5455 | &else_scope, |
| 5411 | 5456 | condbr, |
| 5412 | 5457 | cond, |
| 5413 | for_full.ast.then_expr, | |
| 5414 | else_info.src, | |
| 5415 | 5458 | then_result, |
| 5416 | 5459 | else_info.result, |
| 5417 | 5460 | loop_block, |
| ... | ... | @@ -5614,10 +5657,12 @@ fn switchExpr( |
| 5614 | 5657 | .name = capture_name, |
| 5615 | 5658 | .inst = capture, |
| 5616 | 5659 | .token_src = payload_token, |
| 5660 | .used = .capture, | |
| 5617 | 5661 | }; |
| 5618 | 5662 | break :blk &capture_val_scope.base; |
| 5619 | 5663 | }; |
| 5620 | 5664 | const case_result = try expr(&case_scope, sub_scope, block_scope.break_result_loc, case.ast.target_expr); |
| 5665 | try checkUsed(parent_gz, &case_scope.base, sub_scope); | |
| 5621 | 5666 | if (!parent_gz.refIsNoReturn(case_result)) { |
| 5622 | 5667 | block_scope.break_count += 1; |
| 5623 | 5668 | _ = try case_scope.addBreak(.@"break", switch_block, case_result); |
| ... | ... | @@ -5706,6 +5751,7 @@ fn switchExpr( |
| 5706 | 5751 | .name = capture_name, |
| 5707 | 5752 | .inst = capture, |
| 5708 | 5753 | .token_src = payload_token, |
| 5754 | .used = .capture, | |
| 5709 | 5755 | }; |
| 5710 | 5756 | break :blk &capture_val_scope.base; |
| 5711 | 5757 | }; |
| ... | ... | @@ -5739,6 +5785,7 @@ fn switchExpr( |
| 5739 | 5785 | } |
| 5740 | 5786 | |
| 5741 | 5787 | const case_result = try expr(&case_scope, sub_scope, block_scope.break_result_loc, case.ast.target_expr); |
| 5788 | try checkUsed(parent_gz, &case_scope.base, sub_scope); | |
| 5742 | 5789 | if (!parent_gz.refIsNoReturn(case_result)) { |
| 5743 | 5790 | block_scope.break_count += 1; |
| 5744 | 5791 | _ = try case_scope.addBreak(.@"break", switch_block, case_result); |
| ... | ... | @@ -5752,6 +5799,7 @@ fn switchExpr( |
| 5752 | 5799 | const item_node = case.ast.values[0]; |
| 5753 | 5800 | const item_inst = try comptimeExpr(parent_gz, scope, item_rl, item_node); |
| 5754 | 5801 | const case_result = try expr(&case_scope, sub_scope, block_scope.break_result_loc, case.ast.target_expr); |
| 5802 | try checkUsed(parent_gz, &case_scope.base, sub_scope); | |
| 5755 | 5803 | if (!parent_gz.refIsNoReturn(case_result)) { |
| 5756 | 5804 | block_scope.break_count += 1; |
| 5757 | 5805 | _ = try case_scope.addBreak(.@"break", switch_block, case_result); |
| ... | ... | @@ -5950,7 +5998,7 @@ fn switchExpr( |
| 5950 | 5998 | const block_ref = parent_gz.indexToRef(switch_block); |
| 5951 | 5999 | switch (rl) { |
| 5952 | 6000 | .ref => return block_ref, |
| 5953 | else => return rvalue(parent_gz, scope, rl, block_ref, switch_node), | |
| 6001 | else => return rvalue(parent_gz, rl, block_ref, switch_node), | |
| 5954 | 6002 | } |
| 5955 | 6003 | }, |
| 5956 | 6004 | .break_void => { |
| ... | ... | @@ -6016,7 +6064,6 @@ fn ret(gz: *GenZir, scope: *Scope, node: ast.Node.Index) InnerError!Zir.Inst.Ref |
| 6016 | 6064 | const astgen = gz.astgen; |
| 6017 | 6065 | const tree = astgen.tree; |
| 6018 | 6066 | const node_datas = tree.nodes.items(.data); |
| 6019 | const main_tokens = tree.nodes.items(.main_token); | |
| 6020 | 6067 | |
| 6021 | 6068 | if (gz.in_defer) return astgen.failNode(node, "cannot return from defer expression", .{}); |
| 6022 | 6069 | |
| ... | ... | @@ -6092,7 +6139,7 @@ fn identifier( |
| 6092 | 6139 | } |
| 6093 | 6140 | |
| 6094 | 6141 | if (simple_types.get(ident_name)) |zir_const_ref| { |
| 6095 | return rvalue(gz, scope, rl, zir_const_ref, ident); | |
| 6142 | return rvalue(gz, rl, zir_const_ref, ident); | |
| 6096 | 6143 | } |
| 6097 | 6144 | |
| 6098 | 6145 | if (ident_name.len >= 2) integer: { |
| ... | ... | @@ -6118,7 +6165,7 @@ fn identifier( |
| 6118 | 6165 | .bit_count = bit_count, |
| 6119 | 6166 | } }, |
| 6120 | 6167 | }); |
| 6121 | return rvalue(gz, scope, rl, result, ident); | |
| 6168 | return rvalue(gz, rl, result, ident); | |
| 6122 | 6169 | } |
| 6123 | 6170 | } |
| 6124 | 6171 | |
| ... | ... | @@ -6131,33 +6178,37 @@ fn identifier( |
| 6131 | 6178 | while (true) switch (s.tag) { |
| 6132 | 6179 | .local_val => { |
| 6133 | 6180 | const local_val = s.cast(Scope.LocalVal).?; |
| 6134 | if (hit_namespace) { | |
| 6135 | // captures of non-locals need to be emitted as decl_val or decl_ref | |
| 6136 | // This *might* be capturable depending on if it is comptime known | |
| 6137 | break; | |
| 6138 | } | |
| 6181 | ||
| 6139 | 6182 | if (local_val.name == name_str_index) { |
| 6140 | return rvalue(gz, scope, rl, local_val.inst, ident); | |
| 6183 | local_val.used = .used; | |
| 6184 | // Captures of non-locals need to be emitted as decl_val or decl_ref. | |
| 6185 | // This *might* be capturable depending on if it is comptime known. | |
| 6186 | if (!hit_namespace) { | |
| 6187 | return rvalue(gz, rl, local_val.inst, ident); | |
| 6188 | } | |
| 6141 | 6189 | } |
| 6142 | 6190 | s = local_val.parent; |
| 6143 | 6191 | }, |
| 6144 | 6192 | .local_ptr => { |
| 6145 | 6193 | const local_ptr = s.cast(Scope.LocalPtr).?; |
| 6146 | 6194 | if (local_ptr.name == name_str_index) { |
| 6195 | local_ptr.used = .used; | |
| 6147 | 6196 | if (hit_namespace) { |
| 6148 | if (local_ptr.is_comptime) | |
| 6197 | if (local_ptr.maybe_comptime) | |
| 6149 | 6198 | break |
| 6150 | 6199 | else |
| 6151 | 6200 | return astgen.failNodeNotes(ident, "'{s}' not accessible from inner function", .{ident_name}, &.{ |
| 6152 | 6201 | try astgen.errNoteTok(local_ptr.token_src, "declared here", .{}), |
| 6153 | 6202 | // TODO add crossed function definition here note. |
| 6203 | // Maybe add a note to the error about it being because of the var, | |
| 6204 | // maybe recommend copying it into a const variable. -SpexGuy | |
| 6154 | 6205 | }); |
| 6155 | 6206 | } |
| 6156 | 6207 | switch (rl) { |
| 6157 | 6208 | .ref, .none_or_ref => return local_ptr.ptr, |
| 6158 | 6209 | else => { |
| 6159 | 6210 | const loaded = try gz.addUnNode(.load, local_ptr.ptr, ident); |
| 6160 | return rvalue(gz, scope, rl, loaded, ident); | |
| 6211 | return rvalue(gz, rl, loaded, ident); | |
| 6161 | 6212 | }, |
| 6162 | 6213 | } |
| 6163 | 6214 | } |
| ... | ... | @@ -6191,14 +6242,13 @@ fn identifier( |
| 6191 | 6242 | .ref, .none_or_ref => return gz.addStrTok(.decl_ref, name_str_index, ident_token), |
| 6192 | 6243 | else => { |
| 6193 | 6244 | const result = try gz.addStrTok(.decl_val, name_str_index, ident_token); |
| 6194 | return rvalue(gz, scope, rl, result, ident); | |
| 6245 | return rvalue(gz, rl, result, ident); | |
| 6195 | 6246 | }, |
| 6196 | 6247 | } |
| 6197 | 6248 | } |
| 6198 | 6249 | |
| 6199 | 6250 | fn stringLiteral( |
| 6200 | 6251 | gz: *GenZir, |
| 6201 | scope: *Scope, | |
| 6202 | 6252 | rl: ResultLoc, |
| 6203 | 6253 | node: ast.Node.Index, |
| 6204 | 6254 | ) InnerError!Zir.Inst.Ref { |
| ... | ... | @@ -6214,19 +6264,17 @@ fn stringLiteral( |
| 6214 | 6264 | .len = str.len, |
| 6215 | 6265 | } }, |
| 6216 | 6266 | }); |
| 6217 | return rvalue(gz, scope, rl, result, node); | |
| 6267 | return rvalue(gz, rl, result, node); | |
| 6218 | 6268 | } |
| 6219 | 6269 | |
| 6220 | 6270 | fn multilineStringLiteral( |
| 6221 | 6271 | gz: *GenZir, |
| 6222 | scope: *Scope, | |
| 6223 | 6272 | rl: ResultLoc, |
| 6224 | 6273 | node: ast.Node.Index, |
| 6225 | 6274 | ) InnerError!Zir.Inst.Ref { |
| 6226 | 6275 | const astgen = gz.astgen; |
| 6227 | 6276 | const tree = astgen.tree; |
| 6228 | 6277 | const node_datas = tree.nodes.items(.data); |
| 6229 | const main_tokens = tree.nodes.items(.main_token); | |
| 6230 | 6278 | |
| 6231 | 6279 | const start = node_datas[node].lhs; |
| 6232 | 6280 | const end = node_datas[node].rhs; |
| ... | ... | @@ -6258,10 +6306,10 @@ fn multilineStringLiteral( |
| 6258 | 6306 | .len = @intCast(u32, string_bytes.items.len - str_index), |
| 6259 | 6307 | } }, |
| 6260 | 6308 | }); |
| 6261 | return rvalue(gz, scope, rl, result, node); | |
| 6309 | return rvalue(gz, rl, result, node); | |
| 6262 | 6310 | } |
| 6263 | 6311 | |
| 6264 | fn charLiteral(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !Zir.Inst.Ref { | |
| 6312 | fn charLiteral(gz: *GenZir, rl: ResultLoc, node: ast.Node.Index) !Zir.Inst.Ref { | |
| 6265 | 6313 | const astgen = gz.astgen; |
| 6266 | 6314 | const tree = astgen.tree; |
| 6267 | 6315 | const main_tokens = tree.nodes.items(.main_token); |
| ... | ... | @@ -6281,15 +6329,10 @@ fn charLiteral(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) |
| 6281 | 6329 | }, |
| 6282 | 6330 | }; |
| 6283 | 6331 | const result = try gz.addInt(value); |
| 6284 | return rvalue(gz, scope, rl, result, node); | |
| 6332 | return rvalue(gz, rl, result, node); | |
| 6285 | 6333 | } |
| 6286 | 6334 | |
| 6287 | fn integerLiteral( | |
| 6288 | gz: *GenZir, | |
| 6289 | scope: *Scope, | |
| 6290 | rl: ResultLoc, | |
| 6291 | node: ast.Node.Index, | |
| 6292 | ) InnerError!Zir.Inst.Ref { | |
| 6335 | fn integerLiteral(gz: *GenZir, rl: ResultLoc, node: ast.Node.Index) InnerError!Zir.Inst.Ref { | |
| 6293 | 6336 | const astgen = gz.astgen; |
| 6294 | 6337 | const tree = astgen.tree; |
| 6295 | 6338 | const main_tokens = tree.nodes.items(.main_token); |
| ... | ... | @@ -6301,7 +6344,7 @@ fn integerLiteral( |
| 6301 | 6344 | 1 => .one, |
| 6302 | 6345 | else => try gz.addInt(small_int), |
| 6303 | 6346 | }; |
| 6304 | return rvalue(gz, scope, rl, result, node); | |
| 6347 | return rvalue(gz, rl, result, node); | |
| 6305 | 6348 | } else |err| switch (err) { |
| 6306 | 6349 | error.InvalidCharacter => unreachable, // Caught by the parser. |
| 6307 | 6350 | error.Overflow => {}, |
| ... | ... | @@ -6332,17 +6375,11 @@ fn integerLiteral( |
| 6332 | 6375 | const limbs = big_int.limbs[0..big_int.len()]; |
| 6333 | 6376 | assert(big_int.isPositive()); |
| 6334 | 6377 | const result = try gz.addIntBig(limbs); |
| 6335 | return rvalue(gz, scope, rl, result, node); | |
| 6378 | return rvalue(gz, rl, result, node); | |
| 6336 | 6379 | } |
| 6337 | 6380 | |
| 6338 | fn floatLiteral( | |
| 6339 | gz: *GenZir, | |
| 6340 | scope: *Scope, | |
| 6341 | rl: ResultLoc, | |
| 6342 | node: ast.Node.Index, | |
| 6343 | ) InnerError!Zir.Inst.Ref { | |
| 6381 | fn floatLiteral(gz: *GenZir, rl: ResultLoc, node: ast.Node.Index) InnerError!Zir.Inst.Ref { | |
| 6344 | 6382 | const astgen = gz.astgen; |
| 6345 | const arena = astgen.arena; | |
| 6346 | 6383 | const tree = astgen.tree; |
| 6347 | 6384 | const main_tokens = tree.nodes.items(.main_token); |
| 6348 | 6385 | |
| ... | ... | @@ -6363,7 +6400,7 @@ fn floatLiteral( |
| 6363 | 6400 | const bigger_again: f128 = smaller_float; |
| 6364 | 6401 | if (bigger_again == float_number) { |
| 6365 | 6402 | const result = try gz.addFloat(smaller_float, node); |
| 6366 | return rvalue(gz, scope, rl, result, node); | |
| 6403 | return rvalue(gz, rl, result, node); | |
| 6367 | 6404 | } |
| 6368 | 6405 | // We need to use 128 bits. Break the float into 4 u32 values so we can |
| 6369 | 6406 | // put it into the `extra` array. |
| ... | ... | @@ -6374,7 +6411,7 @@ fn floatLiteral( |
| 6374 | 6411 | .piece2 = @truncate(u32, int_bits >> 64), |
| 6375 | 6412 | .piece3 = @truncate(u32, int_bits >> 96), |
| 6376 | 6413 | }); |
| 6377 | return rvalue(gz, scope, rl, result, node); | |
| 6414 | return rvalue(gz, rl, result, node); | |
| 6378 | 6415 | } |
| 6379 | 6416 | |
| 6380 | 6417 | fn asmExpr( |
| ... | ... | @@ -6385,7 +6422,6 @@ fn asmExpr( |
| 6385 | 6422 | full: ast.full.Asm, |
| 6386 | 6423 | ) InnerError!Zir.Inst.Ref { |
| 6387 | 6424 | const astgen = gz.astgen; |
| 6388 | const arena = astgen.arena; | |
| 6389 | 6425 | const tree = astgen.tree; |
| 6390 | 6426 | const main_tokens = tree.nodes.items(.main_token); |
| 6391 | 6427 | const node_datas = tree.nodes.items(.data); |
| ... | ... | @@ -6427,6 +6463,33 @@ fn asmExpr( |
| 6427 | 6463 | // issues and decide how to handle outputs. Do we want this to be identifiers? |
| 6428 | 6464 | // Or maybe we want to force this to be expressions with a pointer type. |
| 6429 | 6465 | // Until that is figured out this is only hooked up for referencing Decls. |
| 6466 | // TODO we have put this as an identifier lookup just so that we don't get | |
| 6467 | // unused vars for outputs. We need to check if this is correct in the future ^^ | |
| 6468 | // so we just put in this simple lookup. This is a workaround. | |
| 6469 | { | |
| 6470 | var s = scope; | |
| 6471 | while (true) switch (s.tag) { | |
| 6472 | .local_val => { | |
| 6473 | const local_val = s.cast(Scope.LocalVal).?; | |
| 6474 | if (local_val.name == str_index) { | |
| 6475 | local_val.used = .used; | |
| 6476 | break; | |
| 6477 | } | |
| 6478 | s = local_val.parent; | |
| 6479 | }, | |
| 6480 | .local_ptr => { | |
| 6481 | const local_ptr = s.cast(Scope.LocalPtr).?; | |
| 6482 | if (local_ptr.name == str_index) { | |
| 6483 | local_ptr.used = .used; | |
| 6484 | break; | |
| 6485 | } | |
| 6486 | s = local_ptr.parent; | |
| 6487 | }, | |
| 6488 | .gen_zir => s = s.cast(GenZir).?.parent, | |
| 6489 | .defer_normal, .defer_error => s = s.cast(Scope.Defer).?.parent, | |
| 6490 | .namespace, .top => break, | |
| 6491 | }; | |
| 6492 | } | |
| 6430 | 6493 | const operand = try gz.addStrTok(.decl_ref, str_index, ident_token); |
| 6431 | 6494 | outputs[i] = .{ |
| 6432 | 6495 | .name = name, |
| ... | ... | @@ -6447,7 +6510,6 @@ fn asmExpr( |
| 6447 | 6510 | const name = try astgen.identAsString(symbolic_name); |
| 6448 | 6511 | const constraint_token = symbolic_name + 2; |
| 6449 | 6512 | const constraint = (try astgen.strLitAsString(constraint_token)).index; |
| 6450 | const has_arrow = token_tags[symbolic_name + 4] == .arrow; | |
| 6451 | 6513 | const operand = try expr(gz, scope, .{ .ty = .usize_type }, node_datas[input_node].lhs); |
| 6452 | 6514 | inputs[i] = .{ |
| 6453 | 6515 | .name = name, |
| ... | ... | @@ -6492,7 +6554,7 @@ fn asmExpr( |
| 6492 | 6554 | .inputs = inputs, |
| 6493 | 6555 | .clobbers = clobbers_buffer[0..clobber_i], |
| 6494 | 6556 | }); |
| 6495 | return rvalue(gz, scope, rl, result, node); | |
| 6557 | return rvalue(gz, rl, result, node); | |
| 6496 | 6558 | } |
| 6497 | 6559 | |
| 6498 | 6560 | fn as( |
| ... | ... | @@ -6507,7 +6569,7 @@ fn as( |
| 6507 | 6569 | switch (rl) { |
| 6508 | 6570 | .none, .none_or_ref, .discard, .ref, .ty => { |
| 6509 | 6571 | const result = try expr(gz, scope, .{ .ty = dest_type }, rhs); |
| 6510 | return rvalue(gz, scope, rl, result, node); | |
| 6572 | return rvalue(gz, rl, result, node); | |
| 6511 | 6573 | }, |
| 6512 | 6574 | .ptr, .inferred_ptr => |result_ptr| { |
| 6513 | 6575 | return asRlPtr(gz, scope, rl, result_ptr, rhs, dest_type); |
| ... | ... | @@ -6529,18 +6591,18 @@ fn unionInit( |
| 6529 | 6591 | const field_name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, params[1]); |
| 6530 | 6592 | switch (rl) { |
| 6531 | 6593 | .none, .none_or_ref, .discard, .ref, .ty, .inferred_ptr => { |
| 6532 | const field_type = try gz.addPlNode(.field_type_ref, params[1], Zir.Inst.FieldTypeRef{ | |
| 6594 | _ = try gz.addPlNode(.field_type_ref, params[1], Zir.Inst.FieldTypeRef{ | |
| 6533 | 6595 | .container_type = union_type, |
| 6534 | 6596 | .field_name = field_name, |
| 6535 | 6597 | }); |
| 6536 | 6598 | const result = try expr(gz, scope, .{ .ty = union_type }, params[2]); |
| 6537 | return rvalue(gz, scope, rl, result, node); | |
| 6599 | return rvalue(gz, rl, result, node); | |
| 6538 | 6600 | }, |
| 6539 | 6601 | .ptr => |result_ptr| { |
| 6540 | return unionInitRlPtr(gz, scope, rl, node, result_ptr, params[2], union_type, field_name); | |
| 6602 | return unionInitRlPtr(gz, scope, node, result_ptr, params[2], union_type, field_name); | |
| 6541 | 6603 | }, |
| 6542 | 6604 | .block_ptr => |block_scope| { |
| 6543 | return unionInitRlPtr(gz, scope, rl, node, block_scope.rl_ptr, params[2], union_type, field_name); | |
| 6605 | return unionInitRlPtr(gz, scope, node, block_scope.rl_ptr, params[2], union_type, field_name); | |
| 6544 | 6606 | }, |
| 6545 | 6607 | } |
| 6546 | 6608 | } |
| ... | ... | @@ -6548,7 +6610,6 @@ fn unionInit( |
| 6548 | 6610 | fn unionInitRlPtr( |
| 6549 | 6611 | parent_gz: *GenZir, |
| 6550 | 6612 | scope: *Scope, |
| 6551 | rl: ResultLoc, | |
| 6552 | 6613 | node: ast.Node.Index, |
| 6553 | 6614 | result_ptr: Zir.Inst.Ref, |
| 6554 | 6615 | expr_node: ast.Node.Index, |
| ... | ... | @@ -6596,7 +6657,7 @@ fn asRlPtr( |
| 6596 | 6657 | parent_zir.appendAssumeCapacity(src_inst); |
| 6597 | 6658 | } |
| 6598 | 6659 | const casted_result = try parent_gz.addBin(.as, dest_type, result); |
| 6599 | return rvalue(parent_gz, scope, rl, casted_result, operand_node); | |
| 6660 | return rvalue(parent_gz, rl, casted_result, operand_node); | |
| 6600 | 6661 | } else { |
| 6601 | 6662 | try parent_zir.appendSlice(astgen.gpa, as_scope.instructions.items); |
| 6602 | 6663 | return result; |
| ... | ... | @@ -6620,16 +6681,16 @@ fn bitCast( |
| 6620 | 6681 | .lhs = dest_type, |
| 6621 | 6682 | .rhs = operand, |
| 6622 | 6683 | }); |
| 6623 | return rvalue(gz, scope, rl, result, node); | |
| 6684 | return rvalue(gz, rl, result, node); | |
| 6624 | 6685 | }, |
| 6625 | 6686 | .ref => { |
| 6626 | 6687 | return astgen.failNode(node, "cannot take address of `@bitCast` result", .{}); |
| 6627 | 6688 | }, |
| 6628 | 6689 | .ptr, .inferred_ptr => |result_ptr| { |
| 6629 | return bitCastRlPtr(gz, scope, rl, node, dest_type, result_ptr, rhs); | |
| 6690 | return bitCastRlPtr(gz, scope, node, dest_type, result_ptr, rhs); | |
| 6630 | 6691 | }, |
| 6631 | 6692 | .block_ptr => |block| { |
| 6632 | return bitCastRlPtr(gz, scope, rl, node, dest_type, block.rl_ptr, rhs); | |
| 6693 | return bitCastRlPtr(gz, scope, node, dest_type, block.rl_ptr, rhs); | |
| 6633 | 6694 | }, |
| 6634 | 6695 | } |
| 6635 | 6696 | } |
| ... | ... | @@ -6637,7 +6698,6 @@ fn bitCast( |
| 6637 | 6698 | fn bitCastRlPtr( |
| 6638 | 6699 | gz: *GenZir, |
| 6639 | 6700 | scope: *Scope, |
| 6640 | rl: ResultLoc, | |
| 6641 | 6701 | node: ast.Node.Index, |
| 6642 | 6702 | dest_type: Zir.Inst.Ref, |
| 6643 | 6703 | result_ptr: Zir.Inst.Ref, |
| ... | ... | @@ -6662,7 +6722,7 @@ fn typeOf( |
| 6662 | 6722 | } |
| 6663 | 6723 | if (params.len == 1) { |
| 6664 | 6724 | const result = try gz.addUnNode(.typeof, try expr(gz, scope, .none, params[0]), node); |
| 6665 | return rvalue(gz, scope, rl, result, node); | |
| 6725 | return rvalue(gz, rl, result, node); | |
| 6666 | 6726 | } |
| 6667 | 6727 | const arena = gz.astgen.arena; |
| 6668 | 6728 | var items = try arena.alloc(Zir.Inst.Ref, params.len); |
| ... | ... | @@ -6671,7 +6731,7 @@ fn typeOf( |
| 6671 | 6731 | } |
| 6672 | 6732 | |
| 6673 | 6733 | const result = try gz.addExtendedMultiOp(.typeof_peer, node, items); |
| 6674 | return rvalue(gz, scope, rl, result, node); | |
| 6734 | return rvalue(gz, rl, result, node); | |
| 6675 | 6735 | } |
| 6676 | 6736 | |
| 6677 | 6737 | fn builtinCall( |
| ... | ... | @@ -6711,7 +6771,6 @@ fn builtinCall( |
| 6711 | 6771 | switch (info.tag) { |
| 6712 | 6772 | .import => { |
| 6713 | 6773 | const node_tags = tree.nodes.items(.tag); |
| 6714 | const node_datas = tree.nodes.items(.data); | |
| 6715 | 6774 | const operand_node = params[0]; |
| 6716 | 6775 | |
| 6717 | 6776 | if (node_tags[operand_node] != .string_literal) { |
| ... | ... | @@ -6722,7 +6781,7 @@ fn builtinCall( |
| 6722 | 6781 | const str = try astgen.strLitAsString(str_lit_token); |
| 6723 | 6782 | try astgen.imports.put(astgen.gpa, str.index, {}); |
| 6724 | 6783 | const result = try gz.addStrTok(.import, str.index, str_lit_token); |
| 6725 | return rvalue(gz, scope, rl, result, node); | |
| 6784 | return rvalue(gz, rl, result, node); | |
| 6726 | 6785 | }, |
| 6727 | 6786 | .compile_log => { |
| 6728 | 6787 | const arg_refs = try astgen.gpa.alloc(Zir.Inst.Ref, params.len); |
| ... | ... | @@ -6731,7 +6790,7 @@ fn builtinCall( |
| 6731 | 6790 | for (params) |param, i| arg_refs[i] = try expr(gz, scope, .none, param); |
| 6732 | 6791 | |
| 6733 | 6792 | const result = try gz.addExtendedMultiOp(.compile_log, node, arg_refs); |
| 6734 | return rvalue(gz, scope, rl, result, node); | |
| 6793 | return rvalue(gz, rl, result, node); | |
| 6735 | 6794 | }, |
| 6736 | 6795 | .field => { |
| 6737 | 6796 | const field_name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, params[1]); |
| ... | ... | @@ -6745,7 +6804,7 @@ fn builtinCall( |
| 6745 | 6804 | .lhs = try expr(gz, scope, .none, params[0]), |
| 6746 | 6805 | .field_name = field_name, |
| 6747 | 6806 | }); |
| 6748 | return rvalue(gz, scope, rl, result, node); | |
| 6807 | return rvalue(gz, rl, result, node); | |
| 6749 | 6808 | }, |
| 6750 | 6809 | .as => return as( gz, scope, rl, node, params[0], params[1]), |
| 6751 | 6810 | .bit_cast => return bitCast( gz, scope, rl, node, params[0], params[1]), |
| ... | ... | @@ -6764,9 +6823,32 @@ fn builtinCall( |
| 6764 | 6823 | .identifier => { |
| 6765 | 6824 | const ident_token = main_tokens[params[0]]; |
| 6766 | 6825 | decl_name = try astgen.identAsString(ident_token); |
| 6767 | // TODO look for local variables in scope matching `decl_name` and emit a compile | |
| 6768 | // error. Only top-level declarations can be exported. Until this is done, the | |
| 6769 | // compile error will end up being "use of undeclared identifier" in Sema. | |
| 6826 | { | |
| 6827 | var s = scope; | |
| 6828 | while (true) switch (s.tag) { | |
| 6829 | .local_val => { | |
| 6830 | const local_val = s.cast(Scope.LocalVal).?; | |
| 6831 | if (local_val.name == decl_name) { | |
| 6832 | local_val.used = .used; | |
| 6833 | break; | |
| 6834 | } | |
| 6835 | s = local_val.parent; | |
| 6836 | }, | |
| 6837 | .local_ptr => { | |
| 6838 | const local_ptr = s.cast(Scope.LocalPtr).?; | |
| 6839 | if (local_ptr.name == decl_name) { | |
| 6840 | if (!local_ptr.maybe_comptime) | |
| 6841 | return astgen.failNode(params[0], "unable to export runtime-known value", .{}); | |
| 6842 | local_ptr.used = .used; | |
| 6843 | break; | |
| 6844 | } | |
| 6845 | s = local_ptr.parent; | |
| 6846 | }, | |
| 6847 | .gen_zir => s = s.cast(GenZir).?.parent, | |
| 6848 | .defer_normal, .defer_error => s = s.cast(Scope.Defer).?.parent, | |
| 6849 | .namespace, .top => break, | |
| 6850 | }; | |
| 6851 | } | |
| 6770 | 6852 | }, |
| 6771 | 6853 | .field_access => { |
| 6772 | 6854 | const namespace_node = node_datas[params[0]].lhs; |
| ... | ... | @@ -6776,7 +6858,7 @@ fn builtinCall( |
| 6776 | 6858 | decl_name = try astgen.identAsString(field_ident); |
| 6777 | 6859 | }, |
| 6778 | 6860 | else => return astgen.failNode( |
| 6779 | params[0], "the first @export parameter must be an identifier", .{}, | |
| 6861 | params[0], "symbol to export must identify a declaration", .{}, | |
| 6780 | 6862 | ), |
| 6781 | 6863 | } |
| 6782 | 6864 | const options = try comptimeExpr(gz, scope, .{ .ty = .export_options_type }, params[1]); |
| ... | ... | @@ -6785,7 +6867,7 @@ fn builtinCall( |
| 6785 | 6867 | .decl_name = decl_name, |
| 6786 | 6868 | .options = options, |
| 6787 | 6869 | }); |
| 6788 | return rvalue(gz, scope, rl, .void_value, node); | |
| 6870 | return rvalue(gz, rl, .void_value, node); | |
| 6789 | 6871 | }, |
| 6790 | 6872 | .@"extern" => { |
| 6791 | 6873 | const type_inst = try typeExpr(gz, scope, params[0]); |
| ... | ... | @@ -6795,18 +6877,18 @@ fn builtinCall( |
| 6795 | 6877 | .lhs = type_inst, |
| 6796 | 6878 | .rhs = options, |
| 6797 | 6879 | }); |
| 6798 | return rvalue(gz, scope, rl, result, node); | |
| 6880 | return rvalue(gz, rl, result, node); | |
| 6799 | 6881 | }, |
| 6800 | 6882 | |
| 6801 | .breakpoint => return simpleNoOpVoid(gz, scope, rl, node, .breakpoint), | |
| 6802 | .fence => return simpleNoOpVoid(gz, scope, rl, node, .fence), | |
| 6883 | .breakpoint => return simpleNoOpVoid(gz, rl, node, .breakpoint), | |
| 6884 | .fence => return simpleNoOpVoid(gz, rl, node, .fence), | |
| 6803 | 6885 | |
| 6804 | .This => return rvalue(gz, scope, rl, try gz.addNodeExtended(.this, node), node), | |
| 6805 | .return_address => return rvalue(gz, scope, rl, try gz.addNodeExtended(.ret_addr, node), node), | |
| 6806 | .src => return rvalue(gz, scope, rl, try gz.addNodeExtended(.builtin_src, node), node), | |
| 6807 | .error_return_trace => return rvalue(gz, scope, rl, try gz.addNodeExtended(.error_return_trace, node), node), | |
| 6808 | .frame => return rvalue(gz, scope, rl, try gz.addNodeExtended(.frame, node), node), | |
| 6809 | .frame_address => return rvalue(gz, scope, rl, try gz.addNodeExtended(.frame_address, node), node), | |
| 6886 | .This => return rvalue(gz, rl, try gz.addNodeExtended(.this, node), node), | |
| 6887 | .return_address => return rvalue(gz, rl, try gz.addNodeExtended(.ret_addr, node), node), | |
| 6888 | .src => return rvalue(gz, rl, try gz.addNodeExtended(.builtin_src, node), node), | |
| 6889 | .error_return_trace => return rvalue(gz, rl, try gz.addNodeExtended(.error_return_trace, node), node), | |
| 6890 | .frame => return rvalue(gz, rl, try gz.addNodeExtended(.frame, node), node), | |
| 6891 | .frame_address => return rvalue(gz, rl, try gz.addNodeExtended(.frame_address, node), node), | |
| 6810 | 6892 | |
| 6811 | 6893 | .type_info => return simpleUnOpType(gz, scope, rl, node, params[0], .type_info), |
| 6812 | 6894 | .size_of => return simpleUnOpType(gz, scope, rl, node, params[0], .size_of), |
| ... | ... | @@ -6862,7 +6944,7 @@ fn builtinCall( |
| 6862 | 6944 | .lhs = dest_align, |
| 6863 | 6945 | .rhs = rhs, |
| 6864 | 6946 | }); |
| 6865 | return rvalue(gz, scope, rl, result, node); | |
| 6947 | return rvalue(gz, rl, result, node); | |
| 6866 | 6948 | }, |
| 6867 | 6949 | |
| 6868 | 6950 | .has_decl => return hasDeclOrField(gz, scope, rl, node, params[0], params[1], .has_decl), |
| ... | ... | @@ -6898,7 +6980,7 @@ fn builtinCall( |
| 6898 | 6980 | .node = gz.nodeIndexToRelative(node), |
| 6899 | 6981 | .operand = operand, |
| 6900 | 6982 | }); |
| 6901 | return rvalue(gz, scope, rl, result, node); | |
| 6983 | return rvalue(gz, rl, result, node); | |
| 6902 | 6984 | }, |
| 6903 | 6985 | .wasm_memory_grow => { |
| 6904 | 6986 | const index_arg = try expr(gz, scope, .{ .ty = .u32_type }, params[0]); |
| ... | ... | @@ -6908,7 +6990,7 @@ fn builtinCall( |
| 6908 | 6990 | .lhs = index_arg, |
| 6909 | 6991 | .rhs = delta_arg, |
| 6910 | 6992 | }); |
| 6911 | return rvalue(gz, scope, rl, result, node); | |
| 6993 | return rvalue(gz, rl, result, node); | |
| 6912 | 6994 | }, |
| 6913 | 6995 | .c_define => { |
| 6914 | 6996 | const name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, params[0]); |
| ... | ... | @@ -6918,7 +7000,7 @@ fn builtinCall( |
| 6918 | 7000 | .lhs = name, |
| 6919 | 7001 | .rhs = value, |
| 6920 | 7002 | }); |
| 6921 | return rvalue(gz, scope, rl, result, node); | |
| 7003 | return rvalue(gz, rl, result, node); | |
| 6922 | 7004 | }, |
| 6923 | 7005 | |
| 6924 | 7006 | .splat => { |
| ... | ... | @@ -6928,7 +7010,7 @@ fn builtinCall( |
| 6928 | 7010 | .lhs = len, |
| 6929 | 7011 | .rhs = scalar, |
| 6930 | 7012 | }); |
| 6931 | return rvalue(gz, scope, rl, result, node); | |
| 7013 | return rvalue(gz, rl, result, node); | |
| 6932 | 7014 | }, |
| 6933 | 7015 | .reduce => { |
| 6934 | 7016 | const op = try expr(gz, scope, .{ .ty = .reduce_op_type }, params[0]); |
| ... | ... | @@ -6937,7 +7019,7 @@ fn builtinCall( |
| 6937 | 7019 | .lhs = op, |
| 6938 | 7020 | .rhs = scalar, |
| 6939 | 7021 | }); |
| 6940 | return rvalue(gz, scope, rl, result, node); | |
| 7022 | return rvalue(gz, rl, result, node); | |
| 6941 | 7023 | }, |
| 6942 | 7024 | |
| 6943 | 7025 | .add_with_overflow => return overflowArithmetic(gz, scope, rl, node, params, .add_with_overflow), |
| ... | ... | @@ -6964,7 +7046,7 @@ fn builtinCall( |
| 6964 | 7046 | .rhs = rhs, |
| 6965 | 7047 | .ptr = ptr, |
| 6966 | 7048 | }); |
| 6967 | return rvalue(gz, scope, rl, result, node); | |
| 7049 | return rvalue(gz, rl, result, node); | |
| 6968 | 7050 | }, |
| 6969 | 7051 | |
| 6970 | 7052 | .atomic_load => { |
| ... | ... | @@ -6984,7 +7066,7 @@ fn builtinCall( |
| 6984 | 7066 | .lhs = ptr, |
| 6985 | 7067 | .rhs = ordering, |
| 6986 | 7068 | }); |
| 6987 | return rvalue(gz, scope, rl, result, node); | |
| 7069 | return rvalue(gz, rl, result, node); | |
| 6988 | 7070 | }, |
| 6989 | 7071 | .atomic_rmw => { |
| 6990 | 7072 | const int_type = try typeExpr(gz, scope, params[0]); |
| ... | ... | @@ -7007,7 +7089,7 @@ fn builtinCall( |
| 7007 | 7089 | .operand = operand, |
| 7008 | 7090 | .ordering = ordering, |
| 7009 | 7091 | }); |
| 7010 | return rvalue(gz, scope, rl, result, node); | |
| 7092 | return rvalue(gz, rl, result, node); | |
| 7011 | 7093 | }, |
| 7012 | 7094 | .atomic_store => { |
| 7013 | 7095 | const int_type = try typeExpr(gz, scope, params[0]); |
| ... | ... | @@ -7028,7 +7110,7 @@ fn builtinCall( |
| 7028 | 7110 | .operand = operand, |
| 7029 | 7111 | .ordering = ordering, |
| 7030 | 7112 | }); |
| 7031 | return rvalue(gz, scope, rl, result, node); | |
| 7113 | return rvalue(gz, rl, result, node); | |
| 7032 | 7114 | }, |
| 7033 | 7115 | .mul_add => { |
| 7034 | 7116 | const float_type = try typeExpr(gz, scope, params[0]); |
| ... | ... | @@ -7040,7 +7122,7 @@ fn builtinCall( |
| 7040 | 7122 | .mulend2 = mulend2, |
| 7041 | 7123 | .addend = addend, |
| 7042 | 7124 | }); |
| 7043 | return rvalue(gz, scope, rl, result, node); | |
| 7125 | return rvalue(gz, rl, result, node); | |
| 7044 | 7126 | }, |
| 7045 | 7127 | .call => { |
| 7046 | 7128 | const options = try comptimeExpr(gz, scope, .{ .ty = .call_options_type }, params[0]); |
| ... | ... | @@ -7051,7 +7133,7 @@ fn builtinCall( |
| 7051 | 7133 | .callee = callee, |
| 7052 | 7134 | .args = args, |
| 7053 | 7135 | }); |
| 7054 | return rvalue(gz, scope, rl, result, node); | |
| 7136 | return rvalue(gz, rl, result, node); | |
| 7055 | 7137 | }, |
| 7056 | 7138 | .field_parent_ptr => { |
| 7057 | 7139 | const parent_type = try typeExpr(gz, scope, params[0]); |
| ... | ... | @@ -7062,7 +7144,7 @@ fn builtinCall( |
| 7062 | 7144 | .field_name = field_name, |
| 7063 | 7145 | .field_ptr = try expr(gz, scope, .{ .ty = field_ptr_type }, params[2]), |
| 7064 | 7146 | }); |
| 7065 | return rvalue(gz, scope, rl, result, node); | |
| 7147 | return rvalue(gz, rl, result, node); | |
| 7066 | 7148 | }, |
| 7067 | 7149 | .memcpy => { |
| 7068 | 7150 | const result = try gz.addPlNode(.memcpy, node, Zir.Inst.Memcpy{ |
| ... | ... | @@ -7070,7 +7152,7 @@ fn builtinCall( |
| 7070 | 7152 | .source = try expr(gz, scope, .{ .ty = .manyptr_const_u8_type }, params[1]), |
| 7071 | 7153 | .byte_count = try expr(gz, scope, .{ .ty = .usize_type }, params[2]), |
| 7072 | 7154 | }); |
| 7073 | return rvalue(gz, scope, rl, result, node); | |
| 7155 | return rvalue(gz, rl, result, node); | |
| 7074 | 7156 | }, |
| 7075 | 7157 | .memset => { |
| 7076 | 7158 | const result = try gz.addPlNode(.memset, node, Zir.Inst.Memset{ |
| ... | ... | @@ -7078,7 +7160,7 @@ fn builtinCall( |
| 7078 | 7160 | .byte = try expr(gz, scope, .{ .ty = .u8_type }, params[1]), |
| 7079 | 7161 | .byte_count = try expr(gz, scope, .{ .ty = .usize_type }, params[2]), |
| 7080 | 7162 | }); |
| 7081 | return rvalue(gz, scope, rl, result, node); | |
| 7163 | return rvalue(gz, rl, result, node); | |
| 7082 | 7164 | }, |
| 7083 | 7165 | .shuffle => { |
| 7084 | 7166 | const result = try gz.addPlNode(.shuffle, node, Zir.Inst.Shuffle{ |
| ... | ... | @@ -7087,7 +7169,7 @@ fn builtinCall( |
| 7087 | 7169 | .b = try expr(gz, scope, .none, params[2]), |
| 7088 | 7170 | .mask = try comptimeExpr(gz, scope, .none, params[3]), |
| 7089 | 7171 | }); |
| 7090 | return rvalue(gz, scope, rl, result, node); | |
| 7172 | return rvalue(gz, rl, result, node); | |
| 7091 | 7173 | }, |
| 7092 | 7174 | .async_call => { |
| 7093 | 7175 | const result = try gz.addPlNode(.builtin_async_call, node, Zir.Inst.AsyncCall{ |
| ... | ... | @@ -7096,14 +7178,14 @@ fn builtinCall( |
| 7096 | 7178 | .fn_ptr = try expr(gz, scope, .none, params[2]), |
| 7097 | 7179 | .args = try expr(gz, scope, .none, params[3]), |
| 7098 | 7180 | }); |
| 7099 | return rvalue(gz, scope, rl, result, node); | |
| 7181 | return rvalue(gz, rl, result, node); | |
| 7100 | 7182 | }, |
| 7101 | 7183 | .Vector => { |
| 7102 | 7184 | const result = try gz.addPlNode(.vector_type, node, Zir.Inst.Bin{ |
| 7103 | 7185 | .lhs = try comptimeExpr(gz, scope, .{.ty = .u32_type}, params[0]), |
| 7104 | 7186 | .rhs = try typeExpr(gz, scope, params[1]), |
| 7105 | 7187 | }); |
| 7106 | return rvalue(gz, scope, rl, result, node); | |
| 7188 | return rvalue(gz, rl, result, node); | |
| 7107 | 7189 | }, |
| 7108 | 7190 | |
| 7109 | 7191 | } |
| ... | ... | @@ -7112,13 +7194,12 @@ fn builtinCall( |
| 7112 | 7194 | |
| 7113 | 7195 | fn simpleNoOpVoid( |
| 7114 | 7196 | gz: *GenZir, |
| 7115 | scope: *Scope, | |
| 7116 | 7197 | rl: ResultLoc, |
| 7117 | 7198 | node: ast.Node.Index, |
| 7118 | 7199 | tag: Zir.Inst.Tag, |
| 7119 | 7200 | ) InnerError!Zir.Inst.Ref { |
| 7120 | 7201 | _ = try gz.addNode(tag, node); |
| 7121 | return rvalue(gz, scope, rl, .void_value, node); | |
| 7202 | return rvalue(gz, rl, .void_value, node); | |
| 7122 | 7203 | } |
| 7123 | 7204 | |
| 7124 | 7205 | fn hasDeclOrField( |
| ... | ... | @@ -7136,7 +7217,7 @@ fn hasDeclOrField( |
| 7136 | 7217 | .lhs = container_type, |
| 7137 | 7218 | .rhs = name, |
| 7138 | 7219 | }); |
| 7139 | return rvalue(gz, scope, rl, result, node); | |
| 7220 | return rvalue(gz, rl, result, node); | |
| 7140 | 7221 | } |
| 7141 | 7222 | |
| 7142 | 7223 | fn typeCast( |
| ... | ... | @@ -7152,7 +7233,7 @@ fn typeCast( |
| 7152 | 7233 | .lhs = try typeExpr(gz, scope, lhs_node), |
| 7153 | 7234 | .rhs = try expr(gz, scope, .none, rhs_node), |
| 7154 | 7235 | }); |
| 7155 | return rvalue(gz, scope, rl, result, node); | |
| 7236 | return rvalue(gz, rl, result, node); | |
| 7156 | 7237 | } |
| 7157 | 7238 | |
| 7158 | 7239 | fn simpleUnOpType( |
| ... | ... | @@ -7165,7 +7246,7 @@ fn simpleUnOpType( |
| 7165 | 7246 | ) InnerError!Zir.Inst.Ref { |
| 7166 | 7247 | const operand = try typeExpr(gz, scope, operand_node); |
| 7167 | 7248 | const result = try gz.addUnNode(tag, operand, node); |
| 7168 | return rvalue(gz, scope, rl, result, node); | |
| 7249 | return rvalue(gz, rl, result, node); | |
| 7169 | 7250 | } |
| 7170 | 7251 | |
| 7171 | 7252 | fn simpleUnOp( |
| ... | ... | @@ -7179,7 +7260,7 @@ fn simpleUnOp( |
| 7179 | 7260 | ) InnerError!Zir.Inst.Ref { |
| 7180 | 7261 | const operand = try expr(gz, scope, operand_rl, operand_node); |
| 7181 | 7262 | const result = try gz.addUnNode(tag, operand, node); |
| 7182 | return rvalue(gz, scope, rl, result, node); | |
| 7263 | return rvalue(gz, rl, result, node); | |
| 7183 | 7264 | } |
| 7184 | 7265 | |
| 7185 | 7266 | fn cmpxchg( |
| ... | ... | @@ -7209,7 +7290,7 @@ fn cmpxchg( |
| 7209 | 7290 | .fail_order = try expr(gz, scope, .{ .ty = .atomic_ordering_type }, params[5]), |
| 7210 | 7291 | // zig fmt: on |
| 7211 | 7292 | }); |
| 7212 | return rvalue(gz, scope, rl, result, node); | |
| 7293 | return rvalue(gz, rl, result, node); | |
| 7213 | 7294 | } |
| 7214 | 7295 | |
| 7215 | 7296 | fn bitBuiltin( |
| ... | ... | @@ -7224,7 +7305,7 @@ fn bitBuiltin( |
| 7224 | 7305 | const int_type = try typeExpr(gz, scope, int_type_node); |
| 7225 | 7306 | const operand = try expr(gz, scope, .{ .ty = int_type }, operand_node); |
| 7226 | 7307 | const result = try gz.addUnNode(tag, operand, node); |
| 7227 | return rvalue(gz, scope, rl, result, node); | |
| 7308 | return rvalue(gz, rl, result, node); | |
| 7228 | 7309 | } |
| 7229 | 7310 | |
| 7230 | 7311 | fn divBuiltin( |
| ... | ... | @@ -7240,7 +7321,7 @@ fn divBuiltin( |
| 7240 | 7321 | .lhs = try expr(gz, scope, .none, lhs_node), |
| 7241 | 7322 | .rhs = try expr(gz, scope, .none, rhs_node), |
| 7242 | 7323 | }); |
| 7243 | return rvalue(gz, scope, rl, result, node); | |
| 7324 | return rvalue(gz, rl, result, node); | |
| 7244 | 7325 | } |
| 7245 | 7326 | |
| 7246 | 7327 | fn simpleCBuiltin( |
| ... | ... | @@ -7256,7 +7337,7 @@ fn simpleCBuiltin( |
| 7256 | 7337 | .node = gz.nodeIndexToRelative(node), |
| 7257 | 7338 | .operand = operand, |
| 7258 | 7339 | }); |
| 7259 | return rvalue(gz, scope, rl, .void_value, node); | |
| 7340 | return rvalue(gz, rl, .void_value, node); | |
| 7260 | 7341 | } |
| 7261 | 7342 | |
| 7262 | 7343 | fn offsetOf( |
| ... | ... | @@ -7274,7 +7355,7 @@ fn offsetOf( |
| 7274 | 7355 | .lhs = type_inst, |
| 7275 | 7356 | .rhs = field_name, |
| 7276 | 7357 | }); |
| 7277 | return rvalue(gz, scope, rl, result, node); | |
| 7358 | return rvalue(gz, rl, result, node); | |
| 7278 | 7359 | } |
| 7279 | 7360 | |
| 7280 | 7361 | fn shiftOp( |
| ... | ... | @@ -7293,7 +7374,7 @@ fn shiftOp( |
| 7293 | 7374 | .lhs = lhs, |
| 7294 | 7375 | .rhs = rhs, |
| 7295 | 7376 | }); |
| 7296 | return rvalue(gz, scope, rl, result, node); | |
| 7377 | return rvalue(gz, rl, result, node); | |
| 7297 | 7378 | } |
| 7298 | 7379 | |
| 7299 | 7380 | fn cImport( |
| ... | ... | @@ -7318,7 +7399,7 @@ fn cImport( |
| 7318 | 7399 | try block_scope.setBlockBody(block_inst); |
| 7319 | 7400 | try gz.instructions.append(gpa, block_inst); |
| 7320 | 7401 | |
| 7321 | return rvalue(gz, scope, rl, .void_value, node); | |
| 7402 | return rvalue(gz, rl, .void_value, node); | |
| 7322 | 7403 | } |
| 7323 | 7404 | |
| 7324 | 7405 | fn overflowArithmetic( |
| ... | ... | @@ -7348,7 +7429,7 @@ fn overflowArithmetic( |
| 7348 | 7429 | .rhs = rhs, |
| 7349 | 7430 | .ptr = ptr, |
| 7350 | 7431 | }); |
| 7351 | return rvalue(gz, scope, rl, result, node); | |
| 7432 | return rvalue(gz, rl, result, node); | |
| 7352 | 7433 | } |
| 7353 | 7434 | |
| 7354 | 7435 | fn callExpr( |
| ... | ... | @@ -7400,7 +7481,7 @@ fn callExpr( |
| 7400 | 7481 | }; |
| 7401 | 7482 | break :res try gz.addCall(tag, lhs, args, node); |
| 7402 | 7483 | }; |
| 7403 | return rvalue(gz, scope, rl, result, node); // TODO function call with result location | |
| 7484 | return rvalue(gz, rl, result, node); // TODO function call with result location | |
| 7404 | 7485 | } |
| 7405 | 7486 | |
| 7406 | 7487 | pub const simple_types = std.ComptimeStringMap(Zir.Inst.Ref, .{ |
| ... | ... | @@ -7876,7 +7957,6 @@ fn nodeMayEvalToError(tree: *const ast.Tree, start_node: ast.Node.Index) enum { |
| 7876 | 7957 | /// If the `ResultLoc` is `ty`, it will coerce the result to the type. |
| 7877 | 7958 | fn rvalue( |
| 7878 | 7959 | gz: *GenZir, |
| 7879 | scope: *Scope, | |
| 7880 | 7960 | rl: ResultLoc, |
| 7881 | 7961 | result: Zir.Inst.Ref, |
| 7882 | 7962 | src_node: ast.Node.Index, |
| ... | ... | @@ -8024,7 +8104,6 @@ fn parseStrLit( |
| 8024 | 8104 | bytes: []const u8, |
| 8025 | 8105 | offset: u32, |
| 8026 | 8106 | ) InnerError!void { |
| 8027 | const tree = astgen.tree; | |
| 8028 | 8107 | const raw_string = bytes[offset..]; |
| 8029 | 8108 | var buf_managed = buf.toManaged(astgen.gpa); |
| 8030 | 8109 | const result = std.zig.string_literal.parseAppend(&buf_managed, raw_string); |
| ... | ... | @@ -8327,6 +8406,15 @@ const Scope = struct { |
| 8327 | 8406 | top, |
| 8328 | 8407 | }; |
| 8329 | 8408 | |
| 8409 | // either .used or the type of the var/constant | |
| 8410 | const Used = enum { | |
| 8411 | fn_param, | |
| 8412 | constant, | |
| 8413 | variable, | |
| 8414 | loop_index, | |
| 8415 | capture, | |
| 8416 | used, | |
| 8417 | }; | |
| 8330 | 8418 | /// This is always a `const` local and importantly the `inst` is a value type, not a pointer. |
| 8331 | 8419 | /// This structure lives as long as the AST generation of the Block |
| 8332 | 8420 | /// node that contains the variable. |
| ... | ... | @@ -8341,6 +8429,8 @@ const Scope = struct { |
| 8341 | 8429 | token_src: ast.TokenIndex, |
| 8342 | 8430 | /// String table index. |
| 8343 | 8431 | name: u32, |
| 8432 | /// has this variable been referenced? | |
| 8433 | used: Used, | |
| 8344 | 8434 | }; |
| 8345 | 8435 | |
| 8346 | 8436 | /// This could be a `const` or `var` local. It has a pointer instead of a value. |
| ... | ... | @@ -8357,7 +8447,10 @@ const Scope = struct { |
| 8357 | 8447 | token_src: ast.TokenIndex, |
| 8358 | 8448 | /// String table index. |
| 8359 | 8449 | name: u32, |
| 8360 | is_comptime: bool, | |
| 8450 | /// true means we find out during Sema whether the value is comptime. false means it is already known at AstGen the value is runtime-known. | |
| 8451 | maybe_comptime: bool, | |
| 8452 | /// has this variable been referenced? | |
| 8453 | used: Used, | |
| 8361 | 8454 | }; |
| 8362 | 8455 | |
| 8363 | 8456 | const Defer = struct { |
| ... | ... | @@ -8467,7 +8560,6 @@ const GenZir = struct { |
| 8467 | 8560 | fn calcLine(gz: GenZir, node: ast.Node.Index) u32 { |
| 8468 | 8561 | const astgen = gz.astgen; |
| 8469 | 8562 | const tree = astgen.tree; |
| 8470 | const node_tags = tree.nodes.items(.tag); | |
| 8471 | 8563 | const token_starts = tree.tokens.items(.start); |
| 8472 | 8564 | const decl_start = token_starts[tree.firstToken(gz.decl_node_index)]; |
| 8473 | 8565 | const node_start = token_starts[tree.firstToken(node)]; |
src/Compilation.zig+8-4| ... | ... | @@ -325,7 +325,6 @@ pub const AllErrors = struct { |
| 325 | 325 | }, |
| 326 | 326 | |
| 327 | 327 | pub fn renderToStdErr(msg: Message, ttyconf: std.debug.TTY.Config) void { |
| 328 | const stderr_mutex = std.debug.getStderrMutex(); | |
| 329 | 328 | const held = std.debug.getStderrMutex().acquire(); |
| 330 | 329 | defer held.release(); |
| 331 | 330 | const stderr = std.io.getStdErr(); |
| ... | ... | @@ -524,6 +523,7 @@ pub const AllErrors = struct { |
| 524 | 523 | errors: *std.ArrayList(Message), |
| 525 | 524 | msg: []const u8, |
| 526 | 525 | ) !void { |
| 526 | _ = arena; | |
| 527 | 527 | try errors.append(.{ .plain = .{ .msg = msg } }); |
| 528 | 528 | } |
| 529 | 529 | |
| ... | ... | @@ -1639,7 +1639,7 @@ pub fn update(self: *Compilation) !void { |
| 1639 | 1639 | // Make sure std.zig is inside the import_table. We unconditionally need |
| 1640 | 1640 | // it for start.zig. |
| 1641 | 1641 | const std_pkg = module.root_pkg.table.get("std").?; |
| 1642 | _ = try module.importPkg(module.root_pkg, std_pkg); | |
| 1642 | _ = try module.importPkg(std_pkg); | |
| 1643 | 1643 | |
| 1644 | 1644 | // Put a work item in for every known source file to detect if |
| 1645 | 1645 | // it changed, and, if so, re-compute ZIR and then queue the job |
| ... | ... | @@ -2283,8 +2283,12 @@ fn workerAstGenFile( |
| 2283 | 2283 | ) void { |
| 2284 | 2284 | defer wg.finish(); |
| 2285 | 2285 | |
| 2286 | var child_prog_node = prog_node.start(file.sub_file_path, 0); | |
| 2287 | child_prog_node.activate(); | |
| 2288 | defer child_prog_node.end(); | |
| 2289 | ||
| 2286 | 2290 | const mod = comp.bin_file.options.module.?; |
| 2287 | mod.astGenFile(file, prog_node) catch |err| switch (err) { | |
| 2291 | mod.astGenFile(file) catch |err| switch (err) { | |
| 2288 | 2292 | error.AnalysisFail => return, |
| 2289 | 2293 | else => { |
| 2290 | 2294 | file.status = .retryable_failure; |
| ... | ... | @@ -2373,7 +2377,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult { |
| 2373 | 2377 | // We need to "unhit" in this case, to keep the digests matching. |
| 2374 | 2378 | const prev_hash_state = man.hash.peekBin(); |
| 2375 | 2379 | const actual_hit = hit: { |
| 2376 | const is_hit = try man.hit(); | |
| 2380 | _ = try man.hit(); | |
| 2377 | 2381 | if (man.files.items.len == 0) { |
| 2378 | 2382 | man.unhit(prev_hash_state, 0); |
| 2379 | 2383 | break :hit false; |
src/DepTokenizer.zig+2-3| ... | ... | @@ -944,7 +944,7 @@ fn printLabel(out: anytype, label: []const u8, bytes: []const u8) !void { |
| 944 | 944 | try out.writeAll(text); |
| 945 | 945 | var i: usize = text.len; |
| 946 | 946 | const end = 79; |
| 947 | while (i < 79) : (i += 1) { | |
| 947 | while (i < end) : (i += 1) { | |
| 948 | 948 | try out.writeAll(&[_]u8{label[0]}); |
| 949 | 949 | } |
| 950 | 950 | try out.writeAll("\n"); |
| ... | ... | @@ -953,7 +953,7 @@ fn printLabel(out: anytype, label: []const u8, bytes: []const u8) !void { |
| 953 | 953 | fn printRuler(out: anytype) !void { |
| 954 | 954 | var i: usize = 0; |
| 955 | 955 | const end = 79; |
| 956 | while (i < 79) : (i += 1) { | |
| 956 | while (i < end) : (i += 1) { | |
| 957 | 957 | try out.writeAll("-"); |
| 958 | 958 | } |
| 959 | 959 | try out.writeAll("\n"); |
| ... | ... | @@ -1057,4 +1057,3 @@ const printable_char_tab: [256]u8 = ( |
| 1057 | 1057 | "................................................................" ++ |
| 1058 | 1058 | "................................................................" |
| 1059 | 1059 | ).*; |
| 1060 |
src/Module.zig+24-25| ... | ... | @@ -774,7 +774,10 @@ pub const Fn = struct { |
| 774 | 774 | ir.dumpFn(mod, func); |
| 775 | 775 | } |
| 776 | 776 | |
| 777 | pub fn deinit(func: *Fn, gpa: *Allocator) void {} | |
| 777 | pub fn deinit(func: *Fn, gpa: *Allocator) void { | |
| 778 | _ = func; | |
| 779 | _ = gpa; | |
| 780 | } | |
| 778 | 781 | }; |
| 779 | 782 | |
| 780 | 783 | pub const Var = struct { |
| ... | ... | @@ -1561,7 +1564,6 @@ pub const SrcLoc = struct { |
| 1561 | 1564 | .node_offset_array_access_index => |node_off| { |
| 1562 | 1565 | const tree = try src_loc.file_scope.getTree(gpa); |
| 1563 | 1566 | const node_datas = tree.nodes.items(.data); |
| 1564 | const node_tags = tree.nodes.items(.tag); | |
| 1565 | 1567 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 1566 | 1568 | const main_tokens = tree.nodes.items(.main_token); |
| 1567 | 1569 | const tok_index = main_tokens[node_datas[node].rhs]; |
| ... | ... | @@ -1570,7 +1572,6 @@ pub const SrcLoc = struct { |
| 1570 | 1572 | }, |
| 1571 | 1573 | .node_offset_slice_sentinel => |node_off| { |
| 1572 | 1574 | const tree = try src_loc.file_scope.getTree(gpa); |
| 1573 | const node_datas = tree.nodes.items(.data); | |
| 1574 | 1575 | const node_tags = tree.nodes.items(.tag); |
| 1575 | 1576 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 1576 | 1577 | const full = switch (node_tags[node]) { |
| ... | ... | @@ -1586,7 +1587,6 @@ pub const SrcLoc = struct { |
| 1586 | 1587 | }, |
| 1587 | 1588 | .node_offset_call_func => |node_off| { |
| 1588 | 1589 | const tree = try src_loc.file_scope.getTree(gpa); |
| 1589 | const node_datas = tree.nodes.items(.data); | |
| 1590 | 1590 | const node_tags = tree.nodes.items(.tag); |
| 1591 | 1591 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 1592 | 1592 | var params: [1]ast.Node.Index = undefined; |
| ... | ... | @@ -1625,7 +1625,6 @@ pub const SrcLoc = struct { |
| 1625 | 1625 | .node_offset_deref_ptr => |node_off| { |
| 1626 | 1626 | const tree = try src_loc.file_scope.getTree(gpa); |
| 1627 | 1627 | const node_datas = tree.nodes.items(.data); |
| 1628 | const node_tags = tree.nodes.items(.tag); | |
| 1629 | 1628 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 1630 | 1629 | const tok_index = node_datas[node].lhs; |
| 1631 | 1630 | const token_starts = tree.tokens.items(.start); |
| ... | ... | @@ -1633,7 +1632,6 @@ pub const SrcLoc = struct { |
| 1633 | 1632 | }, |
| 1634 | 1633 | .node_offset_asm_source => |node_off| { |
| 1635 | 1634 | const tree = try src_loc.file_scope.getTree(gpa); |
| 1636 | const node_datas = tree.nodes.items(.data); | |
| 1637 | 1635 | const node_tags = tree.nodes.items(.tag); |
| 1638 | 1636 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 1639 | 1637 | const full = switch (node_tags[node]) { |
| ... | ... | @@ -1648,7 +1646,6 @@ pub const SrcLoc = struct { |
| 1648 | 1646 | }, |
| 1649 | 1647 | .node_offset_asm_ret_ty => |node_off| { |
| 1650 | 1648 | const tree = try src_loc.file_scope.getTree(gpa); |
| 1651 | const node_datas = tree.nodes.items(.data); | |
| 1652 | 1649 | const node_tags = tree.nodes.items(.tag); |
| 1653 | 1650 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 1654 | 1651 | const full = switch (node_tags[node]) { |
| ... | ... | @@ -1771,7 +1768,6 @@ pub const SrcLoc = struct { |
| 1771 | 1768 | |
| 1772 | 1769 | .node_offset_fn_type_cc => |node_off| { |
| 1773 | 1770 | const tree = try src_loc.file_scope.getTree(gpa); |
| 1774 | const node_datas = tree.nodes.items(.data); | |
| 1775 | 1771 | const node_tags = tree.nodes.items(.tag); |
| 1776 | 1772 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 1777 | 1773 | var params: [1]ast.Node.Index = undefined; |
| ... | ... | @@ -1790,7 +1786,6 @@ pub const SrcLoc = struct { |
| 1790 | 1786 | |
| 1791 | 1787 | .node_offset_fn_type_ret_ty => |node_off| { |
| 1792 | 1788 | const tree = try src_loc.file_scope.getTree(gpa); |
| 1793 | const node_datas = tree.nodes.items(.data); | |
| 1794 | 1789 | const node_tags = tree.nodes.items(.tag); |
| 1795 | 1790 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 1796 | 1791 | var params: [1]ast.Node.Index = undefined; |
| ... | ... | @@ -1810,7 +1805,6 @@ pub const SrcLoc = struct { |
| 1810 | 1805 | .node_offset_anyframe_type => |node_off| { |
| 1811 | 1806 | const tree = try src_loc.file_scope.getTree(gpa); |
| 1812 | 1807 | const node_datas = tree.nodes.items(.data); |
| 1813 | const node_tags = tree.nodes.items(.tag); | |
| 1814 | 1808 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); |
| 1815 | 1809 | const node = node_datas[parent_node].rhs; |
| 1816 | 1810 | const main_tokens = tree.nodes.items(.main_token); |
| ... | ... | @@ -2217,7 +2211,7 @@ comptime { |
| 2217 | 2211 | } |
| 2218 | 2212 | } |
| 2219 | 2213 | |
| 2220 | pub fn astGenFile(mod: *Module, file: *Scope.File, prog_node: *std.Progress.Node) !void { | |
| 2214 | pub fn astGenFile(mod: *Module, file: *Scope.File) !void { | |
| 2221 | 2215 | const tracy = trace(@src()); |
| 2222 | 2216 | defer tracy.end(); |
| 2223 | 2217 | |
| ... | ... | @@ -2502,7 +2496,6 @@ pub fn astGenFile(mod: *Module, file: *Scope.File, prog_node: *std.Progress.Node |
| 2502 | 2496 | @ptrCast([*]const u8, file.zir.instructions.items(.data).ptr); |
| 2503 | 2497 | if (data_has_safety_tag) { |
| 2504 | 2498 | // 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 | 2499 | for (file.zir.instructions.items(.data)) |*data, i| { |
| 2507 | 2500 | const as_struct = @ptrCast(*const Stage1DataLayout, data); |
| 2508 | 2501 | safety_buffer[i] = as_struct.data; |
| ... | ... | @@ -2838,7 +2831,7 @@ pub fn ensureDeclAnalyzed(mod: *Module, decl: *Decl) InnerError!void { |
| 2838 | 2831 | } |
| 2839 | 2832 | |
| 2840 | 2833 | pub fn semaPkg(mod: *Module, pkg: *Package) !void { |
| 2841 | const file = (try mod.importPkg(mod.root_pkg, pkg)).file; | |
| 2834 | const file = (try mod.importPkg(pkg)).file; | |
| 2842 | 2835 | return mod.semaFile(file); |
| 2843 | 2836 | } |
| 2844 | 2837 | |
| ... | ... | @@ -3137,7 +3130,7 @@ pub const ImportFileResult = struct { |
| 3137 | 3130 | is_new: bool, |
| 3138 | 3131 | }; |
| 3139 | 3132 | |
| 3140 | pub fn importPkg(mod: *Module, cur_pkg: *Package, pkg: *Package) !ImportFileResult { | |
| 3133 | pub fn importPkg(mod: *Module, pkg: *Package) !ImportFileResult { | |
| 3141 | 3134 | const gpa = mod.gpa; |
| 3142 | 3135 | |
| 3143 | 3136 | // The resolved path is used as the key in the import table, to detect if |
| ... | ... | @@ -3190,7 +3183,7 @@ pub fn importFile( |
| 3190 | 3183 | import_string: []const u8, |
| 3191 | 3184 | ) !ImportFileResult { |
| 3192 | 3185 | if (cur_file.pkg.table.get(import_string)) |pkg| { |
| 3193 | return mod.importPkg(cur_file.pkg, pkg); | |
| 3186 | return mod.importPkg(pkg); | |
| 3194 | 3187 | } |
| 3195 | 3188 | const gpa = mod.gpa; |
| 3196 | 3189 | |
| ... | ... | @@ -3386,7 +3379,6 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) InnerError!vo |
| 3386 | 3379 | log.debug("scan existing {*} ({s}) of {*}", .{ decl, decl.name, namespace }); |
| 3387 | 3380 | // Update the AST node of the decl; even if its contents are unchanged, it may |
| 3388 | 3381 | // have been re-ordered. |
| 3389 | const prev_src_node = decl.src_node; | |
| 3390 | 3382 | decl.src_node = decl_node; |
| 3391 | 3383 | decl.src_line = line; |
| 3392 | 3384 | |
| ... | ... | @@ -3395,7 +3387,7 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) InnerError!vo |
| 3395 | 3387 | decl.has_align = has_align; |
| 3396 | 3388 | decl.has_linksection = has_linksection; |
| 3397 | 3389 | decl.zir_decl_index = @intCast(u32, decl_sub_index); |
| 3398 | if (decl.getFunction()) |func| { | |
| 3390 | if (decl.getFunction()) |_| { | |
| 3399 | 3391 | switch (mod.comp.bin_file.tag) { |
| 3400 | 3392 | .coff => { |
| 3401 | 3393 | // TODO Implement for COFF |
| ... | ... | @@ -3764,6 +3756,7 @@ pub fn analyzeExport( |
| 3764 | 3756 | errdefer de_gop.value_ptr.* = mod.gpa.shrink(de_gop.value_ptr.*, de_gop.value_ptr.len - 1); |
| 3765 | 3757 | } |
| 3766 | 3758 | pub fn constInst(mod: *Module, arena: *Allocator, src: LazySrcLoc, typed_value: TypedValue) !*ir.Inst { |
| 3759 | _ = mod; | |
| 3767 | 3760 | const const_inst = try arena.create(ir.Inst.Constant); |
| 3768 | 3761 | const_inst.* = .{ |
| 3769 | 3762 | .base = .{ |
| ... | ... | @@ -4132,6 +4125,7 @@ pub fn floatAdd( |
| 4132 | 4125 | lhs: Value, |
| 4133 | 4126 | rhs: Value, |
| 4134 | 4127 | ) !Value { |
| 4128 | _ = src; | |
| 4135 | 4129 | switch (float_type.tag()) { |
| 4136 | 4130 | .f16 => { |
| 4137 | 4131 | @panic("TODO add __trunctfhf2 to compiler-rt"); |
| ... | ... | @@ -4165,6 +4159,7 @@ pub fn floatSub( |
| 4165 | 4159 | lhs: Value, |
| 4166 | 4160 | rhs: Value, |
| 4167 | 4161 | ) !Value { |
| 4162 | _ = src; | |
| 4168 | 4163 | switch (float_type.tag()) { |
| 4169 | 4164 | .f16 => { |
| 4170 | 4165 | @panic("TODO add __trunctfhf2 to compiler-rt"); |
| ... | ... | @@ -4198,6 +4193,7 @@ pub fn floatDiv( |
| 4198 | 4193 | lhs: Value, |
| 4199 | 4194 | rhs: Value, |
| 4200 | 4195 | ) !Value { |
| 4196 | _ = src; | |
| 4201 | 4197 | switch (float_type.tag()) { |
| 4202 | 4198 | .f16 => { |
| 4203 | 4199 | @panic("TODO add __trunctfhf2 to compiler-rt"); |
| ... | ... | @@ -4231,6 +4227,7 @@ pub fn floatMul( |
| 4231 | 4227 | lhs: Value, |
| 4232 | 4228 | rhs: Value, |
| 4233 | 4229 | ) !Value { |
| 4230 | _ = src; | |
| 4234 | 4231 | switch (float_type.tag()) { |
| 4235 | 4232 | .f16 => { |
| 4236 | 4233 | @panic("TODO add __trunctfhf2 to compiler-rt"); |
| ... | ... | @@ -4264,6 +4261,7 @@ pub fn simplePtrType( |
| 4264 | 4261 | mutable: bool, |
| 4265 | 4262 | size: std.builtin.TypeInfo.Pointer.Size, |
| 4266 | 4263 | ) Allocator.Error!Type { |
| 4264 | _ = mod; | |
| 4267 | 4265 | if (!mutable and size == .Slice and elem_ty.eql(Type.initTag(.u8))) { |
| 4268 | 4266 | return Type.initTag(.const_slice_u8); |
| 4269 | 4267 | } |
| ... | ... | @@ -4298,6 +4296,7 @@ pub fn ptrType( |
| 4298 | 4296 | @"volatile": bool, |
| 4299 | 4297 | size: std.builtin.TypeInfo.Pointer.Size, |
| 4300 | 4298 | ) Allocator.Error!Type { |
| 4299 | _ = mod; | |
| 4301 | 4300 | assert(host_size == 0 or bit_offset < host_size * 8); |
| 4302 | 4301 | |
| 4303 | 4302 | // TODO check if type can be represented by simplePtrType |
| ... | ... | @@ -4315,6 +4314,7 @@ pub fn ptrType( |
| 4315 | 4314 | } |
| 4316 | 4315 | |
| 4317 | 4316 | pub fn optionalType(mod: *Module, arena: *Allocator, child_type: Type) Allocator.Error!Type { |
| 4317 | _ = mod; | |
| 4318 | 4318 | switch (child_type.tag()) { |
| 4319 | 4319 | .single_const_pointer => return Type.Tag.optional_single_const_pointer.create( |
| 4320 | 4320 | arena, |
| ... | ... | @@ -4335,6 +4335,7 @@ pub fn arrayType( |
| 4335 | 4335 | sentinel: ?Value, |
| 4336 | 4336 | elem_type: Type, |
| 4337 | 4337 | ) Allocator.Error!Type { |
| 4338 | _ = mod; | |
| 4338 | 4339 | if (elem_type.eql(Type.initTag(.u8))) { |
| 4339 | 4340 | if (sentinel) |some| { |
| 4340 | 4341 | if (some.eql(Value.initTag(.zero))) { |
| ... | ... | @@ -4365,6 +4366,7 @@ pub fn errorUnionType( |
| 4365 | 4366 | error_set: Type, |
| 4366 | 4367 | payload: Type, |
| 4367 | 4368 | ) Allocator.Error!Type { |
| 4369 | _ = mod; | |
| 4368 | 4370 | assert(error_set.zigTypeTag() == .ErrorSet); |
| 4369 | 4371 | if (error_set.eql(Type.initTag(.anyerror)) and payload.eql(Type.initTag(.void))) { |
| 4370 | 4372 | return Type.initTag(.anyerror_void_error_union); |
| ... | ... | @@ -4692,11 +4694,9 @@ pub fn analyzeUnionFields(mod: *Module, union_obj: *Union) InnerError!void { |
| 4692 | 4694 | const src: LazySrcLoc = .{ .node_offset = union_obj.node_offset }; |
| 4693 | 4695 | extra_index += @boolToInt(small.has_src_node); |
| 4694 | 4696 | |
| 4695 | const tag_type_ref = if (small.has_tag_type) blk: { | |
| 4696 | const tag_type_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]); | |
| 4697 | if (small.has_tag_type) { | |
| 4697 | 4698 | extra_index += 1; |
| 4698 | break :blk tag_type_ref; | |
| 4699 | } else .none; | |
| 4699 | } | |
| 4700 | 4700 | |
| 4701 | 4701 | const body_len = if (small.has_body_len) blk: { |
| 4702 | 4702 | const body_len = zir.extra[extra_index]; |
| ... | ... | @@ -4784,6 +4784,7 @@ pub fn analyzeUnionFields(mod: *Module, union_obj: *Union) InnerError!void { |
| 4784 | 4784 | cur_bit_bag >>= 1; |
| 4785 | 4785 | const unused = @truncate(u1, cur_bit_bag) != 0; |
| 4786 | 4786 | cur_bit_bag >>= 1; |
| 4787 | _ = unused; | |
| 4787 | 4788 | |
| 4788 | 4789 | const field_name_zir = zir.nullTerminatedString(zir.extra[extra_index]); |
| 4789 | 4790 | extra_index += 1; |
| ... | ... | @@ -4800,11 +4801,9 @@ pub fn analyzeUnionFields(mod: *Module, union_obj: *Union) InnerError!void { |
| 4800 | 4801 | break :blk align_ref; |
| 4801 | 4802 | } else .none; |
| 4802 | 4803 | |
| 4803 | const tag_ref: Zir.Inst.Ref = if (has_tag) blk: { | |
| 4804 | const tag_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]); | |
| 4804 | if (has_tag) { | |
| 4805 | 4805 | extra_index += 1; |
| 4806 | break :blk tag_ref; | |
| 4807 | } else .none; | |
| 4806 | } | |
| 4808 | 4807 | |
| 4809 | 4808 | // This string needs to outlive the ZIR code. |
| 4810 | 4809 | const field_name = try decl_arena.allocator.dupe(u8, field_name_zir); |
src/Sema.zig+64-22| ... | ... | @@ -702,6 +702,7 @@ fn zirBitcastResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) I |
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 705 | _ = inst; | |
| 705 | 706 | const tracy = trace(@src()); |
| 706 | 707 | defer tracy.end(); |
| 707 | 708 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirCoerceResultPtr", .{}); |
| ... | ... | @@ -776,6 +777,7 @@ fn zirStructDecl( |
| 776 | 777 | } |
| 777 | 778 | |
| 778 | 779 | fn createTypeName(sema: *Sema, block: *Scope.Block, name_strategy: Zir.Inst.NameStrategy) ![:0]u8 { |
| 780 | _ = block; | |
| 779 | 781 | switch (name_strategy) { |
| 780 | 782 | .anon => { |
| 781 | 783 | // It would be neat to have "struct:line:column" but this name has |
| ... | ... | @@ -1074,6 +1076,10 @@ fn zirOpaqueDecl( |
| 1074 | 1076 | const src = inst_data.src(); |
| 1075 | 1077 | const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index); |
| 1076 | 1078 | |
| 1079 | _ = name_strategy; | |
| 1080 | _ = inst_data; | |
| 1081 | _ = src; | |
| 1082 | _ = extra; | |
| 1077 | 1083 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirOpaqueDecl", .{}); |
| 1078 | 1084 | } |
| 1079 | 1085 | |
| ... | ... | @@ -1230,14 +1236,13 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In |
| 1230 | 1236 | |
| 1231 | 1237 | fn zirArg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1232 | 1238 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; |
| 1233 | const src = inst_data.src(); | |
| 1234 | 1239 | const arg_name = inst_data.get(sema.code); |
| 1235 | 1240 | const arg_index = sema.next_arg_index; |
| 1236 | 1241 | sema.next_arg_index += 1; |
| 1237 | 1242 | |
| 1238 | 1243 | // TODO check if arg_name shadows a Decl |
| 1239 | 1244 | |
| 1240 | if (block.inlining) |inlining| { | |
| 1245 | if (block.inlining) |_| { | |
| 1241 | 1246 | return sema.param_inst_list[arg_index]; |
| 1242 | 1247 | } |
| 1243 | 1248 | |
| ... | ... | @@ -1636,6 +1641,7 @@ fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In |
| 1636 | 1641 | } |
| 1637 | 1642 | |
| 1638 | 1643 | fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1644 | _ = block; | |
| 1639 | 1645 | const tracy = trace(@src()); |
| 1640 | 1646 | defer tracy.end(); |
| 1641 | 1647 | |
| ... | ... | @@ -1644,6 +1650,7 @@ fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In |
| 1644 | 1650 | } |
| 1645 | 1651 | |
| 1646 | 1652 | fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1653 | _ = block; | |
| 1647 | 1654 | const tracy = trace(@src()); |
| 1648 | 1655 | defer tracy.end(); |
| 1649 | 1656 | |
| ... | ... | @@ -1661,6 +1668,7 @@ fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! |
| 1661 | 1668 | } |
| 1662 | 1669 | |
| 1663 | 1670 | fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1671 | _ = block; | |
| 1664 | 1672 | const arena = sema.arena; |
| 1665 | 1673 | const inst_data = sema.code.instructions.items(.data)[inst].float; |
| 1666 | 1674 | const src = inst_data.src(); |
| ... | ... | @@ -1673,6 +1681,7 @@ fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!* |
| 1673 | 1681 | } |
| 1674 | 1682 | |
| 1675 | 1683 | fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1684 | _ = block; | |
| 1676 | 1685 | const arena = sema.arena; |
| 1677 | 1686 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1678 | 1687 | const extra = sema.code.extraData(Zir.Inst.Float128, inst_data.payload_index).data; |
| ... | ... | @@ -2354,6 +2363,7 @@ fn analyzeCall( |
| 2354 | 2363 | } |
| 2355 | 2364 | |
| 2356 | 2365 | fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2366 | _ = block; | |
| 2357 | 2367 | const tracy = trace(@src()); |
| 2358 | 2368 | defer tracy.end(); |
| 2359 | 2369 | |
| ... | ... | @@ -2462,6 +2472,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn |
| 2462 | 2472 | } |
| 2463 | 2473 | |
| 2464 | 2474 | fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2475 | _ = block; | |
| 2465 | 2476 | const tracy = trace(@src()); |
| 2466 | 2477 | defer tracy.end(); |
| 2467 | 2478 | |
| ... | ... | @@ -2622,6 +2633,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn |
| 2622 | 2633 | } |
| 2623 | 2634 | |
| 2624 | 2635 | fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2636 | _ = block; | |
| 2625 | 2637 | const tracy = trace(@src()); |
| 2626 | 2638 | defer tracy.end(); |
| 2627 | 2639 | |
| ... | ... | @@ -3005,7 +3017,6 @@ fn zirFunc( |
| 3005 | 3017 | defer tracy.end(); |
| 3006 | 3018 | |
| 3007 | 3019 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 3008 | const src = inst_data.src(); | |
| 3009 | 3020 | const extra = sema.code.extraData(Zir.Inst.Func, inst_data.payload_index); |
| 3010 | 3021 | const param_types = sema.code.refSlice(extra.end, extra.data.param_types_len); |
| 3011 | 3022 | |
| ... | ... | @@ -3061,7 +3072,9 @@ fn funcCommon( |
| 3061 | 3072 | |
| 3062 | 3073 | const fn_ty: Type = fn_ty: { |
| 3063 | 3074 | // Hot path for some common function types. |
| 3064 | if (zir_param_types.len == 0 and !var_args and align_val.tag() == .null_value) { | |
| 3075 | if (zir_param_types.len == 0 and !var_args and align_val.tag() == .null_value and | |
| 3076 | !inferred_error_set) | |
| 3077 | { | |
| 3065 | 3078 | if (return_type.zigTypeTag() == .NoReturn and cc == .Unspecified) { |
| 3066 | 3079 | break :fn_ty Type.initTag(.fn_noreturn_no_args); |
| 3067 | 3080 | } |
| ... | ... | @@ -3092,6 +3105,10 @@ fn funcCommon( |
| 3092 | 3105 | return mod.fail(&block.base, src, "TODO implement support for function prototypes to have alignment specified", .{}); |
| 3093 | 3106 | } |
| 3094 | 3107 | |
| 3108 | if (inferred_error_set) { | |
| 3109 | return mod.fail(&block.base, src, "TODO implement functions with inferred error sets", .{}); | |
| 3110 | } | |
| 3111 | ||
| 3095 | 3112 | break :fn_ty try Type.Tag.function.create(sema.arena, .{ |
| 3096 | 3113 | .param_types = param_types, |
| 3097 | 3114 | .return_type = return_type, |
| ... | ... | @@ -3332,9 +3349,7 @@ fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 3332 | 3349 | defer tracy.end(); |
| 3333 | 3350 | |
| 3334 | 3351 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 3335 | const src = inst_data.src(); | |
| 3336 | 3352 | 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 | 3353 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 3339 | 3354 | |
| 3340 | 3355 | const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs); |
| ... | ... | @@ -3499,6 +3514,8 @@ fn zirSwitchCapture( |
| 3499 | 3514 | const switch_info = zir_datas[capture_info.switch_inst].pl_node; |
| 3500 | 3515 | const src = switch_info.src(); |
| 3501 | 3516 | |
| 3517 | _ = is_ref; | |
| 3518 | _ = is_multi; | |
| 3502 | 3519 | return sema.mod.fail(&block.base, src, "TODO implement Sema for zirSwitchCapture", .{}); |
| 3503 | 3520 | } |
| 3504 | 3521 | |
| ... | ... | @@ -3516,6 +3533,7 @@ fn zirSwitchCaptureElse( |
| 3516 | 3533 | const switch_info = zir_datas[capture_info.switch_inst].pl_node; |
| 3517 | 3534 | const src = switch_info.src(); |
| 3518 | 3535 | |
| 3536 | _ = is_ref; | |
| 3519 | 3537 | return sema.mod.fail(&block.base, src, "TODO implement Sema for zirSwitchCaptureElse", .{}); |
| 3520 | 3538 | } |
| 3521 | 3539 | |
| ... | ... | @@ -3653,7 +3671,6 @@ fn analyzeSwitch( |
| 3653 | 3671 | extra_index += 1; |
| 3654 | 3672 | const body_len = sema.code.extra[extra_index]; |
| 3655 | 3673 | extra_index += 1; |
| 3656 | const body = sema.code.extra[extra_index..][0..body_len]; | |
| 3657 | 3674 | extra_index += body_len; |
| 3658 | 3675 | |
| 3659 | 3676 | try sema.validateSwitchItemEnum( |
| ... | ... | @@ -3763,7 +3780,6 @@ fn analyzeSwitch( |
| 3763 | 3780 | extra_index += 1; |
| 3764 | 3781 | const body_len = sema.code.extra[extra_index]; |
| 3765 | 3782 | extra_index += 1; |
| 3766 | const body = sema.code.extra[extra_index..][0..body_len]; | |
| 3767 | 3783 | extra_index += body_len; |
| 3768 | 3784 | |
| 3769 | 3785 | try sema.validateSwitchItem( |
| ... | ... | @@ -3859,7 +3875,6 @@ fn analyzeSwitch( |
| 3859 | 3875 | extra_index += 1; |
| 3860 | 3876 | const body_len = sema.code.extra[extra_index]; |
| 3861 | 3877 | extra_index += 1; |
| 3862 | const body = sema.code.extra[extra_index..][0..body_len]; | |
| 3863 | 3878 | extra_index += body_len; |
| 3864 | 3879 | |
| 3865 | 3880 | try sema.validateSwitchItemBool( |
| ... | ... | @@ -3942,7 +3957,6 @@ fn analyzeSwitch( |
| 3942 | 3957 | extra_index += 1; |
| 3943 | 3958 | const body_len = sema.code.extra[extra_index]; |
| 3944 | 3959 | extra_index += 1; |
| 3945 | const body = sema.code.extra[extra_index..][0..body_len]; | |
| 3946 | 3960 | extra_index += body_len; |
| 3947 | 3961 | |
| 3948 | 3962 | try sema.validateSwitchItemSparse( |
| ... | ... | @@ -4457,6 +4471,7 @@ fn validateSwitchNoRange( |
| 4457 | 4471 | fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4458 | 4472 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 4459 | 4473 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 4474 | _ = extra; | |
| 4460 | 4475 | const src = inst_data.src(); |
| 4461 | 4476 | |
| 4462 | 4477 | return sema.mod.fail(&block.base, src, "TODO implement zirHasField", .{}); |
| ... | ... | @@ -4515,12 +4530,17 @@ fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! |
| 4515 | 4530 | fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4516 | 4531 | const tracy = trace(@src()); |
| 4517 | 4532 | defer tracy.end(); |
| 4533 | ||
| 4534 | _ = block; | |
| 4535 | _ = inst; | |
| 4518 | 4536 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirShl", .{}); |
| 4519 | 4537 | } |
| 4520 | 4538 | |
| 4521 | 4539 | fn zirShr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4522 | 4540 | const tracy = trace(@src()); |
| 4523 | 4541 | defer tracy.end(); |
| 4542 | ||
| 4543 | _ = inst; | |
| 4524 | 4544 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirShr", .{}); |
| 4525 | 4545 | } |
| 4526 | 4546 | |
| ... | ... | @@ -4590,18 +4610,24 @@ fn zirBitwise( |
| 4590 | 4610 | fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4591 | 4611 | const tracy = trace(@src()); |
| 4592 | 4612 | defer tracy.end(); |
| 4613 | ||
| 4614 | _ = inst; | |
| 4593 | 4615 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirBitNot", .{}); |
| 4594 | 4616 | } |
| 4595 | 4617 | |
| 4596 | 4618 | fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4597 | 4619 | const tracy = trace(@src()); |
| 4598 | 4620 | defer tracy.end(); |
| 4621 | ||
| 4622 | _ = inst; | |
| 4599 | 4623 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayCat", .{}); |
| 4600 | 4624 | } |
| 4601 | 4625 | |
| 4602 | 4626 | fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4603 | 4627 | const tracy = trace(@src()); |
| 4604 | 4628 | defer tracy.end(); |
| 4629 | ||
| 4630 | _ = inst; | |
| 4605 | 4631 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayMul", .{}); |
| 4606 | 4632 | } |
| 4607 | 4633 | |
| ... | ... | @@ -5061,6 +5087,7 @@ fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 5061 | 5087 | } |
| 5062 | 5088 | |
| 5063 | 5089 | fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 5090 | _ = block; | |
| 5064 | 5091 | const zir_datas = sema.code.instructions.items(.data); |
| 5065 | 5092 | const inst_data = zir_datas[inst].un_node; |
| 5066 | 5093 | const src = inst_data.src(); |
| ... | ... | @@ -5069,6 +5096,7 @@ fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! |
| 5069 | 5096 | } |
| 5070 | 5097 | |
| 5071 | 5098 | fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 5099 | _ = block; | |
| 5072 | 5100 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5073 | 5101 | const src = inst_data.src(); |
| 5074 | 5102 | const operand_ptr = try sema.resolveInst(inst_data.operand); |
| ... | ... | @@ -5594,6 +5622,10 @@ fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: |
| 5594 | 5622 | return mod.failWithOwnedErrorMsg(&block.base, msg); |
| 5595 | 5623 | } |
| 5596 | 5624 | |
| 5625 | if (is_ref) { | |
| 5626 | return mod.fail(&block.base, src, "TODO: Sema.zirStructInit is_ref=true", .{}); | |
| 5627 | } | |
| 5628 | ||
| 5597 | 5629 | const is_comptime = for (field_inits) |field_init| { |
| 5598 | 5630 | if (field_init.value() == null) { |
| 5599 | 5631 | break false; |
| ... | ... | @@ -5617,18 +5649,24 @@ fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: |
| 5617 | 5649 | fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst { |
| 5618 | 5650 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5619 | 5651 | const src = inst_data.src(); |
| 5652 | ||
| 5653 | _ = is_ref; | |
| 5620 | 5654 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirStructInitAnon", .{}); |
| 5621 | 5655 | } |
| 5622 | 5656 | |
| 5623 | 5657 | fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst { |
| 5624 | 5658 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5625 | 5659 | const src = inst_data.src(); |
| 5660 | ||
| 5661 | _ = is_ref; | |
| 5626 | 5662 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInit", .{}); |
| 5627 | 5663 | } |
| 5628 | 5664 | |
| 5629 | 5665 | fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst { |
| 5630 | 5666 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5631 | 5667 | const src = inst_data.src(); |
| 5668 | ||
| 5669 | _ = is_ref; | |
| 5632 | 5670 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInitAnon", .{}); |
| 5633 | 5671 | } |
| 5634 | 5672 | |
| ... | ... | @@ -5771,7 +5809,6 @@ fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 5771 | 5809 | return sema.mod.fail(&block.base, type_src, "expected pointer, found '{}'", .{type_res}); |
| 5772 | 5810 | const ptr_align = type_res.ptrAlignment(sema.mod.getTarget()); |
| 5773 | 5811 | |
| 5774 | const uncasted_operand = try sema.resolveInst(extra.rhs); | |
| 5775 | 5812 | if (try sema.resolveDefinedValue(block, operand_src, operand_coerced)) |val| { |
| 5776 | 5813 | const addr = val.toUnsignedInt(); |
| 5777 | 5814 | if (!type_res.isAllowzeroPtr() and addr == 0) |
| ... | ... | @@ -6025,6 +6062,8 @@ fn zirAwait( |
| 6025 | 6062 | ) InnerError!*Inst { |
| 6026 | 6063 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 6027 | 6064 | const src = inst_data.src(); |
| 6065 | ||
| 6066 | _ = is_nosuspend; | |
| 6028 | 6067 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAwait", .{}); |
| 6029 | 6068 | } |
| 6030 | 6069 | |
| ... | ... | @@ -6035,7 +6074,6 @@ fn zirVarExtended( |
| 6035 | 6074 | ) InnerError!*Inst { |
| 6036 | 6075 | const extra = sema.code.extraData(Zir.Inst.ExtendedVar, extended.operand); |
| 6037 | 6076 | const src = sema.src; |
| 6038 | const align_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at align | |
| 6039 | 6077 | const ty_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at type |
| 6040 | 6078 | const mut_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at mut token |
| 6041 | 6079 | const init_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at init expr |
| ... | ... | @@ -6305,6 +6343,8 @@ fn addSafetyCheck(sema: *Sema, parent_block: *Scope.Block, ok: *Inst, panic_id: |
| 6305 | 6343 | } |
| 6306 | 6344 | |
| 6307 | 6345 | fn safetyPanic(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, panic_id: PanicId) !Zir.Inst.Index { |
| 6346 | _ = sema; | |
| 6347 | _ = panic_id; | |
| 6308 | 6348 | // TODO Once we have a panic function to call, call it here instead of breakpoint. |
| 6309 | 6349 | _ = try block.addNoOp(src, Type.initTag(.void), .breakpoint); |
| 6310 | 6350 | _ = try block.addNoOp(src, Type.initTag(.noreturn), .unreach); |
| ... | ... | @@ -6618,6 +6658,8 @@ fn elemPtrArray( |
| 6618 | 6658 | }); |
| 6619 | 6659 | } |
| 6620 | 6660 | } |
| 6661 | _ = elem_index; | |
| 6662 | _ = elem_index_src; | |
| 6621 | 6663 | return sema.mod.fail(&block.base, src, "TODO implement more analyze elemptr for arrays", .{}); |
| 6622 | 6664 | } |
| 6623 | 6665 | |
| ... | ... | @@ -7131,6 +7173,7 @@ fn analyzeSlice( |
| 7131 | 7173 | ptr_child.isVolatilePtr(), |
| 7132 | 7174 | return_ptr_size, |
| 7133 | 7175 | ); |
| 7176 | _ = return_type; | |
| 7134 | 7177 | |
| 7135 | 7178 | return sema.mod.fail(&block.base, src, "TODO implement analysis of slice", .{}); |
| 7136 | 7179 | } |
| ... | ... | @@ -7476,14 +7519,14 @@ fn resolveTypeFields(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, ty: Type |
| 7476 | 7519 | struct_obj.status = .have_field_types; |
| 7477 | 7520 | return ty; |
| 7478 | 7521 | }, |
| 7479 | .extern_options => return sema.resolveBuiltinTypeFields(block, src, ty, "ExternOptions"), | |
| 7480 | .export_options => return sema.resolveBuiltinTypeFields(block, src, ty, "ExportOptions"), | |
| 7481 | .atomic_ordering => return sema.resolveBuiltinTypeFields(block, src, ty, "AtomicOrdering"), | |
| 7482 | .atomic_rmw_op => return sema.resolveBuiltinTypeFields(block, src, ty, "AtomicRmwOp"), | |
| 7483 | .calling_convention => return sema.resolveBuiltinTypeFields(block, src, ty, "CallingConvention"), | |
| 7484 | .float_mode => return sema.resolveBuiltinTypeFields(block, src, ty, "FloatMode"), | |
| 7485 | .reduce_op => return sema.resolveBuiltinTypeFields(block, src, ty, "ReduceOp"), | |
| 7486 | .call_options => return sema.resolveBuiltinTypeFields(block, src, ty, "CallOptions"), | |
| 7522 | .extern_options => return sema.resolveBuiltinTypeFields(block, src, "ExternOptions"), | |
| 7523 | .export_options => return sema.resolveBuiltinTypeFields(block, src, "ExportOptions"), | |
| 7524 | .atomic_ordering => return sema.resolveBuiltinTypeFields(block, src, "AtomicOrdering"), | |
| 7525 | .atomic_rmw_op => return sema.resolveBuiltinTypeFields(block, src, "AtomicRmwOp"), | |
| 7526 | .calling_convention => return sema.resolveBuiltinTypeFields(block, src, "CallingConvention"), | |
| 7527 | .float_mode => return sema.resolveBuiltinTypeFields(block, src, "FloatMode"), | |
| 7528 | .reduce_op => return sema.resolveBuiltinTypeFields(block, src, "ReduceOp"), | |
| 7529 | .call_options => return sema.resolveBuiltinTypeFields(block, src, "CallOptions"), | |
| 7487 | 7530 | |
| 7488 | 7531 | .@"union", .union_tagged => { |
| 7489 | 7532 | const union_obj = ty.cast(Type.Payload.Union).?.data; |
| ... | ... | @@ -7509,7 +7552,6 @@ fn resolveBuiltinTypeFields( |
| 7509 | 7552 | sema: *Sema, |
| 7510 | 7553 | block: *Scope.Block, |
| 7511 | 7554 | src: LazySrcLoc, |
| 7512 | ty: Type, | |
| 7513 | 7555 | name: []const u8, |
| 7514 | 7556 | ) InnerError!Type { |
| 7515 | 7557 | const resolved_ty = try sema.getBuiltinType(block, src, name); |
| ... | ... | @@ -7524,7 +7566,7 @@ fn getBuiltinType( |
| 7524 | 7566 | ) InnerError!Type { |
| 7525 | 7567 | const mod = sema.mod; |
| 7526 | 7568 | const std_pkg = mod.root_pkg.table.get("std").?; |
| 7527 | const std_file = (mod.importPkg(mod.root_pkg, std_pkg) catch unreachable).file; | |
| 7569 | const std_file = (mod.importPkg(std_pkg) catch unreachable).file; | |
| 7528 | 7570 | const opt_builtin_inst = try sema.analyzeNamespaceLookup( |
| 7529 | 7571 | block, |
| 7530 | 7572 | src, |
src/ThreadPool.zig+2-2| ... | ... | @@ -101,7 +101,7 @@ pub fn deinit(self: *ThreadPool) void { |
| 101 | 101 | |
| 102 | 102 | pub fn spawn(self: *ThreadPool, comptime func: anytype, args: anytype) !void { |
| 103 | 103 | if (std.builtin.single_threaded) { |
| 104 | const result = @call(.{}, func, args); | |
| 104 | @call(.{}, func, args); | |
| 105 | 105 | return; |
| 106 | 106 | } |
| 107 | 107 | |
| ... | ... | @@ -114,7 +114,7 @@ pub fn spawn(self: *ThreadPool, comptime func: anytype, args: anytype) !void { |
| 114 | 114 | fn runFn(runnable: *Runnable) void { |
| 115 | 115 | const run_node = @fieldParentPtr(RunQueue.Node, "data", runnable); |
| 116 | 116 | const closure = @fieldParentPtr(@This(), "run_node", run_node); |
| 117 | const result = @call(.{}, func, closure.arguments); | |
| 117 | @call(.{}, func, closure.arguments); | |
| 118 | 118 | |
| 119 | 119 | const held = closure.pool.lock.acquire(); |
| 120 | 120 | defer held.release(); |
src/Zir.zig+14-4| ... | ... | @@ -3176,6 +3176,7 @@ const Writer = struct { |
| 3176 | 3176 | inst: Inst.Index, |
| 3177 | 3177 | ) (@TypeOf(stream).Error || error{OutOfMemory})!void { |
| 3178 | 3178 | const inst_data = self.code.instructions.items(.data)[inst].array_type_sentinel; |
| 3179 | _ = inst_data; | |
| 3179 | 3180 | try stream.writeAll("TODO)"); |
| 3180 | 3181 | } |
| 3181 | 3182 | |
| ... | ... | @@ -3213,6 +3214,7 @@ const Writer = struct { |
| 3213 | 3214 | inst: Inst.Index, |
| 3214 | 3215 | ) (@TypeOf(stream).Error || error{OutOfMemory})!void { |
| 3215 | 3216 | const inst_data = self.code.instructions.items(.data)[inst].ptr_type; |
| 3217 | _ = inst_data; | |
| 3216 | 3218 | try stream.writeAll("TODO)"); |
| 3217 | 3219 | } |
| 3218 | 3220 | |
| ... | ... | @@ -3559,6 +3561,8 @@ const Writer = struct { |
| 3559 | 3561 | assert(body.len == 0); |
| 3560 | 3562 | try stream.writeAll("{}, {})"); |
| 3561 | 3563 | } else { |
| 3564 | const prev_parent_decl_node = self.parent_decl_node; | |
| 3565 | if (src_node) |off| self.parent_decl_node = self.relativeToNodeIndex(off); | |
| 3562 | 3566 | self.indent += 2; |
| 3563 | 3567 | if (body.len == 0) { |
| 3564 | 3568 | try stream.writeAll("{}, {\n"); |
| ... | ... | @@ -3621,6 +3625,7 @@ const Writer = struct { |
| 3621 | 3625 | try stream.writeAll(",\n"); |
| 3622 | 3626 | } |
| 3623 | 3627 | |
| 3628 | self.parent_decl_node = prev_parent_decl_node; | |
| 3624 | 3629 | self.indent -= 2; |
| 3625 | 3630 | try stream.writeByteNTimes(' ', self.indent); |
| 3626 | 3631 | try stream.writeAll("})"); |
| ... | ... | @@ -3689,6 +3694,8 @@ const Writer = struct { |
| 3689 | 3694 | const body = self.code.extra[extra_index..][0..body_len]; |
| 3690 | 3695 | extra_index += body.len; |
| 3691 | 3696 | |
| 3697 | const prev_parent_decl_node = self.parent_decl_node; | |
| 3698 | if (src_node) |off| self.parent_decl_node = self.relativeToNodeIndex(off); | |
| 3692 | 3699 | self.indent += 2; |
| 3693 | 3700 | if (body.len == 0) { |
| 3694 | 3701 | try stream.writeAll("{}, {\n"); |
| ... | ... | @@ -3754,6 +3761,7 @@ const Writer = struct { |
| 3754 | 3761 | try stream.writeAll(",\n"); |
| 3755 | 3762 | } |
| 3756 | 3763 | |
| 3764 | self.parent_decl_node = prev_parent_decl_node; | |
| 3757 | 3765 | self.indent -= 2; |
| 3758 | 3766 | try stream.writeByteNTimes(' ', self.indent); |
| 3759 | 3767 | try stream.writeAll("})"); |
| ... | ... | @@ -3909,6 +3917,8 @@ const Writer = struct { |
| 3909 | 3917 | assert(body.len == 0); |
| 3910 | 3918 | try stream.writeAll("{}, {})"); |
| 3911 | 3919 | } else { |
| 3920 | const prev_parent_decl_node = self.parent_decl_node; | |
| 3921 | if (src_node) |off| self.parent_decl_node = self.relativeToNodeIndex(off); | |
| 3912 | 3922 | self.indent += 2; |
| 3913 | 3923 | if (body.len == 0) { |
| 3914 | 3924 | try stream.writeAll("{}, {\n"); |
| ... | ... | @@ -3949,6 +3959,7 @@ const Writer = struct { |
| 3949 | 3959 | } |
| 3950 | 3960 | try stream.writeAll(",\n"); |
| 3951 | 3961 | } |
| 3962 | self.parent_decl_node = prev_parent_decl_node; | |
| 3952 | 3963 | self.indent -= 2; |
| 3953 | 3964 | try stream.writeByteNTimes(' ', self.indent); |
| 3954 | 3965 | try stream.writeAll("})"); |
| ... | ... | @@ -4431,6 +4442,7 @@ const Writer = struct { |
| 4431 | 4442 | } |
| 4432 | 4443 | |
| 4433 | 4444 | fn writeInstIndex(self: *Writer, stream: anytype, inst: Inst.Index) !void { |
| 4445 | _ = self; | |
| 4434 | 4446 | return stream.print("%{d}", .{inst}); |
| 4435 | 4447 | } |
| 4436 | 4448 | |
| ... | ... | @@ -4451,6 +4463,7 @@ const Writer = struct { |
| 4451 | 4463 | name: []const u8, |
| 4452 | 4464 | flag: bool, |
| 4453 | 4465 | ) !void { |
| 4466 | _ = self; | |
| 4454 | 4467 | if (!flag) return; |
| 4455 | 4468 | try stream.writeAll(name); |
| 4456 | 4469 | } |
| ... | ... | @@ -4739,7 +4752,6 @@ fn findDeclsSwitch( |
| 4739 | 4752 | var extra_index: usize = special.end; |
| 4740 | 4753 | var scalar_i: usize = 0; |
| 4741 | 4754 | while (scalar_i < extra.data.cases_len) : (scalar_i += 1) { |
| 4742 | const item_ref = @intToEnum(Inst.Ref, zir.extra[extra_index]); | |
| 4743 | 4755 | extra_index += 1; |
| 4744 | 4756 | const body_len = zir.extra[extra_index]; |
| 4745 | 4757 | extra_index += 1; |
| ... | ... | @@ -4779,7 +4791,6 @@ fn findDeclsSwitchMulti( |
| 4779 | 4791 | { |
| 4780 | 4792 | var scalar_i: usize = 0; |
| 4781 | 4793 | while (scalar_i < extra.data.scalar_cases_len) : (scalar_i += 1) { |
| 4782 | const item_ref = @intToEnum(Inst.Ref, zir.extra[extra_index]); | |
| 4783 | 4794 | extra_index += 1; |
| 4784 | 4795 | const body_len = zir.extra[extra_index]; |
| 4785 | 4796 | extra_index += 1; |
| ... | ... | @@ -4800,12 +4811,11 @@ fn findDeclsSwitchMulti( |
| 4800 | 4811 | extra_index += 1; |
| 4801 | 4812 | const items = zir.refSlice(extra_index, items_len); |
| 4802 | 4813 | extra_index += items_len; |
| 4814 | _ = items; | |
| 4803 | 4815 | |
| 4804 | 4816 | var range_i: usize = 0; |
| 4805 | 4817 | while (range_i < ranges_len) : (range_i += 1) { |
| 4806 | const item_first = @intToEnum(Inst.Ref, zir.extra[extra_index]); | |
| 4807 | 4818 | extra_index += 1; |
| 4808 | const item_last = @intToEnum(Inst.Ref, zir.extra[extra_index]); | |
| 4809 | 4819 | extra_index += 1; |
| 4810 | 4820 | } |
| 4811 | 4821 |
src/air.zig+36| ... | ... | @@ -304,9 +304,12 @@ pub const Inst = struct { |
| 304 | 304 | base: Inst, |
| 305 | 305 | |
| 306 | 306 | pub fn operandCount(self: *const NoOp) usize { |
| 307 | _ = self; | |
| 307 | 308 | return 0; |
| 308 | 309 | } |
| 309 | 310 | pub fn getOperand(self: *const NoOp, index: usize) ?*Inst { |
| 311 | _ = self; | |
| 312 | _ = index; | |
| 310 | 313 | return null; |
| 311 | 314 | } |
| 312 | 315 | }; |
| ... | ... | @@ -316,6 +319,7 @@ pub const Inst = struct { |
| 316 | 319 | operand: *Inst, |
| 317 | 320 | |
| 318 | 321 | pub fn operandCount(self: *const UnOp) usize { |
| 322 | _ = self; | |
| 319 | 323 | return 1; |
| 320 | 324 | } |
| 321 | 325 | pub fn getOperand(self: *const UnOp, index: usize) ?*Inst { |
| ... | ... | @@ -331,6 +335,7 @@ pub const Inst = struct { |
| 331 | 335 | rhs: *Inst, |
| 332 | 336 | |
| 333 | 337 | pub fn operandCount(self: *const BinOp) usize { |
| 338 | _ = self; | |
| 334 | 339 | return 2; |
| 335 | 340 | } |
| 336 | 341 | pub fn getOperand(self: *const BinOp, index: usize) ?*Inst { |
| ... | ... | @@ -356,9 +361,12 @@ pub const Inst = struct { |
| 356 | 361 | name: [*:0]const u8, |
| 357 | 362 | |
| 358 | 363 | pub fn operandCount(self: *const Arg) usize { |
| 364 | _ = self; | |
| 359 | 365 | return 0; |
| 360 | 366 | } |
| 361 | 367 | pub fn getOperand(self: *const Arg, index: usize) ?*Inst { |
| 368 | _ = self; | |
| 369 | _ = index; | |
| 362 | 370 | return null; |
| 363 | 371 | } |
| 364 | 372 | }; |
| ... | ... | @@ -391,9 +399,12 @@ pub const Inst = struct { |
| 391 | 399 | body: Body, |
| 392 | 400 | |
| 393 | 401 | pub fn operandCount(self: *const Block) usize { |
| 402 | _ = self; | |
| 394 | 403 | return 0; |
| 395 | 404 | } |
| 396 | 405 | pub fn getOperand(self: *const Block, index: usize) ?*Inst { |
| 406 | _ = self; | |
| 407 | _ = index; | |
| 397 | 408 | return null; |
| 398 | 409 | } |
| 399 | 410 | }; |
| ... | ... | @@ -412,9 +423,12 @@ pub const Inst = struct { |
| 412 | 423 | body: Body, |
| 413 | 424 | |
| 414 | 425 | pub fn operandCount(self: *const BrBlockFlat) usize { |
| 426 | _ = self; | |
| 415 | 427 | return 0; |
| 416 | 428 | } |
| 417 | 429 | pub fn getOperand(self: *const BrBlockFlat, index: usize) ?*Inst { |
| 430 | _ = self; | |
| 431 | _ = index; | |
| 418 | 432 | return null; |
| 419 | 433 | } |
| 420 | 434 | }; |
| ... | ... | @@ -427,9 +441,11 @@ pub const Inst = struct { |
| 427 | 441 | operand: *Inst, |
| 428 | 442 | |
| 429 | 443 | pub fn operandCount(self: *const Br) usize { |
| 444 | _ = self; | |
| 430 | 445 | return 1; |
| 431 | 446 | } |
| 432 | 447 | pub fn getOperand(self: *const Br, index: usize) ?*Inst { |
| 448 | _ = self; | |
| 433 | 449 | if (index == 0) |
| 434 | 450 | return self.operand; |
| 435 | 451 | return null; |
| ... | ... | @@ -443,9 +459,12 @@ pub const Inst = struct { |
| 443 | 459 | block: *Block, |
| 444 | 460 | |
| 445 | 461 | pub fn operandCount(self: *const BrVoid) usize { |
| 462 | _ = self; | |
| 446 | 463 | return 0; |
| 447 | 464 | } |
| 448 | 465 | pub fn getOperand(self: *const BrVoid, index: usize) ?*Inst { |
| 466 | _ = self; | |
| 467 | _ = index; | |
| 449 | 468 | return null; |
| 450 | 469 | } |
| 451 | 470 | }; |
| ... | ... | @@ -490,6 +509,7 @@ pub const Inst = struct { |
| 490 | 509 | else_death_count: u32 = 0, |
| 491 | 510 | |
| 492 | 511 | pub fn operandCount(self: *const CondBr) usize { |
| 512 | _ = self; | |
| 493 | 513 | return 1; |
| 494 | 514 | } |
| 495 | 515 | pub fn getOperand(self: *const CondBr, index: usize) ?*Inst { |
| ... | ... | @@ -516,9 +536,12 @@ pub const Inst = struct { |
| 516 | 536 | val: Value, |
| 517 | 537 | |
| 518 | 538 | pub fn operandCount(self: *const Constant) usize { |
| 539 | _ = self; | |
| 519 | 540 | return 0; |
| 520 | 541 | } |
| 521 | 542 | pub fn getOperand(self: *const Constant, index: usize) ?*Inst { |
| 543 | _ = self; | |
| 544 | _ = index; | |
| 522 | 545 | return null; |
| 523 | 546 | } |
| 524 | 547 | }; |
| ... | ... | @@ -530,9 +553,12 @@ pub const Inst = struct { |
| 530 | 553 | body: Body, |
| 531 | 554 | |
| 532 | 555 | pub fn operandCount(self: *const Loop) usize { |
| 556 | _ = self; | |
| 533 | 557 | return 0; |
| 534 | 558 | } |
| 535 | 559 | pub fn getOperand(self: *const Loop, index: usize) ?*Inst { |
| 560 | _ = self; | |
| 561 | _ = index; | |
| 536 | 562 | return null; |
| 537 | 563 | } |
| 538 | 564 | }; |
| ... | ... | @@ -544,9 +570,12 @@ pub const Inst = struct { |
| 544 | 570 | variable: *Module.Var, |
| 545 | 571 | |
| 546 | 572 | pub fn operandCount(self: *const VarPtr) usize { |
| 573 | _ = self; | |
| 547 | 574 | return 0; |
| 548 | 575 | } |
| 549 | 576 | pub fn getOperand(self: *const VarPtr, index: usize) ?*Inst { |
| 577 | _ = self; | |
| 578 | _ = index; | |
| 550 | 579 | return null; |
| 551 | 580 | } |
| 552 | 581 | }; |
| ... | ... | @@ -559,9 +588,12 @@ pub const Inst = struct { |
| 559 | 588 | field_index: usize, |
| 560 | 589 | |
| 561 | 590 | pub fn operandCount(self: *const StructFieldPtr) usize { |
| 591 | _ = self; | |
| 562 | 592 | return 1; |
| 563 | 593 | } |
| 564 | 594 | pub fn getOperand(self: *const StructFieldPtr, index: usize) ?*Inst { |
| 595 | _ = self; | |
| 596 | _ = index; | |
| 565 | 597 | var i = index; |
| 566 | 598 | |
| 567 | 599 | if (i < 1) |
| ... | ... | @@ -593,6 +625,7 @@ pub const Inst = struct { |
| 593 | 625 | }; |
| 594 | 626 | |
| 595 | 627 | pub fn operandCount(self: *const SwitchBr) usize { |
| 628 | _ = self; | |
| 596 | 629 | return 1; |
| 597 | 630 | } |
| 598 | 631 | pub fn getOperand(self: *const SwitchBr, index: usize) ?*Inst { |
| ... | ... | @@ -621,9 +654,12 @@ pub const Inst = struct { |
| 621 | 654 | column: u32, |
| 622 | 655 | |
| 623 | 656 | pub fn operandCount(self: *const DbgStmt) usize { |
| 657 | _ = self; | |
| 624 | 658 | return 0; |
| 625 | 659 | } |
| 626 | 660 | pub fn getOperand(self: *const DbgStmt, index: usize) ?*Inst { |
| 661 | _ = self; | |
| 662 | _ = index; | |
| 627 | 663 | return null; |
| 628 | 664 | } |
| 629 | 665 | }; |
src/codegen.zig+22-6| ... | ... | @@ -118,7 +118,6 @@ pub fn generateSymbol( |
| 118 | 118 | if (typed_value.ty.sentinel()) |sentinel| { |
| 119 | 119 | try code.ensureCapacity(code.items.len + payload.data.len + 1); |
| 120 | 120 | code.appendSliceAssumeCapacity(payload.data); |
| 121 | const prev_len = code.items.len; | |
| 122 | 121 | switch (try generateSymbol(bin_file, src_loc, .{ |
| 123 | 122 | .ty = typed_value.ty.elemType(), |
| 124 | 123 | .val = sentinel, |
| ... | ... | @@ -565,7 +564,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 565 | 564 | .r11 = true, // fp |
| 566 | 565 | .r14 = true, // lr |
| 567 | 566 | }; |
| 568 | inline for (callee_preserved_regs) |reg, i| { | |
| 567 | inline for (callee_preserved_regs) |reg| { | |
| 569 | 568 | if (self.register_manager.isRegAllocated(reg)) { |
| 570 | 569 | @field(saved_regs, @tagName(reg)) = true; |
| 571 | 570 | } |
| ... | ... | @@ -603,7 +602,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 603 | 602 | } else { |
| 604 | 603 | if (math.cast(i26, amt)) |offset| { |
| 605 | 604 | writeInt(u32, self.code.items[jmp_reloc..][0..4], Instruction.b(.al, offset).toU32()); |
| 606 | } else |err| { | |
| 605 | } else |_| { | |
| 607 | 606 | return self.failSymbol("exitlude jump is too large", .{}); |
| 608 | 607 | } |
| 609 | 608 | } |
| ... | ... | @@ -676,7 +675,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 676 | 675 | } else { |
| 677 | 676 | if (math.cast(i28, amt)) |offset| { |
| 678 | 677 | writeInt(u32, self.code.items[jmp_reloc..][0..4], Instruction.b(offset).toU32()); |
| 679 | } else |err| { | |
| 678 | } else |_| { | |
| 680 | 679 | return self.failSymbol("exitlude jump is too large", .{}); |
| 681 | 680 | } |
| 682 | 681 | } |
| ... | ... | @@ -1498,6 +1497,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 1498 | 1497 | swap_lhs_and_rhs: bool, |
| 1499 | 1498 | op: ir.Inst.Tag, |
| 1500 | 1499 | ) !void { |
| 1500 | _ = src; | |
| 1501 | 1501 | assert(lhs_mcv == .register or rhs_mcv == .register); |
| 1502 | 1502 | |
| 1503 | 1503 | const op1 = if (swap_lhs_and_rhs) rhs_mcv.register else lhs_mcv.register; |
| ... | ... | @@ -1906,6 +1906,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 1906 | 1906 | try self.genX8664ModRMRegToStack(src, dst_ty, off, src_reg, mr + 0x1); |
| 1907 | 1907 | }, |
| 1908 | 1908 | .immediate => |imm| { |
| 1909 | _ = imm; | |
| 1909 | 1910 | return self.fail(src, "TODO implement x86 ADD/SUB/CMP source immediate", .{}); |
| 1910 | 1911 | }, |
| 1911 | 1912 | .embedded_in_code, .memory, .stack_offset => { |
| ... | ... | @@ -2055,6 +2056,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 2055 | 2056 | return self.genSetStack(src, dst_ty, off, MCValue{ .register = dst_reg }); |
| 2056 | 2057 | }, |
| 2057 | 2058 | .immediate => |imm| { |
| 2059 | _ = imm; | |
| 2058 | 2060 | return self.fail(src, "TODO implement x86 multiply source immediate", .{}); |
| 2059 | 2061 | }, |
| 2060 | 2062 | .embedded_in_code, .memory, .stack_offset => { |
| ... | ... | @@ -2983,14 +2985,14 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 2983 | 2985 | .arm, .armeb => { |
| 2984 | 2986 | if (math.cast(i26, @intCast(i32, index) - @intCast(i32, self.code.items.len + 8))) |delta| { |
| 2985 | 2987 | writeInt(u32, try self.code.addManyAsArray(4), Instruction.b(.al, delta).toU32()); |
| 2986 | } else |err| { | |
| 2988 | } else |_| { | |
| 2987 | 2989 | return self.fail(src, "TODO: enable larger branch offset", .{}); |
| 2988 | 2990 | } |
| 2989 | 2991 | }, |
| 2990 | 2992 | .aarch64, .aarch64_be, .aarch64_32 => { |
| 2991 | 2993 | if (math.cast(i28, @intCast(i32, index) - @intCast(i32, self.code.items.len + 8))) |delta| { |
| 2992 | 2994 | writeInt(u32, try self.code.addManyAsArray(4), Instruction.b(delta).toU32()); |
| 2993 | } else |err| { | |
| 2995 | } else |_| { | |
| 2994 | 2996 | return self.fail(src, "TODO: enable larger branch offset", .{}); |
| 2995 | 2997 | } |
| 2996 | 2998 | }, |
| ... | ... | @@ -3308,9 +3310,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 3308 | 3310 | } |
| 3309 | 3311 | }, |
| 3310 | 3312 | .compare_flags_unsigned => |op| { |
| 3313 | _ = op; | |
| 3311 | 3314 | return self.fail(src, "TODO implement set stack variable with compare flags value (unsigned)", .{}); |
| 3312 | 3315 | }, |
| 3313 | 3316 | .compare_flags_signed => |op| { |
| 3317 | _ = op; | |
| 3314 | 3318 | return self.fail(src, "TODO implement set stack variable with compare flags value (signed)", .{}); |
| 3315 | 3319 | }, |
| 3316 | 3320 | .immediate => { |
| ... | ... | @@ -3318,6 +3322,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 3318 | 3322 | return self.genSetStack(src, ty, stack_offset, MCValue{ .register = reg }); |
| 3319 | 3323 | }, |
| 3320 | 3324 | .embedded_in_code => |code_offset| { |
| 3325 | _ = code_offset; | |
| 3321 | 3326 | return self.fail(src, "TODO implement set stack variable from embedded_in_code", .{}); |
| 3322 | 3327 | }, |
| 3323 | 3328 | .register => |reg| { |
| ... | ... | @@ -3354,6 +3359,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 3354 | 3359 | } |
| 3355 | 3360 | }, |
| 3356 | 3361 | .memory => |vaddr| { |
| 3362 | _ = vaddr; | |
| 3357 | 3363 | return self.fail(src, "TODO implement set stack variable from memory vaddr", .{}); |
| 3358 | 3364 | }, |
| 3359 | 3365 | .stack_offset => |off| { |
| ... | ... | @@ -3382,9 +3388,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 3382 | 3388 | } |
| 3383 | 3389 | }, |
| 3384 | 3390 | .compare_flags_unsigned => |op| { |
| 3391 | _ = op; | |
| 3385 | 3392 | return self.fail(src, "TODO implement set stack variable with compare flags value (unsigned)", .{}); |
| 3386 | 3393 | }, |
| 3387 | 3394 | .compare_flags_signed => |op| { |
| 3395 | _ = op; | |
| 3388 | 3396 | return self.fail(src, "TODO implement set stack variable with compare flags value (signed)", .{}); |
| 3389 | 3397 | }, |
| 3390 | 3398 | .immediate => |x_big| { |
| ... | ... | @@ -3437,12 +3445,14 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 3437 | 3445 | } |
| 3438 | 3446 | }, |
| 3439 | 3447 | .embedded_in_code => |code_offset| { |
| 3448 | _ = code_offset; | |
| 3440 | 3449 | return self.fail(src, "TODO implement set stack variable from embedded_in_code", .{}); |
| 3441 | 3450 | }, |
| 3442 | 3451 | .register => |reg| { |
| 3443 | 3452 | try self.genX8664ModRMRegToStack(src, ty, stack_offset, reg, 0x89); |
| 3444 | 3453 | }, |
| 3445 | 3454 | .memory => |vaddr| { |
| 3455 | _ = vaddr; | |
| 3446 | 3456 | return self.fail(src, "TODO implement set stack variable from memory vaddr", .{}); |
| 3447 | 3457 | }, |
| 3448 | 3458 | .stack_offset => |off| { |
| ... | ... | @@ -3471,9 +3481,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 3471 | 3481 | } |
| 3472 | 3482 | }, |
| 3473 | 3483 | .compare_flags_unsigned => |op| { |
| 3484 | _ = op; | |
| 3474 | 3485 | return self.fail(src, "TODO implement set stack variable with compare flags value (unsigned)", .{}); |
| 3475 | 3486 | }, |
| 3476 | 3487 | .compare_flags_signed => |op| { |
| 3488 | _ = op; | |
| 3477 | 3489 | return self.fail(src, "TODO implement set stack variable with compare flags value (signed)", .{}); |
| 3478 | 3490 | }, |
| 3479 | 3491 | .immediate => { |
| ... | ... | @@ -3481,6 +3493,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 3481 | 3493 | return self.genSetStack(src, ty, stack_offset, MCValue{ .register = reg }); |
| 3482 | 3494 | }, |
| 3483 | 3495 | .embedded_in_code => |code_offset| { |
| 3496 | _ = code_offset; | |
| 3484 | 3497 | return self.fail(src, "TODO implement set stack variable from embedded_in_code", .{}); |
| 3485 | 3498 | }, |
| 3486 | 3499 | .register => |reg| { |
| ... | ... | @@ -3513,6 +3526,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 3513 | 3526 | } |
| 3514 | 3527 | }, |
| 3515 | 3528 | .memory => |vaddr| { |
| 3529 | _ = vaddr; | |
| 3516 | 3530 | return self.fail(src, "TODO implement set stack variable from memory vaddr", .{}); |
| 3517 | 3531 | }, |
| 3518 | 3532 | .stack_offset => |off| { |
| ... | ... | @@ -3843,6 +3857,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 3843 | 3857 | ); |
| 3844 | 3858 | }, |
| 3845 | 3859 | .compare_flags_signed => |op| { |
| 3860 | _ = op; | |
| 3846 | 3861 | return self.fail(src, "TODO set register with compare flags value (signed)", .{}); |
| 3847 | 3862 | }, |
| 3848 | 3863 | .immediate => |x| { |
| ... | ... | @@ -4461,6 +4476,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 4461 | 4476 | dummy, |
| 4462 | 4477 | |
| 4463 | 4478 | pub fn allocIndex(self: Register) ?u4 { |
| 4479 | _ = self; | |
| 4464 | 4480 | return null; |
| 4465 | 4481 | } |
| 4466 | 4482 | }; |
src/codegen/arm.zig+1-1| ... | ... | @@ -674,7 +674,7 @@ pub const Instruction = union(enum) { |
| 674 | 674 | }; |
| 675 | 675 | const imm4h: u4 = switch (offset) { |
| 676 | 676 | .immediate => |imm| @truncate(u4, imm >> 4), |
| 677 | .register => |reg| 0b0000, | |
| 677 | .register => 0b0000, | |
| 678 | 678 | }; |
| 679 | 679 | |
| 680 | 680 | return Instruction{ |
src/codegen/c.zig+9-1| ... | ... | @@ -47,6 +47,8 @@ fn formatTypeAsCIdentifier( |
| 47 | 47 | options: std.fmt.FormatOptions, |
| 48 | 48 | writer: anytype, |
| 49 | 49 | ) !void { |
| 50 | _ = fmt; | |
| 51 | _ = options; | |
| 50 | 52 | var buffer = [1]u8{0} ** 128; |
| 51 | 53 | // We don't care if it gets cut off, it's still more unique than a number |
| 52 | 54 | var buf = std.fmt.bufPrint(&buffer, "{}", .{data}) catch &buffer; |
| ... | ... | @@ -63,6 +65,8 @@ fn formatIdent( |
| 63 | 65 | options: std.fmt.FormatOptions, |
| 64 | 66 | writer: anytype, |
| 65 | 67 | ) !void { |
| 68 | _ = fmt; | |
| 69 | _ = options; | |
| 66 | 70 | for (ident) |c, i| { |
| 67 | 71 | switch (c) { |
| 68 | 72 | 'a'...'z', 'A'...'Z', '_' => try writer.writeByte(c), |
| ... | ... | @@ -747,6 +751,7 @@ pub fn genBody(o: *Object, body: ir.Body) error{ AnalysisFail, OutOfMemory }!voi |
| 747 | 751 | } |
| 748 | 752 | |
| 749 | 753 | fn genVarPtr(o: *Object, inst: *Inst.VarPtr) !CValue { |
| 754 | _ = o; | |
| 750 | 755 | return CValue{ .decl_ref = inst.variable.owner_decl }; |
| 751 | 756 | } |
| 752 | 757 | |
| ... | ... | @@ -937,6 +942,8 @@ fn genCall(o: *Object, inst: *Inst.Call) !CValue { |
| 937 | 942 | } |
| 938 | 943 | |
| 939 | 944 | fn genDbgStmt(o: *Object, inst: *Inst.DbgStmt) !CValue { |
| 945 | _ = o; | |
| 946 | _ = inst; | |
| 940 | 947 | // TODO emit #line directive here with line number and filename |
| 941 | 948 | return CValue.none; |
| 942 | 949 | } |
| ... | ... | @@ -1016,11 +1023,13 @@ fn genBitcast(o: *Object, inst: *Inst.UnOp) !CValue { |
| 1016 | 1023 | } |
| 1017 | 1024 | |
| 1018 | 1025 | fn genBreakpoint(o: *Object, inst: *Inst.NoOp) !CValue { |
| 1026 | _ = inst; | |
| 1019 | 1027 | try o.writer().writeAll("zig_breakpoint();\n"); |
| 1020 | 1028 | return CValue.none; |
| 1021 | 1029 | } |
| 1022 | 1030 | |
| 1023 | 1031 | fn genUnreach(o: *Object, inst: *Inst.NoOp) !CValue { |
| 1032 | _ = inst; | |
| 1024 | 1033 | try o.writer().writeAll("zig_unreachable();\n"); |
| 1025 | 1034 | return CValue.none; |
| 1026 | 1035 | } |
| ... | ... | @@ -1107,7 +1116,6 @@ fn genAsm(o: *Object, as: *Inst.Assembly) !CValue { |
| 1107 | 1116 | for (as.inputs) |i, index| { |
| 1108 | 1117 | if (i[0] == '{' and i[i.len - 1] == '}') { |
| 1109 | 1118 | const reg = i[1 .. i.len - 1]; |
| 1110 | const arg = as.args[index]; | |
| 1111 | 1119 | if (index > 0) { |
| 1112 | 1120 | try writer.writeAll(", "); |
| 1113 | 1121 | } |
src/codegen/llvm.zig+4| ... | ... | @@ -154,6 +154,7 @@ pub const Object = struct { |
| 154 | 154 | object_pathZ: [:0]const u8, |
| 155 | 155 | |
| 156 | 156 | pub fn create(allocator: *Allocator, sub_path: []const u8, options: link.Options) !*Object { |
| 157 | _ = sub_path; | |
| 157 | 158 | const self = try allocator.create(Object); |
| 158 | 159 | errdefer allocator.destroy(self); |
| 159 | 160 | |
| ... | ... | @@ -742,6 +743,7 @@ pub const FuncGen = struct { |
| 742 | 743 | } |
| 743 | 744 | |
| 744 | 745 | fn genRetVoid(self: *FuncGen, inst: *Inst.NoOp) ?*const llvm.Value { |
| 746 | _ = inst; | |
| 745 | 747 | _ = self.builder.buildRetVoid(); |
| 746 | 748 | return null; |
| 747 | 749 | } |
| ... | ... | @@ -873,6 +875,7 @@ pub const FuncGen = struct { |
| 873 | 875 | } |
| 874 | 876 | |
| 875 | 877 | fn genUnreach(self: *FuncGen, inst: *Inst.NoOp) ?*const llvm.Value { |
| 878 | _ = inst; | |
| 876 | 879 | _ = self.builder.buildUnreachable(); |
| 877 | 880 | return null; |
| 878 | 881 | } |
| ... | ... | @@ -1013,6 +1016,7 @@ pub const FuncGen = struct { |
| 1013 | 1016 | } |
| 1014 | 1017 | |
| 1015 | 1018 | fn genBreakpoint(self: *FuncGen, inst: *Inst.NoOp) !?*const llvm.Value { |
| 1019 | _ = inst; | |
| 1016 | 1020 | const llvn_fn = self.getIntrinsic("llvm.debugtrap"); |
| 1017 | 1021 | _ = self.builder.buildCall(llvn_fn, null, 0, ""); |
| 1018 | 1022 | return null; |
src/codegen/spirv.zig+1-3| ... | ... | @@ -714,7 +714,6 @@ pub const DeclGen = struct { |
| 714 | 714 | return self.fail(inst.base.src, "TODO: SPIR-V backend: binary operations for strange integers", .{}); |
| 715 | 715 | } |
| 716 | 716 | |
| 717 | const is_bool = info.class == .bool; | |
| 718 | 717 | const is_float = info.class == .float; |
| 719 | 718 | const is_signed = info.signedness == .signed; |
| 720 | 719 | // **Note**: All these operations must be valid for vectors as well! |
| ... | ... | @@ -802,8 +801,6 @@ pub const DeclGen = struct { |
| 802 | 801 | const result_id = self.spv.allocResultId(); |
| 803 | 802 | const result_type_id = try self.genType(inst.base.src, inst.base.ty); |
| 804 | 803 | |
| 805 | const info = try self.arithmeticTypeInfo(inst.operand.ty); | |
| 806 | ||
| 807 | 804 | const opcode = switch (inst.base.tag) { |
| 808 | 805 | // Bool -> bool |
| 809 | 806 | .not => Opcode.OpLogicalNot, |
| ... | ... | @@ -867,6 +864,7 @@ pub const DeclGen = struct { |
| 867 | 864 | // are not allowed to be created from a phi node, and throw an error for those. For now, genType already throws |
| 868 | 865 | // an error for pointers. |
| 869 | 866 | const result_type_id = try self.genType(inst.base.src, inst.base.ty); |
| 867 | _ = result_type_id; | |
| 870 | 868 | |
| 871 | 869 | try writeOpcode(&self.code, .OpPhi, 2 + @intCast(u16, incoming_blocks.items.len * 2)); // result type + result + variable/parent... |
| 872 | 870 |
src/codegen/wasm.zig+7-6| ... | ... | @@ -702,7 +702,7 @@ pub const Context = struct { |
| 702 | 702 | try writer.writeByte(wasm.valtype(.i32)); // error code is always an i32 integer. |
| 703 | 703 | try writer.writeByte(val_type); |
| 704 | 704 | }, |
| 705 | else => |ret_type| { | |
| 705 | else => { | |
| 706 | 706 | try leb.writeULEB128(writer, @as(u32, 1)); |
| 707 | 707 | // Can we maybe get the source index of the return type? |
| 708 | 708 | const val_type = try self.genValtype(.{ .node_offset = 0 }, return_type); |
| ... | ... | @@ -721,7 +721,7 @@ pub const Context = struct { |
| 721 | 721 | // TODO: check for and handle death of instructions |
| 722 | 722 | const mod_fn = blk: { |
| 723 | 723 | if (typed_value.val.castTag(.function)) |func| break :blk func.data; |
| 724 | if (typed_value.val.castTag(.extern_fn)) |ext_fn| return Result.appended; // don't need code body for extern functions | |
| 724 | if (typed_value.val.castTag(.extern_fn)) |_| return Result.appended; // don't need code body for extern functions | |
| 725 | 725 | unreachable; |
| 726 | 726 | }; |
| 727 | 727 | |
| ... | ... | @@ -849,7 +849,6 @@ pub const Context = struct { |
| 849 | 849 | } |
| 850 | 850 | |
| 851 | 851 | fn genCall(self: *Context, inst: *Inst.Call) InnerError!WValue { |
| 852 | const func_inst = inst.func.castTag(.constant).?; | |
| 853 | 852 | const func_val = inst.func.value().?; |
| 854 | 853 | |
| 855 | 854 | const target: *Decl = blk: { |
| ... | ... | @@ -914,7 +913,7 @@ pub const Context = struct { |
| 914 | 913 | .local => |local| { |
| 915 | 914 | try self.emitWValue(rhs); |
| 916 | 915 | try writer.writeByte(wasm.opcode(.local_set)); |
| 917 | try leb.writeULEB128(writer, lhs.local); | |
| 916 | try leb.writeULEB128(writer, local); | |
| 918 | 917 | }, |
| 919 | 918 | else => unreachable, |
| 920 | 919 | } |
| ... | ... | @@ -926,6 +925,7 @@ pub const Context = struct { |
| 926 | 925 | } |
| 927 | 926 | |
| 928 | 927 | fn genArg(self: *Context, inst: *Inst.Arg) InnerError!WValue { |
| 928 | _ = inst; | |
| 929 | 929 | // arguments share the index with locals |
| 930 | 930 | defer self.local_index += 1; |
| 931 | 931 | return WValue{ .local = self.local_index }; |
| ... | ... | @@ -1146,8 +1146,6 @@ pub const Context = struct { |
| 1146 | 1146 | } |
| 1147 | 1147 | |
| 1148 | 1148 | fn genCmp(self: *Context, inst: *Inst.BinOp, op: std.math.CompareOperator) InnerError!WValue { |
| 1149 | const ty = inst.lhs.ty.tag(); | |
| 1150 | ||
| 1151 | 1149 | // save offset, so potential conditions can insert blocks in front of |
| 1152 | 1150 | // the comparison that we can later jump back to |
| 1153 | 1151 | const offset = self.code.items.len; |
| ... | ... | @@ -1216,12 +1214,15 @@ pub const Context = struct { |
| 1216 | 1214 | } |
| 1217 | 1215 | |
| 1218 | 1216 | fn genBreakpoint(self: *Context, breakpoint: *Inst.NoOp) InnerError!WValue { |
| 1217 | _ = self; | |
| 1218 | _ = breakpoint; | |
| 1219 | 1219 | // unsupported by wasm itself. Can be implemented once we support DWARF |
| 1220 | 1220 | // for wasm |
| 1221 | 1221 | return .none; |
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | 1224 | fn genUnreachable(self: *Context, unreach: *Inst.NoOp) InnerError!WValue { |
| 1225 | _ = unreach; | |
| 1225 | 1226 | try self.code.append(wasm.opcode(.@"unreachable")); |
| 1226 | 1227 | return .none; |
| 1227 | 1228 | } |
src/glibc.zig-1| ... | ... | @@ -497,7 +497,6 @@ fn add_include_dirs(comp: *Compilation, arena: *Allocator, args: *std.ArrayList( |
| 497 | 497 | const target = comp.getTarget(); |
| 498 | 498 | const arch = target.cpu.arch; |
| 499 | 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"); | |
| 501 | 500 | |
| 502 | 501 | const s = path.sep_str; |
| 503 | 502 |
src/link.zig+1-1| ... | ... | @@ -517,7 +517,7 @@ pub const File = struct { |
| 517 | 517 | .target = base.options.target, |
| 518 | 518 | .output_mode = .Obj, |
| 519 | 519 | }); |
| 520 | const o_directory = base.options.module.?.zig_cache_artifact_directory; | |
| 520 | const o_directory = module.zig_cache_artifact_directory; | |
| 521 | 521 | const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename}); |
| 522 | 522 | break :blk full_obj_path; |
| 523 | 523 | } |
src/link/C.zig+10-2| ... | ... | @@ -76,7 +76,10 @@ pub fn deinit(self: *C) void { |
| 76 | 76 | self.decl_table.deinit(self.base.allocator); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | pub fn allocateDeclIndexes(self: *C, decl: *Module.Decl) !void {} | |
| 79 | pub fn allocateDeclIndexes(self: *C, decl: *Module.Decl) !void { | |
| 80 | _ = self; | |
| 81 | _ = decl; | |
| 82 | } | |
| 80 | 83 | |
| 81 | 84 | pub fn freeDecl(self: *C, decl: *Module.Decl) void { |
| 82 | 85 | _ = self.decl_table.swapRemove(decl); |
| ... | ... | @@ -307,4 +310,9 @@ pub fn updateDeclExports( |
| 307 | 310 | module: *Module, |
| 308 | 311 | decl: *Module.Decl, |
| 309 | 312 | exports: []const *Module.Export, |
| 310 | ) !void {} | |
| 313 | ) !void { | |
| 314 | _ = exports; | |
| 315 | _ = decl; | |
| 316 | _ = module; | |
| 317 | _ = self; | |
| 318 | } |
src/link/Coff.zig+4-1| ... | ... | @@ -831,7 +831,7 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void { |
| 831 | 831 | .target = self.base.options.target, |
| 832 | 832 | .output_mode = .Obj, |
| 833 | 833 | }); |
| 834 | const o_directory = self.base.options.module.?.zig_cache_artifact_directory; | |
| 834 | const o_directory = module.zig_cache_artifact_directory; | |
| 835 | 835 | const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename}); |
| 836 | 836 | break :blk full_obj_path; |
| 837 | 837 | } |
| ... | ... | @@ -1340,6 +1340,9 @@ pub fn getDeclVAddr(self: *Coff, decl: *const Module.Decl) u64 { |
| 1340 | 1340 | } |
| 1341 | 1341 | |
| 1342 | 1342 | pub fn updateDeclLineNumber(self: *Coff, module: *Module, decl: *Module.Decl) !void { |
| 1343 | _ = self; | |
| 1344 | _ = module; | |
| 1345 | _ = decl; | |
| 1343 | 1346 | // TODO Implement this |
| 1344 | 1347 | } |
| 1345 | 1348 |
src/link/Elf.zig+8-3| ... | ... | @@ -1262,7 +1262,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { |
| 1262 | 1262 | .target = self.base.options.target, |
| 1263 | 1263 | .output_mode = .Obj, |
| 1264 | 1264 | }); |
| 1265 | const o_directory = self.base.options.module.?.zig_cache_artifact_directory; | |
| 1265 | const o_directory = module.zig_cache_artifact_directory; | |
| 1266 | 1266 | const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename}); |
| 1267 | 1267 | break :blk full_obj_path; |
| 1268 | 1268 | } |
| ... | ... | @@ -1938,6 +1938,9 @@ fn freeTextBlock(self: *Elf, text_block: *TextBlock) void { |
| 1938 | 1938 | } |
| 1939 | 1939 | |
| 1940 | 1940 | fn shrinkTextBlock(self: *Elf, text_block: *TextBlock, new_block_size: u64) void { |
| 1941 | _ = self; | |
| 1942 | _ = text_block; | |
| 1943 | _ = new_block_size; | |
| 1941 | 1944 | // TODO check the new capacity, and if it crosses the size threshold into a big enough |
| 1942 | 1945 | // capacity, insert a free list node for it. |
| 1943 | 1946 | } |
| ... | ... | @@ -2706,6 +2709,7 @@ pub fn updateDeclExports( |
| 2706 | 2709 | |
| 2707 | 2710 | /// Must be called only after a successful call to `updateDecl`. |
| 2708 | 2711 | pub fn updateDeclLineNumber(self: *Elf, module: *Module, decl: *const Module.Decl) !void { |
| 2712 | _ = module; | |
| 2709 | 2713 | const tracy = trace(@src()); |
| 2710 | 2714 | defer tracy.end(); |
| 2711 | 2715 | |
| ... | ... | @@ -2979,6 +2983,7 @@ fn dbgLineNeededHeaderBytes(self: Elf) u32 { |
| 2979 | 2983 | } |
| 2980 | 2984 | |
| 2981 | 2985 | fn dbgInfoNeededHeaderBytes(self: Elf) u32 { |
| 2986 | _ = self; | |
| 2982 | 2987 | return 120; |
| 2983 | 2988 | } |
| 2984 | 2989 | |
| ... | ... | @@ -3372,7 +3377,7 @@ const CsuObjects = struct { |
| 3372 | 3377 | if (result.crtend) |*obj| obj.* = try fs.path.join(arena, &[_][]const u8{ gcc_dir_path, obj.* }); |
| 3373 | 3378 | }, |
| 3374 | 3379 | else => { |
| 3375 | inline for (std.meta.fields(@TypeOf(result))) |f, i| { | |
| 3380 | inline for (std.meta.fields(@TypeOf(result))) |f| { | |
| 3376 | 3381 | if (@field(result, f.name)) |*obj| { |
| 3377 | 3382 | obj.* = try fs.path.join(arena, &[_][]const u8{ crt_dir_path, obj.* }); |
| 3378 | 3383 | } |
| ... | ... | @@ -3380,7 +3385,7 @@ const CsuObjects = struct { |
| 3380 | 3385 | }, |
| 3381 | 3386 | } |
| 3382 | 3387 | } else { |
| 3383 | inline for (std.meta.fields(@TypeOf(result))) |f, i| { | |
| 3388 | inline for (std.meta.fields(@TypeOf(result))) |f| { | |
| 3384 | 3389 | if (@field(result, f.name)) |*obj| { |
| 3385 | 3390 | if (comp.crt_files.get(obj.*)) |crtf| { |
| 3386 | 3391 | obj.* = crtf.full_object_path; |
src/link/MachO.zig+5-4| ... | ... | @@ -441,6 +441,7 @@ pub fn flush(self: *MachO, comp: *Compilation) !void { |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | pub fn flushModule(self: *MachO, comp: *Compilation) !void { |
| 444 | _ = comp; | |
| 444 | 445 | const tracy = trace(@src()); |
| 445 | 446 | defer tracy.end(); |
| 446 | 447 | |
| ... | ... | @@ -533,7 +534,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { |
| 533 | 534 | .target = self.base.options.target, |
| 534 | 535 | .output_mode = .Obj, |
| 535 | 536 | }); |
| 536 | const o_directory = self.base.options.module.?.zig_cache_artifact_directory; | |
| 537 | const o_directory = module.zig_cache_artifact_directory; | |
| 537 | 538 | const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename}); |
| 538 | 539 | break :blk full_obj_path; |
| 539 | 540 | } |
| ... | ... | @@ -1254,6 +1255,9 @@ fn freeTextBlock(self: *MachO, text_block: *TextBlock) void { |
| 1254 | 1255 | } |
| 1255 | 1256 | |
| 1256 | 1257 | fn shrinkTextBlock(self: *MachO, text_block: *TextBlock, new_block_size: u64) void { |
| 1258 | _ = self; | |
| 1259 | _ = text_block; | |
| 1260 | _ = new_block_size; | |
| 1257 | 1261 | // TODO check the new capacity, and if it crosses the size threshold into a big enough |
| 1258 | 1262 | // capacity, insert a free list node for it. |
| 1259 | 1263 | } |
| ... | ... | @@ -2918,7 +2922,6 @@ fn relocateSymbolTable(self: *MachO) !void { |
| 2918 | 2922 | const nsyms = nlocals + nglobals + nundefs; |
| 2919 | 2923 | |
| 2920 | 2924 | if (symtab.nsyms < nsyms) { |
| 2921 | const linkedit_segment = self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment; | |
| 2922 | 2925 | const needed_size = nsyms * @sizeOf(macho.nlist_64); |
| 2923 | 2926 | if (needed_size > self.allocatedSizeLinkedit(symtab.symoff)) { |
| 2924 | 2927 | // Move the entire symbol table to a new location |
| ... | ... | @@ -3150,7 +3153,6 @@ fn writeExportTrie(self: *MachO) !void { |
| 3150 | 3153 | const nwritten = try trie.write(stream.writer()); |
| 3151 | 3154 | assert(nwritten == trie.size); |
| 3152 | 3155 | |
| 3153 | const linkedit_segment = self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment; | |
| 3154 | 3156 | const dyld_info = &self.load_commands.items[self.dyld_info_cmd_index.?].DyldInfoOnly; |
| 3155 | 3157 | const allocated_size = self.allocatedSizeLinkedit(dyld_info.export_off); |
| 3156 | 3158 | const needed_size = mem.alignForwardGeneric(u64, buffer.len, @alignOf(u64)); |
| ... | ... | @@ -3357,7 +3359,6 @@ fn populateLazyBindOffsetsInStubHelper(self: *MachO, buffer: []const u8) !void { |
| 3357 | 3359 | error.EndOfStream => break, |
| 3358 | 3360 | else => return err, |
| 3359 | 3361 | }; |
| 3360 | const imm: u8 = inst & macho.BIND_IMMEDIATE_MASK; | |
| 3361 | 3362 | const opcode: u8 = inst & macho.BIND_OPCODE_MASK; |
| 3362 | 3363 | |
| 3363 | 3364 | switch (opcode) { |
src/link/MachO/DebugSymbols.zig+6-7| ... | ... | @@ -500,7 +500,6 @@ pub fn flushModule(self: *DebugSymbols, allocator: *Allocator, options: link.Opt |
| 500 | 500 | if (self.debug_aranges_section_dirty) { |
| 501 | 501 | const dwarf_segment = &self.load_commands.items[self.dwarf_segment_cmd_index.?].Segment; |
| 502 | 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.?]; | |
| 504 | 503 | |
| 505 | 504 | var di_buf = std.ArrayList(u8).init(allocator); |
| 506 | 505 | defer di_buf.deinit(); |
| ... | ... | @@ -844,7 +843,6 @@ fn relocateSymbolTable(self: *DebugSymbols) !void { |
| 844 | 843 | const nsyms = nlocals + nglobals; |
| 845 | 844 | |
| 846 | 845 | if (symtab.nsyms < nsyms) { |
| 847 | const linkedit_segment = self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment; | |
| 848 | 846 | const needed_size = nsyms * @sizeOf(macho.nlist_64); |
| 849 | 847 | if (needed_size > self.allocatedSizeLinkedit(symtab.symoff)) { |
| 850 | 848 | // Move the entire symbol table to a new location |
| ... | ... | @@ -901,14 +899,10 @@ fn writeStringTable(self: *DebugSymbols) !void { |
| 901 | 899 | } |
| 902 | 900 | |
| 903 | 901 | pub fn updateDeclLineNumber(self: *DebugSymbols, module: *Module, decl: *const Module.Decl) !void { |
| 902 | _ = module; | |
| 904 | 903 | const tracy = trace(@src()); |
| 905 | 904 | defer tracy.end(); |
| 906 | 905 | |
| 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 | 906 | const func = decl.val.castTag(.function).?.data; |
| 913 | 907 | const line_off = @intCast(u28, decl.src_line + func.lbrace_line); |
| 914 | 908 | |
| ... | ... | @@ -933,6 +927,8 @@ pub fn initDeclDebugBuffers( |
| 933 | 927 | module: *Module, |
| 934 | 928 | decl: *Module.Decl, |
| 935 | 929 | ) !DeclDebugBuffers { |
| 930 | _ = self; | |
| 931 | _ = module; | |
| 936 | 932 | const tracy = trace(@src()); |
| 937 | 933 | defer tracy.end(); |
| 938 | 934 | |
| ... | ... | @@ -1195,6 +1191,7 @@ fn addDbgInfoType( |
| 1195 | 1191 | dbg_info_buffer: *std.ArrayList(u8), |
| 1196 | 1192 | target: std.Target, |
| 1197 | 1193 | ) !void { |
| 1194 | _ = self; | |
| 1198 | 1195 | switch (ty.zigTypeTag()) { |
| 1199 | 1196 | .Void => unreachable, |
| 1200 | 1197 | .NoReturn => unreachable, |
| ... | ... | @@ -1371,6 +1368,7 @@ fn getRelocDbgInfoSubprogramHighPC() u32 { |
| 1371 | 1368 | } |
| 1372 | 1369 | |
| 1373 | 1370 | fn dbgLineNeededHeaderBytes(self: DebugSymbols, module: *Module) u32 { |
| 1371 | _ = self; | |
| 1374 | 1372 | const directory_entry_format_count = 1; |
| 1375 | 1373 | const file_name_entry_format_count = 1; |
| 1376 | 1374 | const directory_count = 1; |
| ... | ... | @@ -1385,6 +1383,7 @@ fn dbgLineNeededHeaderBytes(self: DebugSymbols, module: *Module) u32 { |
| 1385 | 1383 | } |
| 1386 | 1384 | |
| 1387 | 1385 | fn dbgInfoNeededHeaderBytes(self: DebugSymbols) u32 { |
| 1386 | _ = self; | |
| 1388 | 1387 | return 120; |
| 1389 | 1388 | } |
| 1390 | 1389 |
src/link/MachO/Object.zig-1| ... | ... | @@ -478,7 +478,6 @@ pub fn parseDebugInfo(self: *Object) !void { |
| 478 | 478 | |
| 479 | 479 | self.tu_path = try std.fs.path.join(self.allocator, &[_][]const u8{ comp_dir, name }); |
| 480 | 480 | self.tu_mtime = mtime: { |
| 481 | var buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 482 | 481 | const stat = try self.file.?.stat(); |
| 483 | 482 | break :mtime @intCast(u64, @divFloor(stat.mtime, 1_000_000_000)); |
| 484 | 483 | }; |
src/link/MachO/Zld.zig+5-8| ... | ... | @@ -108,6 +108,7 @@ const TlvOffset = struct { |
| 108 | 108 | offset: u64, |
| 109 | 109 | |
| 110 | 110 | fn cmp(context: void, a: TlvOffset, b: TlvOffset) bool { |
| 111 | _ = context; | |
| 111 | 112 | return a.source_addr < b.source_addr; |
| 112 | 113 | } |
| 113 | 114 | }; |
| ... | ... | @@ -432,13 +433,12 @@ fn mapAndUpdateSections( |
| 432 | 433 | |
| 433 | 434 | fn updateMetadata(self: *Zld) !void { |
| 434 | 435 | for (self.objects.items) |object| { |
| 435 | const object_seg = object.load_commands.items[object.segment_cmd_index.?].Segment; | |
| 436 | 436 | const text_seg = &self.load_commands.items[self.text_segment_cmd_index.?].Segment; |
| 437 | 437 | const data_const_seg = &self.load_commands.items[self.data_const_segment_cmd_index.?].Segment; |
| 438 | 438 | const data_seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment; |
| 439 | 439 | |
| 440 | 440 | // Create missing metadata |
| 441 | for (object.sections.items) |sect, sect_id| { | |
| 441 | for (object.sections.items) |sect| { | |
| 442 | 442 | const segname = sect.segname(); |
| 443 | 443 | const sectname = sect.sectname(); |
| 444 | 444 | |
| ... | ... | @@ -1294,7 +1294,6 @@ fn allocateLinkeditSegment(self: *Zld) void { |
| 1294 | 1294 | } |
| 1295 | 1295 | |
| 1296 | 1296 | fn 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 | 1297 | const seg = &self.load_commands.items[index].Segment; |
| 1299 | 1298 | |
| 1300 | 1299 | // Allocate the sections according to their alignment at the beginning of the segment. |
| ... | ... | @@ -1375,7 +1374,7 @@ fn allocateTentativeSymbols(self: *Zld) !void { |
| 1375 | 1374 | } |
| 1376 | 1375 | |
| 1377 | 1376 | // Convert tentative definitions into regular symbols. |
| 1378 | for (self.tentatives.values()) |sym, i| { | |
| 1377 | for (self.tentatives.values()) |sym| { | |
| 1379 | 1378 | const tent = sym.cast(Symbol.Tentative) orelse unreachable; |
| 1380 | 1379 | const reg = try self.allocator.create(Symbol.Regular); |
| 1381 | 1380 | errdefer self.allocator.destroy(reg); |
| ... | ... | @@ -1427,7 +1426,6 @@ fn writeStubHelperCommon(self: *Zld) !void { |
| 1427 | 1426 | const got = &data_const_segment.sections.items[self.got_section_index.?]; |
| 1428 | 1427 | const data_segment = &self.load_commands.items[self.data_segment_cmd_index.?].Segment; |
| 1429 | 1428 | 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.?]; | |
| 1431 | 1429 | |
| 1432 | 1430 | self.stub_helper_stubs_start_off = blk: { |
| 1433 | 1431 | switch (self.arch.?) { |
| ... | ... | @@ -1761,7 +1759,7 @@ fn resolveSymbolsInObject(self: *Zld, object: *Object) !void { |
| 1761 | 1759 | |
| 1762 | 1760 | t_sym.alias = sym; |
| 1763 | 1761 | sym_ptr.* = sym; |
| 1764 | } else if (sym.cast(Symbol.Unresolved)) |und| { | |
| 1762 | } else if (sym.cast(Symbol.Unresolved)) |_| { | |
| 1765 | 1763 | if (self.globals.get(sym.name)) |g_sym| { |
| 1766 | 1764 | sym.alias = g_sym; |
| 1767 | 1765 | continue; |
| ... | ... | @@ -2654,7 +2652,6 @@ fn setEntryPoint(self: *Zld) !void { |
| 2654 | 2652 | // TODO we should respect the -entry flag passed in by the user to set a custom |
| 2655 | 2653 | // entrypoint. For now, assume default of `_main`. |
| 2656 | 2654 | const seg = self.load_commands.items[self.text_segment_cmd_index.?].Segment; |
| 2657 | const text = seg.sections.items[self.text_section_index.?]; | |
| 2658 | 2655 | const sym = self.globals.get("_main") orelse return error.MissingMainEntrypoint; |
| 2659 | 2656 | const entry_sym = sym.cast(Symbol.Regular) orelse unreachable; |
| 2660 | 2657 | const ec = &self.load_commands.items[self.main_cmd_index.?].Main; |
| ... | ... | @@ -2862,7 +2859,6 @@ fn populateLazyBindOffsetsInStubHelper(self: *Zld, buffer: []const u8) !void { |
| 2862 | 2859 | error.EndOfStream => break, |
| 2863 | 2860 | else => return err, |
| 2864 | 2861 | }; |
| 2865 | const imm: u8 = inst & macho.BIND_IMMEDIATE_MASK; | |
| 2866 | 2862 | const opcode: u8 = inst & macho.BIND_OPCODE_MASK; |
| 2867 | 2863 | |
| 2868 | 2864 | switch (opcode) { |
| ... | ... | @@ -2959,6 +2955,7 @@ fn writeDebugInfo(self: *Zld) !void { |
| 2959 | 2955 | for (self.objects.items) |object| { |
| 2960 | 2956 | const tu_path = object.tu_path orelse continue; |
| 2961 | 2957 | const tu_mtime = object.tu_mtime orelse continue; |
| 2958 | _ = tu_mtime; | |
| 2962 | 2959 | const dirname = std.fs.path.dirname(tu_path) orelse "./"; |
| 2963 | 2960 | // Current dir |
| 2964 | 2961 | try stabs.append(.{ |
src/link/MachO/bind.zig+1| ... | ... | @@ -10,6 +10,7 @@ pub const Pointer = struct { |
| 10 | 10 | }; |
| 11 | 11 | |
| 12 | 12 | pub fn pointerCmp(context: void, a: Pointer, b: Pointer) bool { |
| 13 | _ = context; | |
| 13 | 14 | if (a.segment_id < b.segment_id) return true; |
| 14 | 15 | if (a.segment_id == b.segment_id) { |
| 15 | 16 | return a.offset < b.offset; |
src/link/MachO/reloc/x86_64.zig-1| ... | ... | @@ -175,7 +175,6 @@ pub const Parser = struct { |
| 175 | 175 | |
| 176 | 176 | const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type); |
| 177 | 177 | const target = Relocation.Target.from_reloc(rel, parser.symbols); |
| 178 | const is_extern = rel.r_extern == 1; | |
| 179 | 178 | |
| 180 | 179 | const offset = @intCast(u32, rel.r_address); |
| 181 | 180 | const inst = parser.code[offset..][0..4]; |
src/link/SpirV.zig+7-1| ... | ... | @@ -102,6 +102,7 @@ pub fn deinit(self: *SpirV) void { |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | pub fn updateDecl(self: *SpirV, module: *Module, decl: *Module.Decl) !void { |
| 105 | _ = module; | |
| 105 | 106 | // Keep track of all decls so we can iterate over them on flush(). |
| 106 | 107 | _ = try self.decl_table.getOrPut(self.base.allocator, decl); |
| 107 | 108 | } |
| ... | ... | @@ -111,7 +112,12 @@ pub fn updateDeclExports( |
| 111 | 112 | module: *Module, |
| 112 | 113 | decl: *const Module.Decl, |
| 113 | 114 | exports: []const *Module.Export, |
| 114 | ) !void {} | |
| 115 | ) !void { | |
| 116 | _ = self; | |
| 117 | _ = module; | |
| 118 | _ = decl; | |
| 119 | _ = exports; | |
| 120 | } | |
| 115 | 121 | |
| 116 | 122 | pub fn freeDecl(self: *SpirV, decl: *Module.Decl) void { |
| 117 | 123 | assert(self.decl_table.swapRemove(decl)); |
src/link/Wasm.zig+9-4| ... | ... | @@ -216,7 +216,7 @@ pub fn updateDecl(self: *Wasm, module: *Module, decl: *Module.Decl) !void { |
| 216 | 216 | try module.failed_decls.put(module.gpa, decl, context.err_msg); |
| 217 | 217 | return; |
| 218 | 218 | }, |
| 219 | else => |e| return err, | |
| 219 | else => |e| return e, | |
| 220 | 220 | }; |
| 221 | 221 | |
| 222 | 222 | const code: []const u8 = switch (result) { |
| ... | ... | @@ -258,7 +258,12 @@ pub fn updateDeclExports( |
| 258 | 258 | module: *Module, |
| 259 | 259 | decl: *const Module.Decl, |
| 260 | 260 | exports: []const *Module.Export, |
| 261 | ) !void {} | |
| 261 | ) !void { | |
| 262 | _ = self; | |
| 263 | _ = module; | |
| 264 | _ = decl; | |
| 265 | _ = exports; | |
| 266 | } | |
| 262 | 267 | |
| 263 | 268 | pub fn freeDecl(self: *Wasm, decl: *Module.Decl) void { |
| 264 | 269 | if (self.getFuncidx(decl)) |func_idx| { |
| ... | ... | @@ -300,6 +305,7 @@ pub fn flush(self: *Wasm, comp: *Compilation) !void { |
| 300 | 305 | } |
| 301 | 306 | |
| 302 | 307 | pub fn flushModule(self: *Wasm, comp: *Compilation) !void { |
| 308 | _ = comp; | |
| 303 | 309 | const tracy = trace(@src()); |
| 304 | 310 | defer tracy.end(); |
| 305 | 311 | |
| ... | ... | @@ -496,7 +502,6 @@ pub fn flushModule(self: *Wasm, comp: *Compilation) !void { |
| 496 | 502 | if (data_size != 0) { |
| 497 | 503 | const header_offset = try reserveVecSectionHeader(file); |
| 498 | 504 | const writer = file.writer(); |
| 499 | var len: u32 = 0; | |
| 500 | 505 | // index to memory section (currently, there can only be 1 memory section in wasm) |
| 501 | 506 | try leb.writeULEB128(writer, @as(u32, 0)); |
| 502 | 507 | |
| ... | ... | @@ -558,7 +563,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { |
| 558 | 563 | .target = self.base.options.target, |
| 559 | 564 | .output_mode = .Obj, |
| 560 | 565 | }); |
| 561 | const o_directory = self.base.options.module.?.zig_cache_artifact_directory; | |
| 566 | const o_directory = module.zig_cache_artifact_directory; | |
| 562 | 567 | const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename}); |
| 563 | 568 | break :blk full_obj_path; |
| 564 | 569 | } |
src/main.zig+2-2| ... | ... | @@ -500,7 +500,7 @@ const Emit = union(enum) { |
| 500 | 500 | }; |
| 501 | 501 | |
| 502 | 502 | fn optionalBoolEnvVar(arena: *Allocator, name: []const u8) !bool { |
| 503 | if (std.process.getEnvVarOwned(arena, name)) |value| { | |
| 503 | if (std.process.getEnvVarOwned(arena, name)) |_| { | |
| 504 | 504 | return true; |
| 505 | 505 | } else |err| switch (err) { |
| 506 | 506 | error.EnvironmentVariableNotFound => return false, |
| ... | ... | @@ -2565,6 +2565,7 @@ pub fn cmdInit( |
| 2565 | 2565 | args: []const []const u8, |
| 2566 | 2566 | output_mode: std.builtin.OutputMode, |
| 2567 | 2567 | ) !void { |
| 2568 | _ = gpa; | |
| 2568 | 2569 | { |
| 2569 | 2570 | var i: usize = 0; |
| 2570 | 2571 | while (i < args.len) : (i += 1) { |
| ... | ... | @@ -3749,7 +3750,6 @@ pub fn cmdAstCheck( |
| 3749 | 3750 | |
| 3750 | 3751 | var color: Color = .auto; |
| 3751 | 3752 | var want_output_text = false; |
| 3752 | var have_zig_source_file = false; | |
| 3753 | 3753 | var zig_source_file: ?[]const u8 = null; |
| 3754 | 3754 | |
| 3755 | 3755 | var i: usize = 0; |
src/mingw.zig-2| ... | ... | @@ -372,11 +372,9 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void { |
| 372 | 372 | |
| 373 | 373 | try child.spawn(); |
| 374 | 374 | |
| 375 | const stdout_reader = child.stdout.?.reader(); | |
| 376 | 375 | const stderr_reader = child.stderr.?.reader(); |
| 377 | 376 | |
| 378 | 377 | // TODO https://github.com/ziglang/zig/issues/6343 |
| 379 | const stdout = try stdout_reader.readAllAlloc(arena, std.math.maxInt(u32)); | |
| 380 | 378 | const stderr = try stderr_reader.readAllAlloc(arena, 10 * 1024 * 1024); |
| 381 | 379 | |
| 382 | 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 | 143 | const dirname = path.dirname(src_file).?; |
| 144 | 144 | const basename = path.basename(src_file); |
| 145 | 145 | const noextbasename = basename[0 .. basename.len - std.fs.path.extension(basename).len]; |
| 146 | const before_arch_dir = path.dirname(dirname).?; | |
| 147 | 146 | const dirbasename = path.basename(dirname); |
| 148 | 147 | |
| 149 | 148 | var is_arch_specific = false; |
src/print_env.zig+1| ... | ... | @@ -5,6 +5,7 @@ const Allocator = std.mem.Allocator; |
| 5 | 5 | const fatal = @import("main.zig").fatal; |
| 6 | 6 | |
| 7 | 7 | pub fn cmdEnv(gpa: *Allocator, args: []const []const u8, stdout: std.fs.File.Writer) !void { |
| 8 | _ = args; | |
| 8 | 9 | const self_exe_path = try std.fs.selfExePathAlloc(gpa); |
| 9 | 10 | defer gpa.free(self_exe_path); |
| 10 | 11 |
src/print_targets.zig+1| ... | ... | @@ -17,6 +17,7 @@ pub fn cmdTargets( |
| 17 | 17 | stdout: anytype, |
| 18 | 18 | native_target: Target, |
| 19 | 19 | ) !void { |
| 20 | _ = args; | |
| 20 | 21 | var zig_lib_directory = introspect.findZigLibDir(allocator) catch |err| { |
| 21 | 22 | fatal("unable to find zig installation directory: {s}\n", .{@errorName(err)}); |
| 22 | 23 | }; |
src/register_manager.zig+2-12| ... | ... | @@ -265,6 +265,8 @@ fn MockFunction(comptime Register: type) type { |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | pub fn spillInstruction(self: *Self, src: LazySrcLoc, reg: Register, inst: *ir.Inst) !void { |
| 268 | _ = src; | |
| 269 | _ = inst; | |
| 268 | 270 | try self.spilled.append(self.allocator, reg); |
| 269 | 271 | } |
| 270 | 272 | }; |
| ... | ... | @@ -281,12 +283,6 @@ test "default state" { |
| 281 | 283 | }; |
| 282 | 284 | defer function.deinit(); |
| 283 | 285 | |
| 284 | var mock_instruction = ir.Inst{ | |
| 285 | .tag = .breakpoint, | |
| 286 | .ty = Type.initTag(.void), | |
| 287 | .src = .unneeded, | |
| 288 | }; | |
| 289 | ||
| 290 | 286 | try expect(!function.register_manager.isRegAllocated(.r2)); |
| 291 | 287 | try expect(!function.register_manager.isRegAllocated(.r3)); |
| 292 | 288 | try expect(function.register_manager.isRegFree(.r2)); |
| ... | ... | @@ -365,12 +361,6 @@ test "tryAllocRegs" { |
| 365 | 361 | }; |
| 366 | 362 | defer function.deinit(); |
| 367 | 363 | |
| 368 | var mock_instruction = ir.Inst{ | |
| 369 | .tag = .breakpoint, | |
| 370 | .ty = Type.initTag(.void), | |
| 371 | .src = .unneeded, | |
| 372 | }; | |
| 373 | ||
| 374 | 364 | try expectEqual([_]MockRegister2{ .r0, .r1, .r2 }, function.register_manager.tryAllocRegs(3, .{ null, null, null }, &.{}).?); |
| 375 | 365 | |
| 376 | 366 | // Exceptions |
src/stage1.zig+2| ... | ... | @@ -407,6 +407,8 @@ export fn stage2_add_link_lib( |
| 407 | 407 | symbol_name_ptr: [*c]const u8, |
| 408 | 408 | symbol_name_len: usize, |
| 409 | 409 | ) ?[*:0]const u8 { |
| 410 | _ = symbol_name_len; | |
| 411 | _ = symbol_name_ptr; | |
| 410 | 412 | const comp = @intToPtr(*Compilation, stage1.userdata); |
| 411 | 413 | const lib_name = std.ascii.allocLowerString(comp.gpa, lib_name_ptr[0..lib_name_len]) catch return "out of memory"; |
| 412 | 414 | const target = comp.getTarget(); |
src/test.zig+3| ... | ... | @@ -70,6 +70,8 @@ const ErrorMsg = union(enum) { |
| 70 | 70 | options: std.fmt.FormatOptions, |
| 71 | 71 | writer: anytype, |
| 72 | 72 | ) !void { |
| 73 | _ = fmt; | |
| 74 | _ = options; | |
| 73 | 75 | switch (self) { |
| 74 | 76 | .src => |src| { |
| 75 | 77 | return writer.print("{s}:{d}:{d}: {s}: {s}", .{ |
| ... | ... | @@ -592,6 +594,7 @@ pub const TestContext = struct { |
| 592 | 594 | thread_pool: *ThreadPool, |
| 593 | 595 | global_cache_directory: Compilation.Directory, |
| 594 | 596 | ) !void { |
| 597 | _ = self; | |
| 595 | 598 | const target_info = try std.zig.system.NativeTargetInfo.detect(allocator, case.target); |
| 596 | 599 | const target = target_info.target; |
| 597 | 600 |
src/tracy.zig+3-1| ... | ... | @@ -28,7 +28,9 @@ pub const ___tracy_c_zone_context = extern struct { |
| 28 | 28 | }; |
| 29 | 29 | |
| 30 | 30 | pub const Ctx = if (enable) ___tracy_c_zone_context else struct { |
| 31 | pub fn end(self: Ctx) void {} | |
| 31 | pub fn end(self: Ctx) void { | |
| 32 | _ = self; | |
| 33 | } | |
| 32 | 34 | }; |
| 33 | 35 | |
| 34 | 36 | pub inline fn trace(comptime src: std.builtin.SourceLocation) Ctx { |
src/translate_c.zig+15-9| ... | ... | @@ -206,6 +206,7 @@ const Scope = struct { |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | fn findBlockReturnType(inner: *Scope, c: *Context) clang.QualType { |
| 209 | _ = c; | |
| 209 | 210 | var scope = inner; |
| 210 | 211 | while (true) { |
| 211 | 212 | switch (scope.id) { |
| ... | ... | @@ -601,7 +602,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const clang.FunctionDecl) Error!void { |
| 601 | 602 | var scope = &block_scope.base; |
| 602 | 603 | |
| 603 | 604 | var param_id: c_uint = 0; |
| 604 | for (proto_node.data.params) |*param, i| { | |
| 605 | for (proto_node.data.params) |*param| { | |
| 605 | 606 | const param_name = param.name orelse { |
| 606 | 607 | proto_node.data.is_extern = true; |
| 607 | 608 | proto_node.data.is_export = false; |
| ... | ... | @@ -785,7 +786,7 @@ const builtin_typedef_map = std.ComptimeStringMap([]const u8, .{ |
| 785 | 786 | }); |
| 786 | 787 | |
| 787 | 788 | fn transTypeDef(c: *Context, scope: *Scope, typedef_decl: *const clang.TypedefNameDecl) Error!void { |
| 788 | if (c.decl_table.get(@ptrToInt(typedef_decl.getCanonicalDecl()))) |name| | |
| 789 | if (c.decl_table.get(@ptrToInt(typedef_decl.getCanonicalDecl()))) |_| | |
| 789 | 790 | return; // Avoid processing this decl twice |
| 790 | 791 | const toplevel = scope.id == .root; |
| 791 | 792 | const bs: *Scope.Block = if (!toplevel) try scope.findBlockScope(c) else undefined; |
| ... | ... | @@ -935,7 +936,7 @@ fn hasFlexibleArrayField(c: *Context, record_def: *const clang.RecordDecl) bool |
| 935 | 936 | } |
| 936 | 937 | |
| 937 | 938 | fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordDecl) Error!void { |
| 938 | if (c.decl_table.get(@ptrToInt(record_decl.getCanonicalDecl()))) |name| | |
| 939 | if (c.decl_table.get(@ptrToInt(record_decl.getCanonicalDecl()))) |_| | |
| 939 | 940 | return; // Avoid processing this decl twice |
| 940 | 941 | const record_loc = record_decl.getLocation(); |
| 941 | 942 | const toplevel = scope.id == .root; |
| ... | ... | @@ -1080,7 +1081,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD |
| 1080 | 1081 | } |
| 1081 | 1082 | |
| 1082 | 1083 | fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const clang.EnumDecl) Error!void { |
| 1083 | if (c.decl_table.get(@ptrToInt(enum_decl.getCanonicalDecl()))) |name| | |
| 1084 | if (c.decl_table.get(@ptrToInt(enum_decl.getCanonicalDecl()))) |_| | |
| 1084 | 1085 | return; // Avoid processing this decl twice |
| 1085 | 1086 | const enum_loc = enum_decl.getLocation(); |
| 1086 | 1087 | const toplevel = scope.id == .root; |
| ... | ... | @@ -1312,6 +1313,7 @@ fn transConvertVectorExpr( |
| 1312 | 1313 | source_loc: clang.SourceLocation, |
| 1313 | 1314 | expr: *const clang.ConvertVectorExpr, |
| 1314 | 1315 | ) TransError!Node { |
| 1316 | _ = source_loc; | |
| 1315 | 1317 | const base_stmt = @ptrCast(*const clang.Stmt, expr); |
| 1316 | 1318 | |
| 1317 | 1319 | var block_scope = try Scope.Block.init(c, scope, true); |
| ... | ... | @@ -1321,7 +1323,6 @@ fn transConvertVectorExpr( |
| 1321 | 1323 | const src_type = qualTypeCanon(src_expr.getType()); |
| 1322 | 1324 | const src_vector_ty = @ptrCast(*const clang.VectorType, src_type); |
| 1323 | 1325 | 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()); | |
| 1325 | 1326 | |
| 1326 | 1327 | const src_expr_node = try transExpr(c, &block_scope.base, src_expr, .used); |
| 1327 | 1328 | |
| ... | ... | @@ -1434,6 +1435,7 @@ fn transSimpleOffsetOfExpr( |
| 1434 | 1435 | scope: *Scope, |
| 1435 | 1436 | expr: *const clang.OffsetOfExpr, |
| 1436 | 1437 | ) TransError!Node { |
| 1438 | _ = scope; | |
| 1437 | 1439 | assert(expr.getNumComponents() == 1); |
| 1438 | 1440 | const component = expr.getComponent(0); |
| 1439 | 1441 | if (component.getKind() == .Field) { |
| ... | ... | @@ -2270,6 +2272,7 @@ fn transStringLiteralInitializer( |
| 2270 | 2272 | /// both operands resolve to addresses. The C standard requires that both operands |
| 2271 | 2273 | /// point to elements of the same array object, but we do not verify that here. |
| 2272 | 2274 | fn cIsPointerDiffExpr(c: *Context, stmt: *const clang.BinaryOperator) bool { |
| 2275 | _ = c; | |
| 2273 | 2276 | const lhs = @ptrCast(*const clang.Stmt, stmt.getLHS()); |
| 2274 | 2277 | const rhs = @ptrCast(*const clang.Stmt, stmt.getRHS()); |
| 2275 | 2278 | return stmt.getOpcode() == .Sub and |
| ... | ... | @@ -2573,6 +2576,7 @@ fn transInitListExprVector( |
| 2573 | 2576 | expr: *const clang.InitListExpr, |
| 2574 | 2577 | ty: *const clang.Type, |
| 2575 | 2578 | ) TransError!Node { |
| 2579 | _ = ty; | |
| 2576 | 2580 | const qt = getExprQualType(c, @ptrCast(*const clang.Expr, expr)); |
| 2577 | 2581 | const vector_type = try transQualType(c, scope, qt, loc); |
| 2578 | 2582 | const init_count = expr.getNumInits(); |
| ... | ... | @@ -2722,6 +2726,7 @@ fn transImplicitValueInitExpr( |
| 2722 | 2726 | expr: *const clang.Expr, |
| 2723 | 2727 | used: ResultUsed, |
| 2724 | 2728 | ) TransError!Node { |
| 2729 | _ = used; | |
| 2725 | 2730 | const source_loc = expr.getBeginLoc(); |
| 2726 | 2731 | const qt = getExprQualType(c, expr); |
| 2727 | 2732 | const ty = qt.getTypePtr(); |
| ... | ... | @@ -3408,6 +3413,7 @@ fn transUnaryExprOrTypeTraitExpr( |
| 3408 | 3413 | stmt: *const clang.UnaryExprOrTypeTraitExpr, |
| 3409 | 3414 | result_used: ResultUsed, |
| 3410 | 3415 | ) TransError!Node { |
| 3416 | _ = result_used; | |
| 3411 | 3417 | const loc = stmt.getBeginLoc(); |
| 3412 | 3418 | const type_node = try transQualType(c, scope, stmt.getTypeOfArgument(), loc); |
| 3413 | 3419 | |
| ... | ... | @@ -3802,7 +3808,6 @@ fn transBinaryConditionalOperator(c: *Context, scope: *Scope, stmt: *const clang |
| 3802 | 3808 | const res_is_bool = qualTypeIsBoolean(qt); |
| 3803 | 3809 | const casted_stmt = @ptrCast(*const clang.AbstractConditionalOperator, stmt); |
| 3804 | 3810 | const cond_expr = casted_stmt.getCond(); |
| 3805 | const true_expr = casted_stmt.getTrueExpr(); | |
| 3806 | 3811 | const false_expr = casted_stmt.getFalseExpr(); |
| 3807 | 3812 | |
| 3808 | 3813 | // c: (cond_expr)?:(false_expr) |
| ... | ... | @@ -3895,6 +3900,7 @@ fn maybeSuppressResult( |
| 3895 | 3900 | used: ResultUsed, |
| 3896 | 3901 | result: Node, |
| 3897 | 3902 | ) TransError!Node { |
| 3903 | _ = scope; | |
| 3898 | 3904 | if (used == .used) return result; |
| 3899 | 3905 | return Tag.discard.create(c.arena, result); |
| 3900 | 3906 | } |
| ... | ... | @@ -4336,12 +4342,10 @@ fn transCreateNodeNumber(c: *Context, num: anytype, num_kind: enum { int, float |
| 4336 | 4342 | } |
| 4337 | 4343 | |
| 4338 | 4344 | fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: Node, proto_alias: *ast.Payload.Func) !Node { |
| 4339 | const scope = &c.global_scope.base; | |
| 4340 | ||
| 4341 | 4345 | var fn_params = std.ArrayList(ast.Payload.Param).init(c.gpa); |
| 4342 | 4346 | defer fn_params.deinit(); |
| 4343 | 4347 | |
| 4344 | for (proto_alias.data.params) |param, i| { | |
| 4348 | for (proto_alias.data.params) |param| { | |
| 4345 | 4349 | const param_name = param.name orelse |
| 4346 | 4350 | try std.fmt.allocPrint(c.arena, "arg_{d}", .{c.getMangle()}); |
| 4347 | 4351 | |
| ... | ... | @@ -5657,6 +5661,7 @@ fn parseCSpecifierQualifierList(c: *Context, m: *MacroCtx, scope: *Scope, allow_ |
| 5657 | 5661 | } |
| 5658 | 5662 | |
| 5659 | 5663 | fn parseCNumericType(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { |
| 5664 | _ = scope; | |
| 5660 | 5665 | const KwCounter = struct { |
| 5661 | 5666 | double: u8 = 0, |
| 5662 | 5667 | long: u8 = 0, |
| ... | ... | @@ -5758,6 +5763,7 @@ fn parseCNumericType(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { |
| 5758 | 5763 | } |
| 5759 | 5764 | |
| 5760 | 5765 | fn parseCAbstractDeclarator(c: *Context, m: *MacroCtx, scope: *Scope, node: Node) ParseError!Node { |
| 5766 | _ = scope; | |
| 5761 | 5767 | switch (m.next().?) { |
| 5762 | 5768 | .Asterisk => { |
| 5763 | 5769 | // last token of `node` |
src/type.zig+4-2| ... | ... | @@ -600,9 +600,11 @@ pub const Type = extern union { |
| 600 | 600 | |
| 601 | 601 | pub const HashContext = struct { |
| 602 | 602 | pub fn hash(self: @This(), t: Type) u64 { |
| 603 | _ = self; | |
| 603 | 604 | return t.hash(); |
| 604 | 605 | } |
| 605 | 606 | pub fn eql(self: @This(), a: Type, b: Type) bool { |
| 607 | _ = self; | |
| 606 | 608 | return a.eql(b); |
| 607 | 609 | } |
| 608 | 610 | }; |
| ... | ... | @@ -777,6 +779,7 @@ pub const Type = extern union { |
| 777 | 779 | options: std.fmt.FormatOptions, |
| 778 | 780 | writer: anytype, |
| 779 | 781 | ) @TypeOf(writer).Error!void { |
| 782 | _ = options; | |
| 780 | 783 | comptime assert(fmt.len == 0); |
| 781 | 784 | var ty = start_type; |
| 782 | 785 | while (true) { |
| ... | ... | @@ -3013,7 +3016,7 @@ pub const Type = extern union { |
| 3013 | 3016 | .base = .{ .tag = t }, |
| 3014 | 3017 | .data = data, |
| 3015 | 3018 | }; |
| 3016 | return Type{ .ptr_otherwise = &ptr.base }; | |
| 3019 | return file_struct.Type{ .ptr_otherwise = &ptr.base }; | |
| 3017 | 3020 | } |
| 3018 | 3021 | |
| 3019 | 3022 | pub fn Data(comptime t: Tag) type { |
| ... | ... | @@ -3163,7 +3166,6 @@ pub const CType = enum { |
| 3163 | 3166 | longdouble, |
| 3164 | 3167 | |
| 3165 | 3168 | pub fn sizeInBits(self: CType, target: Target) u16 { |
| 3166 | const arch = target.cpu.arch; | |
| 3167 | 3169 | switch (target.os.tag) { |
| 3168 | 3170 | .freestanding, .other => switch (target.cpu.arch) { |
| 3169 | 3171 | .msp430 => switch (self) { |
src/value.zig+8| ... | ... | @@ -626,6 +626,7 @@ pub const Value = extern union { |
| 626 | 626 | return std.mem.dupe(allocator, u8, payload.data); |
| 627 | 627 | } |
| 628 | 628 | if (self.castTag(.repeated)) |payload| { |
| 629 | _ = payload; | |
| 629 | 630 | @panic("TODO implement toAllocatedBytes for this Value tag"); |
| 630 | 631 | } |
| 631 | 632 | if (self.castTag(.decl_ref)) |payload| { |
| ... | ... | @@ -747,6 +748,7 @@ pub const Value = extern union { |
| 747 | 748 | |
| 748 | 749 | /// Asserts the type is an enum type. |
| 749 | 750 | pub fn toEnum(val: Value, enum_ty: Type, comptime E: type) E { |
| 751 | _ = enum_ty; | |
| 750 | 752 | // TODO this needs to resolve other kinds of Value tags rather than |
| 751 | 753 | // assuming the tag will be .enum_field_index. |
| 752 | 754 | const field_index = val.castTag(.enum_field_index).?.data; |
| ... | ... | @@ -935,6 +937,7 @@ pub const Value = extern union { |
| 935 | 937 | /// Converts an integer or a float to a float. |
| 936 | 938 | /// Returns `error.Overflow` if the value does not fit in the new type. |
| 937 | 939 | pub fn floatCast(self: Value, allocator: *Allocator, ty: Type, target: Target) !Value { |
| 940 | _ = target; | |
| 938 | 941 | switch (ty.tag()) { |
| 939 | 942 | .f16 => { |
| 940 | 943 | @panic("TODO add __trunctfhf2 to compiler-rt"); |
| ... | ... | @@ -1292,17 +1295,21 @@ pub const Value = extern union { |
| 1292 | 1295 | |
| 1293 | 1296 | pub const ArrayHashContext = struct { |
| 1294 | 1297 | pub fn hash(self: @This(), v: Value) u32 { |
| 1298 | _ = self; | |
| 1295 | 1299 | return v.hash_u32(); |
| 1296 | 1300 | } |
| 1297 | 1301 | pub fn eql(self: @This(), a: Value, b: Value) bool { |
| 1302 | _ = self; | |
| 1298 | 1303 | return a.eql(b); |
| 1299 | 1304 | } |
| 1300 | 1305 | }; |
| 1301 | 1306 | pub const HashContext = struct { |
| 1302 | 1307 | pub fn hash(self: @This(), v: Value) u64 { |
| 1308 | _ = self; | |
| 1303 | 1309 | return v.hash(); |
| 1304 | 1310 | } |
| 1305 | 1311 | pub fn eql(self: @This(), a: Value, b: Value) bool { |
| 1312 | _ = self; | |
| 1306 | 1313 | return a.eql(b); |
| 1307 | 1314 | } |
| 1308 | 1315 | }; |
| ... | ... | @@ -1345,6 +1352,7 @@ pub const Value = extern union { |
| 1345 | 1352 | } |
| 1346 | 1353 | |
| 1347 | 1354 | pub fn fieldValue(val: Value, allocator: *Allocator, index: usize) error{OutOfMemory}!Value { |
| 1355 | _ = allocator; | |
| 1348 | 1356 | switch (val.tag()) { |
| 1349 | 1357 | .@"struct" => { |
| 1350 | 1358 | const field_values = val.castTag(.@"struct").?.data; |
test/behavior/align.zig+1| ... | ... | @@ -167,6 +167,7 @@ test "generic function with align param" { |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | fn whyWouldYouEverDoThis(comptime align_bytes: u8) align(align_bytes) u8 { |
| 170 | _ = align_bytes; | |
| 170 | 171 | return 0x1; |
| 171 | 172 | } |
| 172 | 173 |
test/behavior/async_fn.zig+26| ... | ... | @@ -13,6 +13,7 @@ test "simple coroutine suspend and resume" { |
| 13 | 13 | resume frame; |
| 14 | 14 | try expect(global_x == 3); |
| 15 | 15 | const af: anyframe->void = &frame; |
| 16 | _ = af; | |
| 16 | 17 | resume frame; |
| 17 | 18 | try expect(global_x == 4); |
| 18 | 19 | } |
| ... | ... | @@ -45,6 +46,7 @@ test "suspend at end of function" { |
| 45 | 46 | fn doTheTest() !void { |
| 46 | 47 | try expect(x == 1); |
| 47 | 48 | const p = async suspendAtEnd(); |
| 49 | _ = p; | |
| 48 | 50 | try expect(x == 2); |
| 49 | 51 | } |
| 50 | 52 | |
| ... | ... | @@ -131,7 +133,9 @@ test "@frameSize" { |
| 131 | 133 | other(1); |
| 132 | 134 | } |
| 133 | 135 | fn other(param: i32) void { |
| 136 | _ = param; | |
| 134 | 137 | var local: i32 = undefined; |
| 138 | _ = local; | |
| 135 | 139 | suspend {} |
| 136 | 140 | } |
| 137 | 141 | }; |
| ... | ... | @@ -181,6 +185,7 @@ test "coroutine suspend, resume" { |
| 181 | 185 | |
| 182 | 186 | test "coroutine suspend with block" { |
| 183 | 187 | const p = async testSuspendBlock(); |
| 188 | _ = p; | |
| 184 | 189 | try expect(!global_result); |
| 185 | 190 | resume a_promise; |
| 186 | 191 | try expect(global_result); |
| ... | ... | @@ -207,6 +212,7 @@ var await_final_result: i32 = 0; |
| 207 | 212 | test "coroutine await" { |
| 208 | 213 | await_seq('a'); |
| 209 | 214 | var p = async await_amain(); |
| 215 | _ = p; | |
| 210 | 216 | await_seq('f'); |
| 211 | 217 | resume await_a_promise; |
| 212 | 218 | await_seq('i'); |
| ... | ... | @@ -243,6 +249,7 @@ var early_final_result: i32 = 0; |
| 243 | 249 | test "coroutine await early return" { |
| 244 | 250 | early_seq('a'); |
| 245 | 251 | var p = async early_amain(); |
| 252 | _ = p; | |
| 246 | 253 | early_seq('f'); |
| 247 | 254 | try expect(early_final_result == 1234); |
| 248 | 255 | try expect(std.mem.eql(u8, &early_points, "abcdef")); |
| ... | ... | @@ -276,6 +283,7 @@ test "async function with dot syntax" { |
| 276 | 283 | } |
| 277 | 284 | }; |
| 278 | 285 | const p = async S.foo(); |
| 286 | _ = p; | |
| 279 | 287 | try expect(S.y == 2); |
| 280 | 288 | } |
| 281 | 289 | |
| ... | ... | @@ -362,11 +370,13 @@ test "error return trace across suspend points - early return" { |
| 362 | 370 | const p = nonFailing(); |
| 363 | 371 | resume p; |
| 364 | 372 | const p2 = async printTrace(p); |
| 373 | _ = p2; | |
| 365 | 374 | } |
| 366 | 375 | |
| 367 | 376 | test "error return trace across suspend points - async return" { |
| 368 | 377 | const p = nonFailing(); |
| 369 | 378 | const p2 = async printTrace(p); |
| 379 | _ = p2; | |
| 370 | 380 | resume p; |
| 371 | 381 | } |
| 372 | 382 | |
| ... | ... | @@ -396,6 +406,7 @@ fn printTrace(p: anyframe->(anyerror!void)) callconv(.Async) void { |
| 396 | 406 | test "break from suspend" { |
| 397 | 407 | var my_result: i32 = 1; |
| 398 | 408 | const p = async testBreakFromSuspend(&my_result); |
| 409 | _ = p; | |
| 399 | 410 | try std.testing.expect(my_result == 2); |
| 400 | 411 | } |
| 401 | 412 | fn testBreakFromSuspend(my_result: *i32) callconv(.Async) void { |
| ... | ... | @@ -619,11 +630,14 @@ test "returning a const error from async function" { |
| 619 | 630 | fn amain() !void { |
| 620 | 631 | var download_frame = async fetchUrl(10, "a string"); |
| 621 | 632 | const download_text = try await download_frame; |
| 633 | _ = download_text; | |
| 622 | 634 | |
| 623 | 635 | @panic("should not get here"); |
| 624 | 636 | } |
| 625 | 637 | |
| 626 | 638 | fn fetchUrl(unused: i32, url: []const u8) ![]u8 { |
| 639 | _ = unused; | |
| 640 | _ = url; | |
| 627 | 641 | frame = @frame(); |
| 628 | 642 | suspend {} |
| 629 | 643 | ok = true; |
| ... | ... | @@ -700,6 +714,7 @@ fn testAsyncAwaitTypicalUsage( |
| 700 | 714 | |
| 701 | 715 | var global_download_frame: anyframe = undefined; |
| 702 | 716 | fn fetchUrl(allocator: *std.mem.Allocator, url: []const u8) anyerror![]u8 { |
| 717 | _ = url; | |
| 703 | 718 | const result = try std.mem.dupe(allocator, u8, "expected download text"); |
| 704 | 719 | errdefer allocator.free(result); |
| 705 | 720 | if (suspend_download) { |
| ... | ... | @@ -713,6 +728,7 @@ fn testAsyncAwaitTypicalUsage( |
| 713 | 728 | |
| 714 | 729 | var global_file_frame: anyframe = undefined; |
| 715 | 730 | fn readFile(allocator: *std.mem.Allocator, filename: []const u8) anyerror![]u8 { |
| 731 | _ = filename; | |
| 716 | 732 | const result = try std.mem.dupe(allocator, u8, "expected file text"); |
| 717 | 733 | errdefer allocator.free(result); |
| 718 | 734 | if (suspend_file) { |
| ... | ... | @@ -730,6 +746,7 @@ test "alignment of local variables in async functions" { |
| 730 | 746 | const S = struct { |
| 731 | 747 | fn doTheTest() !void { |
| 732 | 748 | var y: u8 = 123; |
| 749 | _ = y; | |
| 733 | 750 | var x: u8 align(128) = 1; |
| 734 | 751 | try expect(@ptrToInt(&x) % 128 == 0); |
| 735 | 752 | } |
| ... | ... | @@ -742,6 +759,7 @@ test "no reason to resolve frame still works" { |
| 742 | 759 | } |
| 743 | 760 | fn simpleNothing() void { |
| 744 | 761 | var x: i32 = 1234; |
| 762 | _ = x; | |
| 745 | 763 | } |
| 746 | 764 | |
| 747 | 765 | test "async call a generic function" { |
| ... | ... | @@ -802,6 +820,7 @@ test "struct parameter to async function is copied to the frame" { |
| 802 | 820 | if (x == 0) return; |
| 803 | 821 | clobberStack(x - 1); |
| 804 | 822 | var y: i32 = x; |
| 823 | _ = y; | |
| 805 | 824 | } |
| 806 | 825 | |
| 807 | 826 | fn bar(f: *@Frame(foo)) void { |
| ... | ... | @@ -1212,6 +1231,7 @@ test "suspend in while loop" { |
| 1212 | 1231 | suspend {} |
| 1213 | 1232 | return val; |
| 1214 | 1233 | } else |err| { |
| 1234 | err catch {}; | |
| 1215 | 1235 | return 0; |
| 1216 | 1236 | } |
| 1217 | 1237 | } |
| ... | ... | @@ -1341,6 +1361,7 @@ test "async function passed 0-bit arg after non-0-bit arg" { |
| 1341 | 1361 | } |
| 1342 | 1362 | |
| 1343 | 1363 | fn bar(x: i32, args: anytype) anyerror!void { |
| 1364 | _ = args; | |
| 1344 | 1365 | global_frame = @frame(); |
| 1345 | 1366 | suspend {} |
| 1346 | 1367 | global_int = x; |
| ... | ... | @@ -1636,6 +1657,8 @@ test "@asyncCall with pass-by-value arguments" { |
| 1636 | 1657 | pub const AT = [5]u8; |
| 1637 | 1658 | |
| 1638 | 1659 | pub fn f(_fill0: u64, s: ST, _fill1: u64, a: AT, _fill2: u64) callconv(.Async) void { |
| 1660 | _ = s; | |
| 1661 | _ = a; | |
| 1639 | 1662 | // Check that the array and struct arguments passed by value don't |
| 1640 | 1663 | // end up overflowing the adjacent fields in the frame structure. |
| 1641 | 1664 | expectEqual(F0, _fill0) catch @panic("test failure"); |
| ... | ... | @@ -1654,6 +1677,7 @@ test "@asyncCall with pass-by-value arguments" { |
| 1654 | 1677 | [_]u8{ 1, 2, 3, 4, 5 }, |
| 1655 | 1678 | F2, |
| 1656 | 1679 | }); |
| 1680 | _ = frame_ptr; | |
| 1657 | 1681 | } |
| 1658 | 1682 | |
| 1659 | 1683 | test "@asyncCall with arguments having non-standard alignment" { |
| ... | ... | @@ -1662,6 +1686,7 @@ test "@asyncCall with arguments having non-standard alignment" { |
| 1662 | 1686 | |
| 1663 | 1687 | const S = struct { |
| 1664 | 1688 | pub fn f(_fill0: u32, s: struct { x: u64 align(16) }, _fill1: u64) callconv(.Async) void { |
| 1689 | _ = s; | |
| 1665 | 1690 | // The compiler inserts extra alignment for s, check that the |
| 1666 | 1691 | // generated code picks the right slot for fill1. |
| 1667 | 1692 | expectEqual(F0, _fill0) catch @panic("test failure"); |
| ... | ... | @@ -1673,4 +1698,5 @@ test "@asyncCall with arguments having non-standard alignment" { |
| 1673 | 1698 | // The function pointer must not be comptime-known. |
| 1674 | 1699 | var t = S.f; |
| 1675 | 1700 | var frame_ptr = @asyncCall(&buffer, {}, t, .{ F0, undefined, F1 }); |
| 1701 | _ = frame_ptr; | |
| 1676 | 1702 | } |
test/behavior/atomics.zig-2| ... | ... | @@ -97,7 +97,6 @@ test "cmpxchg with ptr" { |
| 97 | 97 | |
| 98 | 98 | test "cmpxchg with ignored result" { |
| 99 | 99 | var x: i32 = 1234; |
| 100 | var ptr = &x; | |
| 101 | 100 | |
| 102 | 101 | _ = @cmpxchgStrong(i32, &x, 1234, 5678, .Monotonic, .Monotonic); |
| 103 | 102 | |
| ... | ... | @@ -195,7 +194,6 @@ fn testAtomicRmwInt() !void { |
| 195 | 194 | test "atomics with different types" { |
| 196 | 195 | try testAtomicsWithType(bool, true, false); |
| 197 | 196 | inline for (.{ u1, i4, u5, i15, u24 }) |T| { |
| 198 | var x: T = 0; | |
| 199 | 197 | try testAtomicsWithType(T, 0, 1); |
| 200 | 198 | } |
| 201 | 199 | try testAtomicsWithType(u0, 0, 0); |
test/behavior/await_struct.zig+1| ... | ... | @@ -12,6 +12,7 @@ var await_final_result = Foo{ .x = 0 }; |
| 12 | 12 | test "coroutine await struct" { |
| 13 | 13 | await_seq('a'); |
| 14 | 14 | var p = async await_amain(); |
| 15 | _ = p; | |
| 15 | 16 | await_seq('f'); |
| 16 | 17 | resume await_a_promise; |
| 17 | 18 | await_seq('i'); |
test/behavior/bit_shifting.zig+1-1| ... | ... | @@ -100,5 +100,5 @@ test "comptime shr of BigInt" { |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | test "comptime shift safety check" { |
| 103 | const x = @as(usize, 42) << @sizeOf(usize); | |
| 103 | _ = @as(usize, 42) << @sizeOf(usize); | |
| 104 | 104 | } |
test/behavior/bugs/1310.zig+2| ... | ... | @@ -16,6 +16,8 @@ pub const InvocationTable_ = struct_InvocationTable_; |
| 16 | 16 | pub const VM_ = struct_VM_; |
| 17 | 17 | |
| 18 | 18 | fn agent_callback(_vm: [*]VM, options: [*]u8) callconv(.C) i32 { |
| 19 | _ = _vm; | |
| 20 | _ = options; | |
| 19 | 21 | return 11; |
| 20 | 22 | } |
| 21 | 23 |
test/behavior/bugs/1467.zig+1| ... | ... | @@ -4,4 +4,5 @@ pub const S = extern struct { |
| 4 | 4 | }; |
| 5 | 5 | test "bug 1467" { |
| 6 | 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 | 7 | test "allow these dependencies" { |
| 8 | 8 | var a: A = undefined; |
| 9 | 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 | 1 | test "fixed" { |
| 2 | 2 | const a: *void = undefined; |
| 3 | 3 | const b: *[1]void = a; |
| 4 | _ = b; | |
| 4 | 5 | const c: *[0]u8 = undefined; |
| 5 | 6 | const d: []u8 = c; |
| 7 | _ = d; | |
| 6 | 8 | } |
test/behavior/bugs/2578.zig+3-1| ... | ... | @@ -5,7 +5,9 @@ const Foo = struct { |
| 5 | 5 | var foo: Foo = undefined; |
| 6 | 6 | const t = &foo; |
| 7 | 7 | |
| 8 | fn bar(pointer: ?*c_void) void {} | |
| 8 | fn bar(pointer: ?*c_void) void { | |
| 9 | _ = pointer; | |
| 10 | } | |
| 9 | 11 | |
| 10 | 12 | test "fixed" { |
| 11 | 13 | bar(t); |
test/behavior/bugs/2692.zig+3-1| ... | ... | @@ -1,4 +1,6 @@ |
| 1 | fn foo(a: []u8) void {} | |
| 1 | fn foo(a: []u8) void { | |
| 2 | _ = a; | |
| 3 | } | |
| 2 | 4 | |
| 3 | 5 | test "address of 0 length array" { |
| 4 | 6 | var pt: [0]u8 = undefined; |
test/behavior/bugs/3367.zig+3-1| ... | ... | @@ -3,7 +3,9 @@ const Foo = struct { |
| 3 | 3 | }; |
| 4 | 4 | |
| 5 | 5 | const Mixin = struct { |
| 6 | pub fn two(self: Foo) void {} | |
| 6 | pub fn two(self: Foo) void { | |
| 7 | _ = self; | |
| 8 | } | |
| 7 | 9 | }; |
| 8 | 10 | |
| 9 | 11 | test "container member access usingnamespace decls" { |
test/behavior/bugs/3586.zig+1| ... | ... | @@ -8,4 +8,5 @@ test "fixed" { |
| 8 | 8 | var ctr = Container{ |
| 9 | 9 | .params = NoteParams{}, |
| 10 | 10 | }; |
| 11 | _ = ctr; | |
| 11 | 12 | } |
test/behavior/bugs/4328.zig+2| ... | ... | @@ -53,10 +53,12 @@ test "Peer resolution of extern function calls in @TypeOf" { |
| 53 | 53 | test "Extern function calls, dereferences and field access in @TypeOf" { |
| 54 | 54 | const Test = struct { |
| 55 | 55 | fn test_fn_1(a: c_long) @TypeOf(fopen("test", "r").*) { |
| 56 | _ = a; | |
| 56 | 57 | return .{ .dummy_field = 0 }; |
| 57 | 58 | } |
| 58 | 59 | |
| 59 | 60 | fn test_fn_2(a: anytype) @TypeOf(fopen("test", "r").*.dummy_field) { |
| 61 | _ = a; | |
| 60 | 62 | return 255; |
| 61 | 63 | } |
| 62 | 64 |
test/behavior/bugs/4560.zig+4| ... | ... | @@ -25,6 +25,10 @@ pub fn StringHashMap(comptime V: type) type { |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | pub fn HashMap(comptime K: type, comptime V: type) type { |
| 28 | if (false) { | |
| 29 | K; | |
| 30 | V; | |
| 31 | } | |
| 28 | 32 | return struct { |
| 29 | 33 | size: usize, |
| 30 | 34 | max_distance_from_start_index: usize, |
test/behavior/bugs/4954.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | fn f(buf: []u8) void { |
| 2 | var ptr = &buf[@sizeOf(u32)]; | |
| 2 | _ = &buf[@sizeOf(u32)]; | |
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | test "crash" { |
test/behavior/bugs/529_other_file_2.zig+3-1| ... | ... | @@ -1,4 +1,6 @@ |
| 1 | 1 | pub const A = extern struct { |
| 2 | 2 | field: c_int, |
| 3 | 3 | }; |
| 4 | export fn issue529(a: ?*A) void {} | |
| 4 | export fn issue529(a: ?*A) void { | |
| 5 | _ = a; | |
| 6 | } |
test/behavior/bugs/5487.zig+1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | const io = @import("std").io; |
| 2 | 2 | |
| 3 | 3 | pub fn write(_: void, bytes: []const u8) !usize { |
| 4 | _ = bytes; | |
| 4 | 5 | return 0; |
| 5 | 6 | } |
| 6 | 7 | pub fn writer() io.Writer(void, @typeInfo(@typeInfo(@TypeOf(write)).Fn.return_type.?).ErrorUnion.error_set, write) { |
test/behavior/bugs/624.zig+1| ... | ... | @@ -12,6 +12,7 @@ const ListenerContext = struct { |
| 12 | 12 | const ContextAllocator = MemoryPool(TestContext); |
| 13 | 13 | |
| 14 | 14 | fn MemoryPool(comptime T: type) type { |
| 15 | _ = T; | |
| 15 | 16 | return struct { |
| 16 | 17 | n: usize, |
| 17 | 18 | }; |
test/behavior/bugs/679.zig+1| ... | ... | @@ -2,6 +2,7 @@ const std = @import("std"); |
| 2 | 2 | const expect = std.testing.expect; |
| 3 | 3 | |
| 4 | 4 | pub fn List(comptime T: type) type { |
| 5 | _ = T; | |
| 5 | 6 | return u32; |
| 6 | 7 | } |
| 7 | 8 |
test/behavior/bugs/7003.zig+1| ... | ... | @@ -5,4 +5,5 @@ test "@Type should resolve its children types" { |
| 5 | 5 | comptime var sparse_info = @typeInfo(anyerror!sparse); |
| 6 | 6 | sparse_info.ErrorUnion.payload = dense; |
| 7 | 7 | const B = @Type(sparse_info); |
| 8 | _ = B; | |
| 8 | 9 | } |
test/behavior/bugs/7027.zig+3-1| ... | ... | @@ -9,7 +9,9 @@ const Foobar = struct { |
| 9 | 9 | } |
| 10 | 10 | }; |
| 11 | 11 | |
| 12 | fn foo(arg: anytype) void {} | |
| 12 | fn foo(arg: anytype) void { | |
| 13 | _ = arg; | |
| 14 | } | |
| 13 | 15 | |
| 14 | 16 | test "" { |
| 15 | 17 | comptime var foobar = Foobar.foo(); |
test/behavior/bugs/704.zig+3-1| ... | ... | @@ -1,5 +1,7 @@ |
| 1 | 1 | const xxx = struct { |
| 2 | pub fn bar(self: *xxx) void {} | |
| 2 | pub fn bar(self: *xxx) void { | |
| 3 | _ = self; | |
| 4 | } | |
| 3 | 5 | }; |
| 4 | 6 | test "bug 704" { |
| 5 | 7 | var x: xxx = undefined; |
test/behavior/bugs/7250.zig+3-1| ... | ... | @@ -3,7 +3,9 @@ const nrfx_uart_t = extern struct { |
| 3 | 3 | drv_inst_idx: u8, |
| 4 | 4 | }; |
| 5 | 5 | |
| 6 | pub fn nrfx_uart_rx(p_instance: [*c]const nrfx_uart_t) void {} | |
| 6 | pub fn nrfx_uart_rx(p_instance: [*c]const nrfx_uart_t) void { | |
| 7 | _ = p_instance; | |
| 8 | } | |
| 7 | 9 | |
| 8 | 10 | threadlocal var g_uart0 = nrfx_uart_t{ |
| 9 | 11 | .p_reg = 0, |
test/behavior/bugs/828.zig+6| ... | ... | @@ -4,6 +4,7 @@ const CountBy = struct { |
| 4 | 4 | const One = CountBy{ .a = 1 }; |
| 5 | 5 | |
| 6 | 6 | pub fn counter(self: *const CountBy) Counter { |
| 7 | _ = self; | |
| 7 | 8 | return Counter{ .i = 0 }; |
| 8 | 9 | } |
| 9 | 10 | }; |
| ... | ... | @@ -18,6 +19,7 @@ const Counter = struct { |
| 18 | 19 | }; |
| 19 | 20 | |
| 20 | 21 | fn constCount(comptime cb: *const CountBy, comptime unused: u32) void { |
| 22 | _ = unused; | |
| 21 | 23 | comptime { |
| 22 | 24 | var cnt = cb.counter(); |
| 23 | 25 | if (cnt.i != 0) @compileError("Counter instance reused!"); |
| ... | ... | @@ -30,4 +32,8 @@ test "comptime struct return should not return the same instance" { |
| 30 | 32 | //a second parameter is required to trigger the bug |
| 31 | 33 | const ValA = constCount(&CountBy.One, 12); |
| 32 | 34 | const ValB = constCount(&CountBy.One, 15); |
| 35 | if (false) { | |
| 36 | ValA; | |
| 37 | ValB; | |
| 38 | } | |
| 33 | 39 | } |
test/behavior/bugs/920.zig+2| ... | ... | @@ -46,6 +46,8 @@ fn norm_f_inv(y: f64) f64 { |
| 46 | 46 | return math.sqrt(-2.0 * math.ln(y)); |
| 47 | 47 | } |
| 48 | 48 | fn norm_zero_case(random: *Random, u: f64) f64 { |
| 49 | _ = random; | |
| 50 | _ = u; | |
| 49 | 51 | return 0.0; |
| 50 | 52 | } |
| 51 | 53 |
test/behavior/cast.zig+9-2| ... | ... | @@ -102,6 +102,7 @@ fn castToOptionalTypeError(z: i32) !void { |
| 102 | 102 | |
| 103 | 103 | const f = z; |
| 104 | 104 | const g: anyerror!?i32 = f; |
| 105 | _ = g catch {}; | |
| 105 | 106 | |
| 106 | 107 | const a = A{ .a = z }; |
| 107 | 108 | const b: anyerror!?A = a; |
| ... | ... | @@ -114,7 +115,9 @@ test "implicitly cast from int to anyerror!?T" { |
| 114 | 115 | } |
| 115 | 116 | fn implicitIntLitToOptional() void { |
| 116 | 117 | const f: ?i32 = 1; |
| 118 | _ = f; | |
| 117 | 119 | const g: anyerror!?i32 = 1; |
| 120 | _ = g catch {}; | |
| 118 | 121 | } |
| 119 | 122 | |
| 120 | 123 | test "return null from fn() anyerror!?&T" { |
| ... | ... | @@ -821,9 +824,13 @@ test "variable initialization uses result locations properly with regards to the |
| 821 | 824 | test "cast between [*c]T and ?[*:0]T on fn parameter" { |
| 822 | 825 | const S = struct { |
| 823 | 826 | const Handler = ?fn ([*c]const u8) callconv(.C) void; |
| 824 | fn addCallback(handler: Handler) void {} | |
| 827 | fn addCallback(handler: Handler) void { | |
| 828 | _ = handler; | |
| 829 | } | |
| 825 | 830 | |
| 826 | fn myCallback(cstr: ?[*:0]const u8) callconv(.C) void {} | |
| 831 | fn myCallback(cstr: ?[*:0]const u8) callconv(.C) void { | |
| 832 | _ = cstr; | |
| 833 | } | |
| 827 | 834 | |
| 828 | 835 | fn doTheTest() void { |
| 829 | 836 | addCallback(myCallback); |
test/behavior/enum.zig+2| ... | ... | @@ -111,6 +111,8 @@ test "enum type" { |
| 111 | 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 | 116 | const bar = Bar.B; |
| 115 | 117 | |
| 116 | 118 | try expect(bar == Bar.B); |
test/behavior/error.zig+13-3| ... | ... | @@ -103,6 +103,7 @@ fn testErrorSetType() !void { |
| 103 | 103 | |
| 104 | 104 | const a: MyErrSet!i32 = 5678; |
| 105 | 105 | const b: MyErrSet!i32 = MyErrSet.OutOfMemory; |
| 106 | try expect(b catch error.OutOfMemory == error.OutOfMemory); | |
| 106 | 107 | |
| 107 | 108 | if (a) |value| try expect(value == 5678) else |err| switch (err) { |
| 108 | 109 | error.OutOfMemory => unreachable, |
| ... | ... | @@ -138,7 +139,10 @@ test "comptime test error for empty error set" { |
| 138 | 139 | const EmptyErrorSet = error{}; |
| 139 | 140 | |
| 140 | 141 | fn testComptimeTestErrorEmptySet(x: EmptyErrorSet!i32) !void { |
| 141 | if (x) |v| try expect(v == 1234) else |err| @compileError("bad"); | |
| 142 | if (x) |v| try expect(v == 1234) else |err| { | |
| 143 | _ = err; | |
| 144 | @compileError("bad"); | |
| 145 | } | |
| 142 | 146 | } |
| 143 | 147 | |
| 144 | 148 | test "syntax: optional operator in front of error union operator" { |
| ... | ... | @@ -162,6 +166,7 @@ fn testErrToIntWithOnePossibleValue( |
| 162 | 166 | |
| 163 | 167 | test "empty error union" { |
| 164 | 168 | const x = error{} || error{}; |
| 169 | _ = x; | |
| 165 | 170 | } |
| 166 | 171 | |
| 167 | 172 | test "error union peer type resolution" { |
| ... | ... | @@ -204,6 +209,7 @@ fn entry() void { |
| 204 | 209 | |
| 205 | 210 | fn foo2(f: fn () anyerror!void) void { |
| 206 | 211 | const x = f(); |
| 212 | x catch {}; | |
| 207 | 213 | } |
| 208 | 214 | |
| 209 | 215 | fn bar2() (error{}!void) {} |
| ... | ... | @@ -338,6 +344,7 @@ test "optional error set is the same size as error set" { |
| 338 | 344 | test "debug info for optional error set" { |
| 339 | 345 | const SomeError = error{Hello}; |
| 340 | 346 | var a_local_variable: ?SomeError = null; |
| 347 | _ = a_local_variable; | |
| 341 | 348 | } |
| 342 | 349 | |
| 343 | 350 | test "nested catch" { |
| ... | ... | @@ -349,7 +356,7 @@ test "nested catch" { |
| 349 | 356 | return error.Wrong; |
| 350 | 357 | } |
| 351 | 358 | fn func() anyerror!Foo { |
| 352 | const x = fail() catch | |
| 359 | _ = fail() catch | |
| 353 | 360 | fail() catch |
| 354 | 361 | return error.Bad; |
| 355 | 362 | unreachable; |
| ... | ... | @@ -390,6 +397,7 @@ test "function pointer with return type that is error union with payload which i |
| 390 | 397 | const Err = error{UnspecifiedErr}; |
| 391 | 398 | |
| 392 | 399 | fn bar(a: i32) anyerror!*Foo { |
| 400 | _ = a; | |
| 393 | 401 | return Err.UnspecifiedErr; |
| 394 | 402 | } |
| 395 | 403 | |
| ... | ... | @@ -444,7 +452,9 @@ test "error payload type is correctly resolved" { |
| 444 | 452 | |
| 445 | 453 | test "error union comptime caching" { |
| 446 | 454 | const S = struct { |
| 447 | fn foo(comptime arg: anytype) void {} | |
| 455 | fn foo(comptime arg: anytype) void { | |
| 456 | arg catch {}; | |
| 457 | } | |
| 448 | 458 | }; |
| 449 | 459 | |
| 450 | 460 | S.foo(@as(anyerror!void, {})); |
test/behavior/eval.zig+9-2| ... | ... | @@ -184,6 +184,7 @@ fn testTryToTrickEvalWithRuntimeIf(b: bool) usize { |
| 184 | 184 | comptime var i: usize = 0; |
| 185 | 185 | inline while (i < 10) : (i += 1) { |
| 186 | 186 | const result = if (b) false else true; |
| 187 | _ = result; | |
| 187 | 188 | } |
| 188 | 189 | comptime { |
| 189 | 190 | return i; |
| ... | ... | @@ -195,6 +196,7 @@ test "inlined loop has array literal with elided runtime scope on first iteratio |
| 195 | 196 | comptime var i: usize = 0; |
| 196 | 197 | inline while (i < 2) : (i += 1) { |
| 197 | 198 | const result = if (i == 0) [1]i32{2} else runtime; |
| 199 | _ = result; | |
| 198 | 200 | } |
| 199 | 201 | comptime { |
| 200 | 202 | try expect(i == 2); |
| ... | ... | @@ -420,6 +422,7 @@ test { |
| 420 | 422 | } |
| 421 | 423 | |
| 422 | 424 | pub fn TypeWithCompTimeSlice(comptime field_name: []const u8) type { |
| 425 | _ = field_name; | |
| 423 | 426 | return struct { |
| 424 | 427 | pub const Node = struct {}; |
| 425 | 428 | }; |
| ... | ... | @@ -696,7 +699,9 @@ test "refer to the type of a generic function" { |
| 696 | 699 | f(i32); |
| 697 | 700 | } |
| 698 | 701 | |
| 699 | fn doNothingWithType(comptime T: type) void {} | |
| 702 | fn doNothingWithType(comptime T: type) void { | |
| 703 | _ = T; | |
| 704 | } | |
| 700 | 705 | |
| 701 | 706 | test "zero extend from u0 to u1" { |
| 702 | 707 | var zero_u0: u0 = 0; |
| ... | ... | @@ -817,7 +822,9 @@ test "two comptime calls with array default initialized to undefined" { |
| 817 | 822 | result.getCpuArch(); |
| 818 | 823 | } |
| 819 | 824 | |
| 820 | pub fn getCpuArch(self: CrossTarget) void {} | |
| 825 | pub fn getCpuArch(self: CrossTarget) void { | |
| 826 | _ = self; | |
| 827 | } | |
| 821 | 828 | }; |
| 822 | 829 | |
| 823 | 830 | const DynamicLinker = struct { |
test/behavior/fn.zig+8-2| ... | ... | @@ -23,6 +23,7 @@ test "void parameters" { |
| 23 | 23 | try voidFun(1, void{}, 2, {}); |
| 24 | 24 | } |
| 25 | 25 | fn voidFun(a: i32, b: void, c: i32, d: void) !void { |
| 26 | _ = d; | |
| 26 | 27 | const v = b; |
| 27 | 28 | const vv: void = if (a == 1) v else {}; |
| 28 | 29 | try expect(a + c == 3); |
| ... | ... | @@ -57,7 +58,9 @@ test "call function with empty string" { |
| 57 | 58 | acceptsString(""); |
| 58 | 59 | } |
| 59 | 60 | |
| 60 | fn acceptsString(foo: []u8) void {} | |
| 61 | fn acceptsString(foo: []u8) void { | |
| 62 | _ = foo; | |
| 63 | } | |
| 61 | 64 | |
| 62 | 65 | fn @"weird function name"() i32 { |
| 63 | 66 | return 1234; |
| ... | ... | @@ -70,7 +73,9 @@ test "implicit cast function unreachable return" { |
| 70 | 73 | wantsFnWithVoid(fnWithUnreachable); |
| 71 | 74 | } |
| 72 | 75 | |
| 73 | fn wantsFnWithVoid(f: fn () void) void {} | |
| 76 | fn wantsFnWithVoid(f: fn () void) void { | |
| 77 | _ = f; | |
| 78 | } | |
| 74 | 79 | |
| 75 | 80 | fn fnWithUnreachable() noreturn { |
| 76 | 81 | unreachable; |
| ... | ... | @@ -162,6 +167,7 @@ const Point3 = struct { |
| 162 | 167 | y: i32, |
| 163 | 168 | |
| 164 | 169 | fn addPointCoords(self: Point3, comptime T: type) i32 { |
| 170 | _ = T; | |
| 165 | 171 | return self.x + self.y; |
| 166 | 172 | } |
| 167 | 173 | }; |
test/behavior/for.zig+11-3| ... | ... | @@ -29,10 +29,14 @@ test "for loop with pointer elem var" { |
| 29 | 29 | mangleString(target[0..]); |
| 30 | 30 | try expect(mem.eql(u8, &target, "bcdefgh")); |
| 31 | 31 | |
| 32 | for (source) |*c, i| | |
| 32 | for (source) |*c, i| { | |
| 33 | _ = i; | |
| 33 | 34 | try expect(@TypeOf(c) == *const u8); |
| 34 | for (target) |*c, i| | |
| 35 | } | |
| 36 | for (target) |*c, i| { | |
| 37 | _ = i; | |
| 35 | 38 | try expect(@TypeOf(c) == *u8); |
| 39 | } | |
| 36 | 40 | } |
| 37 | 41 | |
| 38 | 42 | fn mangleString(s: []u8) void { |
| ... | ... | @@ -53,6 +57,7 @@ test "basic for loop" { |
| 53 | 57 | buf_index += 1; |
| 54 | 58 | } |
| 55 | 59 | for (array) |item, index| { |
| 60 | _ = item; | |
| 56 | 61 | buffer[buf_index] = @intCast(u8, index); |
| 57 | 62 | buf_index += 1; |
| 58 | 63 | } |
| ... | ... | @@ -62,6 +67,7 @@ test "basic for loop" { |
| 62 | 67 | buf_index += 1; |
| 63 | 68 | } |
| 64 | 69 | for (array_ptr) |item, index| { |
| 70 | _ = item; | |
| 65 | 71 | buffer[buf_index] = @intCast(u8, index); |
| 66 | 72 | buf_index += 1; |
| 67 | 73 | } |
| ... | ... | @@ -70,7 +76,7 @@ test "basic for loop" { |
| 70 | 76 | buffer[buf_index] = item; |
| 71 | 77 | buf_index += 1; |
| 72 | 78 | } |
| 73 | for (unknown_size) |item, index| { | |
| 79 | for (unknown_size) |_, index| { | |
| 74 | 80 | buffer[buf_index] = @intCast(u8, index); |
| 75 | 81 | buf_index += 1; |
| 76 | 82 | } |
| ... | ... | @@ -118,6 +124,7 @@ test "2 break statements and an else" { |
| 118 | 124 | var buf: [10]u8 = undefined; |
| 119 | 125 | var ok = false; |
| 120 | 126 | ok = for (buf) |item| { |
| 127 | _ = item; | |
| 121 | 128 | if (f) break false; |
| 122 | 129 | if (t) break true; |
| 123 | 130 | } else false; |
| ... | ... | @@ -136,6 +143,7 @@ test "for with null and T peer types and inferred result location type" { |
| 136 | 143 | break item; |
| 137 | 144 | } |
| 138 | 145 | } else null) |v| { |
| 146 | _ = v; | |
| 139 | 147 | @panic("fail"); |
| 140 | 148 | } |
| 141 | 149 | } |
test/behavior/if.zig+1-1| ... | ... | @@ -45,7 +45,7 @@ var global_with_err: anyerror!u32 = error.SomeError; |
| 45 | 45 | test "unwrap mutable global var" { |
| 46 | 46 | if (global_with_val) |v| { |
| 47 | 47 | try expect(v == 0); |
| 48 | } else |e| { | |
| 48 | } else |_| { | |
| 49 | 49 | unreachable; |
| 50 | 50 | } |
| 51 | 51 | if (global_with_err) |_| { |
test/behavior/import.zig+1-1| ... | ... | @@ -18,5 +18,5 @@ test "import in non-toplevel scope" { |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | test "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 | 5 | |
| 6 | 6 | fn randomAddressToFunction() void { |
| 7 | 7 | var addr: usize = 0xdeadbeef; |
| 8 | var ptr = @intToPtr(fn () void, addr); | |
| 8 | _ = @intToPtr(fn () void, addr); | |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | test "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 | 5 | 1 => getErrInt(), |
| 6 | 6 | 2 => { |
| 7 | 7 | const size = try getErrInt(); |
| 8 | _ = size; | |
| 8 | 9 | return try getErrInt(); |
| 9 | 10 | }, |
| 10 | 11 | else => error.ItBroke, |
test/behavior/math.zig+11| ... | ... | @@ -333,6 +333,12 @@ test "quad hex float literal parsing in range" { |
| 333 | 333 | const b = 0x1.dedafcff354b6ae9758763545432p-9; |
| 334 | 334 | const c = 0x1.2f34dd5f437e849b4baab754cdefp+4534; |
| 335 | 335 | const d = 0x1.edcbff8ad76ab5bf46463233214fp-435; |
| 336 | if (false) { | |
| 337 | a; | |
| 338 | b; | |
| 339 | c; | |
| 340 | d; | |
| 341 | } | |
| 336 | 342 | } |
| 337 | 343 | |
| 338 | 344 | test "quad hex float literal parsing accurate" { |
| ... | ... | @@ -457,6 +463,11 @@ test "hex float literal within range" { |
| 457 | 463 | const a = 0x1.0p16383; |
| 458 | 464 | const b = 0x0.1p16387; |
| 459 | 465 | const c = 0x1.0p-16382; |
| 466 | if (false) { | |
| 467 | a; | |
| 468 | b; | |
| 469 | c; | |
| 470 | } | |
| 460 | 471 | } |
| 461 | 472 | |
| 462 | 473 | test "truncating shift left" { |
test/behavior/misc.zig+18-4| ... | ... | @@ -234,6 +234,7 @@ test "compile time global reinterpret" { |
| 234 | 234 | test "explicit cast maybe pointers" { |
| 235 | 235 | const a: ?*i32 = undefined; |
| 236 | 236 | const b: ?*f32 = @ptrCast(?*f32, a); |
| 237 | _ = b; | |
| 237 | 238 | } |
| 238 | 239 | |
| 239 | 240 | test "generic malloc free" { |
| ... | ... | @@ -244,14 +245,18 @@ var some_mem: [100]u8 = undefined; |
| 244 | 245 | fn memAlloc(comptime T: type, n: usize) anyerror![]T { |
| 245 | 246 | return @ptrCast([*]T, &some_mem[0])[0..n]; |
| 246 | 247 | } |
| 247 | fn memFree(comptime T: type, memory: []T) void {} | |
| 248 | fn memFree(comptime T: type, memory: []T) void { | |
| 249 | _ = memory; | |
| 250 | } | |
| 248 | 251 | |
| 249 | 252 | test "cast undefined" { |
| 250 | 253 | const array: [100]u8 = undefined; |
| 251 | 254 | const slice = @as([]const u8, &array); |
| 252 | 255 | testCastUndefined(slice); |
| 253 | 256 | } |
| 254 | fn testCastUndefined(x: []const u8) void {} | |
| 257 | fn testCastUndefined(x: []const u8) void { | |
| 258 | _ = x; | |
| 259 | } | |
| 255 | 260 | |
| 256 | 261 | test "cast small unsigned to larger signed" { |
| 257 | 262 | try expect(castSmallUnsignedToLargerSigned1(200) == @as(i16, 200)); |
| ... | ... | @@ -451,6 +456,7 @@ test "@typeName" { |
| 451 | 456 | } |
| 452 | 457 | |
| 453 | 458 | fn TypeFromFn(comptime T: type) type { |
| 459 | _ = T; | |
| 454 | 460 | return struct {}; |
| 455 | 461 | } |
| 456 | 462 | |
| ... | ... | @@ -554,7 +560,12 @@ test "packed struct, enum, union parameters in extern function" { |
| 554 | 560 | }), &(PackedUnion{ .a = 1 })); |
| 555 | 561 | } |
| 556 | 562 | |
| 557 | export fn testPackedStuff(a: *const PackedStruct, b: *const PackedUnion) void {} | |
| 563 | export fn testPackedStuff(a: *const PackedStruct, b: *const PackedUnion) void { | |
| 564 | if (false) { | |
| 565 | a; | |
| 566 | b; | |
| 567 | } | |
| 568 | } | |
| 558 | 569 | |
| 559 | 570 | test "slicing zero length array" { |
| 560 | 571 | const s1 = ""[0..]; |
| ... | ... | @@ -583,6 +594,7 @@ test "self reference through fn ptr field" { |
| 583 | 594 | }; |
| 584 | 595 | |
| 585 | 596 | fn foo(a: A) u8 { |
| 597 | _ = a; | |
| 586 | 598 | return 12; |
| 587 | 599 | } |
| 588 | 600 | }; |
| ... | ... | @@ -752,7 +764,9 @@ test "extern variable with non-pointer opaque type" { |
| 752 | 764 | |
| 753 | 765 | test "lazy typeInfo value as generic parameter" { |
| 754 | 766 | const S = struct { |
| 755 | fn foo(args: anytype) void {} | |
| 767 | fn foo(args: anytype) void { | |
| 768 | _ = args; | |
| 769 | } | |
| 756 | 770 | }; |
| 757 | 771 | S.foo(@typeInfo(@TypeOf(.{}))); |
| 758 | 772 | } |
test/behavior/null.zig+2| ... | ... | @@ -39,6 +39,7 @@ test "test maybe object and get a pointer to the inner value" { |
| 39 | 39 | test "rhs maybe unwrap return" { |
| 40 | 40 | const x: ?bool = true; |
| 41 | 41 | const y = x orelse return; |
| 42 | _ = y; | |
| 42 | 43 | } |
| 43 | 44 | |
| 44 | 45 | test "maybe return" { |
| ... | ... | @@ -129,6 +130,7 @@ var struct_with_optional: StructWithOptional = undefined; |
| 129 | 130 | test "unwrap optional which is field of global var" { |
| 130 | 131 | struct_with_optional.field = null; |
| 131 | 132 | if (struct_with_optional.field) |payload| { |
| 133 | _ = payload; | |
| 132 | 134 | unreachable; |
| 133 | 135 | } |
| 134 | 136 | struct_with_optional.field = 1234; |
test/behavior/optional.zig+2| ... | ... | @@ -128,6 +128,7 @@ test "nested orelse" { |
| 128 | 128 | const x = maybe() orelse |
| 129 | 129 | maybe() orelse |
| 130 | 130 | return null; |
| 131 | _ = x; | |
| 131 | 132 | unreachable; |
| 132 | 133 | } |
| 133 | 134 | const Foo = struct { |
| ... | ... | @@ -160,6 +161,7 @@ test "self-referential struct through a slice of optional" { |
| 160 | 161 | test "assigning to an unwrapped optional field in an inline loop" { |
| 161 | 162 | comptime var maybe_pos_arg: ?comptime_int = null; |
| 162 | 163 | inline for ("ab") |x| { |
| 164 | _ = x; | |
| 163 | 165 | maybe_pos_arg = 0; |
| 164 | 166 | if (maybe_pos_arg.? != 0) { |
| 165 | 167 | @compileError("bad"); |
test/behavior/pointers.zig+10-2| ... | ... | @@ -65,6 +65,10 @@ test "assigning integer to C pointer" { |
| 65 | 65 | var x: i32 = 0; |
| 66 | 66 | var ptr: [*c]u8 = 0; |
| 67 | 67 | var ptr2: [*c]u8 = x; |
| 68 | if (false) { | |
| 69 | ptr; | |
| 70 | ptr2; | |
| 71 | } | |
| 68 | 72 | } |
| 69 | 73 | |
| 70 | 74 | 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" { |
| 78 | 82 | test "C pointer comparison and arithmetic" { |
| 79 | 83 | const S = struct { |
| 80 | 84 | fn doTheTest() !void { |
| 81 | var one: usize = 1; | |
| 82 | 85 | var ptr1: [*c]u32 = 0; |
| 83 | 86 | var ptr2 = ptr1 + 10; |
| 84 | 87 | try expect(ptr1 == 0); |
| ... | ... | @@ -176,6 +179,7 @@ test "assign null directly to C pointer and test null equality" { |
| 176 | 179 | try expect(!(x != null)); |
| 177 | 180 | try expect(!(null != x)); |
| 178 | 181 | if (x) |same_x| { |
| 182 | _ = same_x; | |
| 179 | 183 | @panic("fail"); |
| 180 | 184 | } |
| 181 | 185 | var otherx: i32 = undefined; |
| ... | ... | @@ -186,7 +190,10 @@ test "assign null directly to C pointer and test null equality" { |
| 186 | 190 | comptime try expect(null == y); |
| 187 | 191 | comptime try expect(!(y != null)); |
| 188 | 192 | comptime try expect(!(null != y)); |
| 189 | if (y) |same_y| @panic("fail"); | |
| 193 | if (y) |same_y| { | |
| 194 | _ = same_y; | |
| 195 | @panic("fail"); | |
| 196 | } | |
| 190 | 197 | const othery: i32 = undefined; |
| 191 | 198 | comptime try expect((y orelse &othery) == &othery); |
| 192 | 199 | |
| ... | ... | @@ -325,6 +332,7 @@ test "@ptrToInt on null optional at comptime" { |
| 325 | 332 | { |
| 326 | 333 | const pointer = @intToPtr(?*u8, 0x000); |
| 327 | 334 | const x = @ptrToInt(pointer); |
| 335 | _ = x; | |
| 328 | 336 | comptime try expect(0 == @ptrToInt(pointer)); |
| 329 | 337 | } |
| 330 | 338 | { |
test/behavior/reflection.zig+5| ... | ... | @@ -15,6 +15,11 @@ test "reflection: function return type, var args, and param types" { |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | fn dummy(a: bool, b: i32, c: f32) i32 { |
| 18 | if (false) { | |
| 19 | a; | |
| 20 | b; | |
| 21 | c; | |
| 22 | } | |
| 18 | 23 | return 1234; |
| 19 | 24 | } |
| 20 | 25 |
test/behavior/sizeof_and_typeof.zig+2-2| ... | ... | @@ -195,11 +195,11 @@ test "branching logic inside @TypeOf" { |
| 195 | 195 | |
| 196 | 196 | fn fn1(alpha: bool) void { |
| 197 | 197 | const n: usize = 7; |
| 198 | const v = if (alpha) n else @sizeOf(usize); | |
| 198 | _ = if (alpha) n else @sizeOf(usize); | |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | test "lazy @sizeOf result is checked for definedness" { |
| 202 | const f = fn1; | |
| 202 | _ = fn1; | |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | test "@bitSizeOf" { |
test/behavior/slice.zig+1| ... | ... | @@ -104,6 +104,7 @@ test "obtaining a null terminated slice" { |
| 104 | 104 | |
| 105 | 105 | // now we obtain a null terminated slice: |
| 106 | 106 | const ptr = buf[0..3 :0]; |
| 107 | _ = ptr; | |
| 107 | 108 | |
| 108 | 109 | var runtime_len: usize = 3; |
| 109 | 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 | 3 | comptime { |
| 4 | 4 | var target = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; |
| 5 | 5 | const slice = target[0..3 :'d']; |
| 6 | _ = slice; | |
| 6 | 7 | } |
| 7 | 8 | |
| 8 | 9 | // ptr_array |
| ... | ... | @@ -10,6 +11,7 @@ test "comptime slice-sentinel in bounds (unterminated)" { |
| 10 | 11 | var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; |
| 11 | 12 | var target = &buf; |
| 12 | 13 | const slice = target[0..3 :'d']; |
| 14 | _ = slice; | |
| 13 | 15 | } |
| 14 | 16 | |
| 15 | 17 | // vector_ConstPtrSpecialBaseArray |
| ... | ... | @@ -17,6 +19,7 @@ test "comptime slice-sentinel in bounds (unterminated)" { |
| 17 | 19 | var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; |
| 18 | 20 | var target: [*]u8 = &buf; |
| 19 | 21 | const slice = target[0..3 :'d']; |
| 22 | _ = slice; | |
| 20 | 23 | } |
| 21 | 24 | |
| 22 | 25 | // vector_ConstPtrSpecialRef |
| ... | ... | @@ -24,6 +27,7 @@ test "comptime slice-sentinel in bounds (unterminated)" { |
| 24 | 27 | var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; |
| 25 | 28 | var target: [*]u8 = @ptrCast([*]u8, &buf); |
| 26 | 29 | const slice = target[0..3 :'d']; |
| 30 | _ = slice; | |
| 27 | 31 | } |
| 28 | 32 | |
| 29 | 33 | // cvector_ConstPtrSpecialBaseArray |
| ... | ... | @@ -31,6 +35,7 @@ test "comptime slice-sentinel in bounds (unterminated)" { |
| 31 | 35 | var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; |
| 32 | 36 | var target: [*c]u8 = &buf; |
| 33 | 37 | const slice = target[0..3 :'d']; |
| 38 | _ = slice; | |
| 34 | 39 | } |
| 35 | 40 | |
| 36 | 41 | // cvector_ConstPtrSpecialRef |
| ... | ... | @@ -38,6 +43,7 @@ test "comptime slice-sentinel in bounds (unterminated)" { |
| 38 | 43 | var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; |
| 39 | 44 | var target: [*c]u8 = @ptrCast([*c]u8, &buf); |
| 40 | 45 | const slice = target[0..3 :'d']; |
| 46 | _ = slice; | |
| 41 | 47 | } |
| 42 | 48 | |
| 43 | 49 | // slice |
| ... | ... | @@ -45,6 +51,7 @@ test "comptime slice-sentinel in bounds (unterminated)" { |
| 45 | 51 | var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; |
| 46 | 52 | var target: []u8 = &buf; |
| 47 | 53 | const slice = target[0..3 :'d']; |
| 54 | _ = slice; | |
| 48 | 55 | } |
| 49 | 56 | } |
| 50 | 57 | |
| ... | ... | @@ -53,6 +60,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" { |
| 53 | 60 | comptime { |
| 54 | 61 | var target = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10; |
| 55 | 62 | const slice = target[0..13 :0xff]; |
| 63 | _ = slice; | |
| 56 | 64 | } |
| 57 | 65 | |
| 58 | 66 | // ptr_array |
| ... | ... | @@ -60,6 +68,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" { |
| 60 | 68 | var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10; |
| 61 | 69 | var target = &buf; |
| 62 | 70 | const slice = target[0..13 :0xff]; |
| 71 | _ = slice; | |
| 63 | 72 | } |
| 64 | 73 | |
| 65 | 74 | // vector_ConstPtrSpecialBaseArray |
| ... | ... | @@ -67,6 +76,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" { |
| 67 | 76 | var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10; |
| 68 | 77 | var target: [*]u8 = &buf; |
| 69 | 78 | const slice = target[0..13 :0xff]; |
| 79 | _ = slice; | |
| 70 | 80 | } |
| 71 | 81 | |
| 72 | 82 | // vector_ConstPtrSpecialRef |
| ... | ... | @@ -74,6 +84,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" { |
| 74 | 84 | var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10; |
| 75 | 85 | var target: [*]u8 = @ptrCast([*]u8, &buf); |
| 76 | 86 | const slice = target[0..13 :0xff]; |
| 87 | _ = slice; | |
| 77 | 88 | } |
| 78 | 89 | |
| 79 | 90 | // cvector_ConstPtrSpecialBaseArray |
| ... | ... | @@ -81,6 +92,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" { |
| 81 | 92 | var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10; |
| 82 | 93 | var target: [*c]u8 = &buf; |
| 83 | 94 | const slice = target[0..13 :0xff]; |
| 95 | _ = slice; | |
| 84 | 96 | } |
| 85 | 97 | |
| 86 | 98 | // cvector_ConstPtrSpecialRef |
| ... | ... | @@ -88,6 +100,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" { |
| 88 | 100 | var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10; |
| 89 | 101 | var target: [*c]u8 = @ptrCast([*c]u8, &buf); |
| 90 | 102 | const slice = target[0..13 :0xff]; |
| 103 | _ = slice; | |
| 91 | 104 | } |
| 92 | 105 | |
| 93 | 106 | // slice |
| ... | ... | @@ -95,6 +108,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" { |
| 95 | 108 | var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10; |
| 96 | 109 | var target: []u8 = &buf; |
| 97 | 110 | const slice = target[0..13 :0xff]; |
| 111 | _ = slice; | |
| 98 | 112 | } |
| 99 | 113 | } |
| 100 | 114 | |
| ... | ... | @@ -103,6 +117,7 @@ test "comptime slice-sentinel in bounds (terminated)" { |
| 103 | 117 | comptime { |
| 104 | 118 | var target = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; |
| 105 | 119 | const slice = target[0..3 :'d']; |
| 120 | _ = slice; | |
| 106 | 121 | } |
| 107 | 122 | |
| 108 | 123 | // ptr_array |
| ... | ... | @@ -110,6 +125,7 @@ test "comptime slice-sentinel in bounds (terminated)" { |
| 110 | 125 | var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; |
| 111 | 126 | var target = &buf; |
| 112 | 127 | const slice = target[0..3 :'d']; |
| 128 | _ = slice; | |
| 113 | 129 | } |
| 114 | 130 | |
| 115 | 131 | // vector_ConstPtrSpecialBaseArray |
| ... | ... | @@ -117,6 +133,7 @@ test "comptime slice-sentinel in bounds (terminated)" { |
| 117 | 133 | var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; |
| 118 | 134 | var target: [*]u8 = &buf; |
| 119 | 135 | const slice = target[0..3 :'d']; |
| 136 | _ = slice; | |
| 120 | 137 | } |
| 121 | 138 | |
| 122 | 139 | // vector_ConstPtrSpecialRef |
| ... | ... | @@ -124,6 +141,7 @@ test "comptime slice-sentinel in bounds (terminated)" { |
| 124 | 141 | var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; |
| 125 | 142 | var target: [*]u8 = @ptrCast([*]u8, &buf); |
| 126 | 143 | const slice = target[0..3 :'d']; |
| 144 | _ = slice; | |
| 127 | 145 | } |
| 128 | 146 | |
| 129 | 147 | // cvector_ConstPtrSpecialBaseArray |
| ... | ... | @@ -131,6 +149,7 @@ test "comptime slice-sentinel in bounds (terminated)" { |
| 131 | 149 | var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; |
| 132 | 150 | var target: [*c]u8 = &buf; |
| 133 | 151 | const slice = target[0..3 :'d']; |
| 152 | _ = slice; | |
| 134 | 153 | } |
| 135 | 154 | |
| 136 | 155 | // cvector_ConstPtrSpecialRef |
| ... | ... | @@ -138,6 +157,7 @@ test "comptime slice-sentinel in bounds (terminated)" { |
| 138 | 157 | var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; |
| 139 | 158 | var target: [*c]u8 = @ptrCast([*c]u8, &buf); |
| 140 | 159 | const slice = target[0..3 :'d']; |
| 160 | _ = slice; | |
| 141 | 161 | } |
| 142 | 162 | |
| 143 | 163 | // slice |
| ... | ... | @@ -145,6 +165,7 @@ test "comptime slice-sentinel in bounds (terminated)" { |
| 145 | 165 | var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; |
| 146 | 166 | var target: []u8 = &buf; |
| 147 | 167 | const slice = target[0..3 :'d']; |
| 168 | _ = slice; | |
| 148 | 169 | } |
| 149 | 170 | } |
| 150 | 171 | |
| ... | ... | @@ -153,6 +174,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" { |
| 153 | 174 | comptime { |
| 154 | 175 | var target = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; |
| 155 | 176 | const slice = target[0..14 :0]; |
| 177 | _ = slice; | |
| 156 | 178 | } |
| 157 | 179 | |
| 158 | 180 | // ptr_array |
| ... | ... | @@ -160,6 +182,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" { |
| 160 | 182 | var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; |
| 161 | 183 | var target = &buf; |
| 162 | 184 | const slice = target[0..14 :0]; |
| 185 | _ = slice; | |
| 163 | 186 | } |
| 164 | 187 | |
| 165 | 188 | // vector_ConstPtrSpecialBaseArray |
| ... | ... | @@ -167,6 +190,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" { |
| 167 | 190 | var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; |
| 168 | 191 | var target: [*]u8 = &buf; |
| 169 | 192 | const slice = target[0..14 :0]; |
| 193 | _ = slice; | |
| 170 | 194 | } |
| 171 | 195 | |
| 172 | 196 | // vector_ConstPtrSpecialRef |
| ... | ... | @@ -174,6 +198,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" { |
| 174 | 198 | var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; |
| 175 | 199 | var target: [*]u8 = @ptrCast([*]u8, &buf); |
| 176 | 200 | const slice = target[0..14 :0]; |
| 201 | _ = slice; | |
| 177 | 202 | } |
| 178 | 203 | |
| 179 | 204 | // cvector_ConstPtrSpecialBaseArray |
| ... | ... | @@ -181,6 +206,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" { |
| 181 | 206 | var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; |
| 182 | 207 | var target: [*c]u8 = &buf; |
| 183 | 208 | const slice = target[0..14 :0]; |
| 209 | _ = slice; | |
| 184 | 210 | } |
| 185 | 211 | |
| 186 | 212 | // cvector_ConstPtrSpecialRef |
| ... | ... | @@ -188,6 +214,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" { |
| 188 | 214 | var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; |
| 189 | 215 | var target: [*c]u8 = @ptrCast([*c]u8, &buf); |
| 190 | 216 | const slice = target[0..14 :0]; |
| 217 | _ = slice; | |
| 191 | 218 | } |
| 192 | 219 | |
| 193 | 220 | // slice |
| ... | ... | @@ -195,5 +222,6 @@ test "comptime slice-sentinel in bounds (on target sentinel)" { |
| 195 | 222 | var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; |
| 196 | 223 | var target: []u8 = &buf; |
| 197 | 224 | const slice = target[0..14 :0]; |
| 225 | _ = slice; | |
| 198 | 226 | } |
| 199 | 227 | } |
test/behavior/struct.zig+10-3| ... | ... | @@ -182,6 +182,7 @@ test "empty struct method call" { |
| 182 | 182 | } |
| 183 | 183 | const EmptyStruct = struct { |
| 184 | 184 | fn method(es: *const EmptyStruct) i32 { |
| 185 | _ = es; | |
| 185 | 186 | return 1234; |
| 186 | 187 | } |
| 187 | 188 | }; |
| ... | ... | @@ -452,9 +453,11 @@ fn alloc(comptime T: type) []T { |
| 452 | 453 | test "call method with mutable reference to struct with no fields" { |
| 453 | 454 | const S = struct { |
| 454 | 455 | fn doC(s: *const @This()) bool { |
| 456 | _ = s; | |
| 455 | 457 | return true; |
| 456 | 458 | } |
| 457 | 459 | fn do(s: *@This()) bool { |
| 460 | _ = s; | |
| 458 | 461 | return true; |
| 459 | 462 | } |
| 460 | 463 | }; |
| ... | ... | @@ -584,13 +587,14 @@ test "default struct initialization fields" { |
| 584 | 587 | const x = S{ |
| 585 | 588 | .b = 5, |
| 586 | 589 | }; |
| 587 | if (x.a + x.b != 1239) { | |
| 588 | @compileError("it should be comptime known"); | |
| 589 | } | |
| 590 | 590 | var five: i32 = 5; |
| 591 | 591 | const y = S{ |
| 592 | 592 | .b = five, |
| 593 | 593 | }; |
| 594 | if (x.a + x.b != 1239) { | |
| 595 | @compileError("it should be comptime known"); | |
| 596 | } | |
| 597 | try expectEqual(y, x); | |
| 594 | 598 | try expectEqual(1239, x.a + x.b); |
| 595 | 599 | } |
| 596 | 600 | |
| ... | ... | @@ -624,11 +628,13 @@ test "for loop over pointers to struct, getting field from struct pointer" { |
| 624 | 628 | var ok = true; |
| 625 | 629 | |
| 626 | 630 | fn eql(a: []const u8) bool { |
| 631 | _ = a; | |
| 627 | 632 | return true; |
| 628 | 633 | } |
| 629 | 634 | |
| 630 | 635 | const ArrayList = struct { |
| 631 | 636 | fn toSlice(self: *ArrayList) []*Foo { |
| 637 | _ = self; | |
| 632 | 638 | return @as([*]*Foo, undefined)[0..0]; |
| 633 | 639 | } |
| 634 | 640 | }; |
| ... | ... | @@ -654,6 +660,7 @@ test "zero-bit field in packed struct" { |
| 654 | 660 | y: void, |
| 655 | 661 | }; |
| 656 | 662 | var x: S = undefined; |
| 663 | _ = x; | |
| 657 | 664 | } |
| 658 | 665 | |
| 659 | 666 | test "struct field init with catch" { |
test/behavior/switch.zig+15-3| ... | ... | @@ -103,6 +103,7 @@ fn switchProngWithVarFn(a: SwitchProngWithVarEnum) !void { |
| 103 | 103 | }, |
| 104 | 104 | SwitchProngWithVarEnum.Meh => |x| { |
| 105 | 105 | const v: void = x; |
| 106 | _ = v; | |
| 106 | 107 | }, |
| 107 | 108 | } |
| 108 | 109 | } |
| ... | ... | @@ -385,6 +386,7 @@ test "switch with null and T peer types and inferred result location type" { |
| 385 | 386 | 0 => true, |
| 386 | 387 | else => null, |
| 387 | 388 | }) |v| { |
| 389 | _ = v; | |
| 388 | 390 | @panic("fail"); |
| 389 | 391 | } |
| 390 | 392 | } |
| ... | ... | @@ -410,12 +412,18 @@ test "switch prongs with cases with identical payload types" { |
| 410 | 412 | try expect(@TypeOf(e) == usize); |
| 411 | 413 | try expect(e == 8); |
| 412 | 414 | }, |
| 413 | .B => |e| @panic("fail"), | |
| 415 | .B => |e| { | |
| 416 | _ = e; | |
| 417 | @panic("fail"); | |
| 418 | }, | |
| 414 | 419 | } |
| 415 | 420 | } |
| 416 | 421 | fn doTheSwitch2(u: Union) !void { |
| 417 | 422 | switch (u) { |
| 418 | .A, .C => |e| @panic("fail"), | |
| 423 | .A, .C => |e| { | |
| 424 | _ = e; | |
| 425 | @panic("fail"); | |
| 426 | }, | |
| 419 | 427 | .B => |e| { |
| 420 | 428 | try expect(@TypeOf(e) == isize); |
| 421 | 429 | try expect(e == -8); |
| ... | ... | @@ -454,6 +462,7 @@ test "switch variable for range and multiple prongs" { |
| 454 | 462 | } |
| 455 | 463 | } |
| 456 | 464 | }; |
| 465 | _ = S; | |
| 457 | 466 | } |
| 458 | 467 | |
| 459 | 468 | var state: u32 = 0; |
| ... | ... | @@ -506,7 +515,10 @@ test "switch on error set with single else" { |
| 506 | 515 | fn doTheTest() !void { |
| 507 | 516 | var some: error{Foo} = error.Foo; |
| 508 | 517 | try expect(switch (some) { |
| 509 | else => |a| true, | |
| 518 | else => |a| blk: { | |
| 519 | a catch {}; | |
| 520 | break :blk true; | |
| 521 | }, | |
| 510 | 522 | }); |
| 511 | 523 | } |
| 512 | 524 | }; |
test/behavior/tuple.zig+1| ... | ... | @@ -105,6 +105,7 @@ test "tuple initializer for var" { |
| 105 | 105 | .id = @as(usize, 2), |
| 106 | 106 | .name = Bytes{ .id = 20 }, |
| 107 | 107 | }; |
| 108 | _ = tmp; | |
| 108 | 109 | } |
| 109 | 110 | }; |
| 110 | 111 |
test/behavior/type.zig+6-1| ... | ... | @@ -431,11 +431,14 @@ test "Type.Fn" { |
| 431 | 431 | |
| 432 | 432 | const foo = struct { |
| 433 | 433 | fn func(a: usize, b: bool) align(4) callconv(.C) usize { |
| 434 | _ = a; | |
| 435 | _ = b; | |
| 434 | 436 | return 0; |
| 435 | 437 | } |
| 436 | 438 | }.func; |
| 437 | 439 | const Foo = @Type(@typeInfo(@TypeOf(foo))); |
| 438 | 440 | const foo_2: Foo = foo; |
| 441 | _ = foo_2; | |
| 439 | 442 | } |
| 440 | 443 | |
| 441 | 444 | test "Type.BoundFn" { |
| ... | ... | @@ -443,7 +446,9 @@ test "Type.BoundFn" { |
| 443 | 446 | if (builtin.target.cpu.arch == .wasm32 or builtin.target.cpu.arch == .wasm64) return error.SkipZigTest; |
| 444 | 447 | |
| 445 | 448 | const TestStruct = packed struct { |
| 446 | pub fn foo(self: *const @This()) align(4) callconv(.Unspecified) void {} | |
| 449 | pub fn foo(self: *const @This()) align(4) callconv(.Unspecified) void { | |
| 450 | _ = self; | |
| 451 | } | |
| 447 | 452 | }; |
| 448 | 453 | const test_instance: TestStruct = undefined; |
| 449 | 454 | try testing.expect(std.meta.eql( |
test/behavior/type_info.zig+8-2| ... | ... | @@ -277,7 +277,9 @@ const TestStruct = packed struct { |
| 277 | 277 | fieldC: *Self, |
| 278 | 278 | fieldD: u32 = 4, |
| 279 | 279 | |
| 280 | pub fn foo(self: *const Self) void {} | |
| 280 | pub fn foo(self: *const Self) void { | |
| 281 | _ = self; | |
| 282 | } | |
| 281 | 283 | const Self = @This(); |
| 282 | 284 | }; |
| 283 | 285 | |
| ... | ... | @@ -326,9 +328,12 @@ extern fn fooAligned(a: usize, b: bool, ...) align(4) callconv(.C) usize; |
| 326 | 328 | |
| 327 | 329 | test "typeInfo with comptime parameter in struct fn def" { |
| 328 | 330 | const S = struct { |
| 329 | pub fn func(comptime x: f32) void {} | |
| 331 | pub fn func(comptime x: f32) void { | |
| 332 | _ = x; | |
| 333 | } | |
| 330 | 334 | }; |
| 331 | 335 | comptime var info = @typeInfo(S); |
| 336 | _ = info; | |
| 332 | 337 | } |
| 333 | 338 | |
| 334 | 339 | test "type info: vectors" { |
| ... | ... | @@ -368,6 +373,7 @@ test "type info: pass to function" { |
| 368 | 373 | } |
| 369 | 374 | |
| 370 | 375 | fn passTypeInfo(comptime info: TypeInfo) type { |
| 376 | _ = info; | |
| 371 | 377 | return void; |
| 372 | 378 | } |
| 373 | 379 |
test/behavior/underscore.zig+2| ... | ... | @@ -7,7 +7,9 @@ test "ignore lval with underscore" { |
| 7 | 7 | |
| 8 | 8 | test "ignore lval with underscore (for loop)" { |
| 9 | 9 | for ([_]void{}) |_, i| { |
| 10 | _ = i; | |
| 10 | 11 | for ([_]void{}) |_, j| { |
| 12 | _ = j; | |
| 11 | 13 | break; |
| 12 | 14 | } |
| 13 | 15 | break; |
test/behavior/union.zig+9-2| ... | ... | @@ -374,7 +374,9 @@ const Attribute = union(enum) { |
| 374 | 374 | B: u8, |
| 375 | 375 | }; |
| 376 | 376 | |
| 377 | fn setAttribute(attr: Attribute) void {} | |
| 377 | fn setAttribute(attr: Attribute) void { | |
| 378 | _ = attr; | |
| 379 | } | |
| 378 | 380 | |
| 379 | 381 | fn Setter(attr: Attribute) type { |
| 380 | 382 | return struct { |
| ... | ... | @@ -465,7 +467,9 @@ test "union no tag with struct member" { |
| 465 | 467 | const Struct = struct {}; |
| 466 | 468 | const Union = union { |
| 467 | 469 | s: Struct, |
| 468 | pub fn foo(self: *@This()) void {} | |
| 470 | pub fn foo(self: *@This()) void { | |
| 471 | _ = self; | |
| 472 | } | |
| 469 | 473 | }; |
| 470 | 474 | var u = Union{ .s = Struct{} }; |
| 471 | 475 | u.foo(); |
| ... | ... | @@ -703,6 +707,7 @@ test "method call on an empty union" { |
| 703 | 707 | X2: [0]u8, |
| 704 | 708 | |
| 705 | 709 | pub fn useIt(self: *@This()) bool { |
| 710 | _ = self; | |
| 706 | 711 | return true; |
| 707 | 712 | } |
| 708 | 713 | }; |
| ... | ... | @@ -771,6 +776,7 @@ test "@unionInit on union w/ tag but no fields" { |
| 771 | 776 | no_op: void, |
| 772 | 777 | |
| 773 | 778 | pub fn decode(buf: []const u8) Data { |
| 779 | _ = buf; | |
| 774 | 780 | return @unionInit(Data, "no_op", {}); |
| 775 | 781 | } |
| 776 | 782 | }; |
| ... | ... | @@ -781,6 +787,7 @@ test "@unionInit on union w/ tag but no fields" { |
| 781 | 787 | |
| 782 | 788 | fn doTheTest() !void { |
| 783 | 789 | var data: Data = .{ .no_op = .{} }; |
| 790 | _ = data; | |
| 784 | 791 | var o = Data.decode(&[_]u8{}); |
| 785 | 792 | try expectEqual(Type.no_op, o); |
| 786 | 793 | } |
test/behavior/var_args.zig+5-2| ... | ... | @@ -18,7 +18,7 @@ test "add arbitrary args" { |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | fn readFirstVarArg(args: anytype) void { |
| 21 | const value = args[0]; | |
| 21 | _ = args[0]; | |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | test "send void arg to var args" { |
| ... | ... | @@ -48,6 +48,7 @@ test "runtime parameter before var args" { |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | fn extraFn(extra: u32, args: anytype) !usize { |
| 51 | _ = extra; | |
| 51 | 52 | if (args.len >= 1) { |
| 52 | 53 | try expect(args[0] == false); |
| 53 | 54 | } |
| ... | ... | @@ -63,9 +64,11 @@ const foos = [_]fn (anytype) bool{ |
| 63 | 64 | }; |
| 64 | 65 | |
| 65 | 66 | fn foo1(args: anytype) bool { |
| 67 | _ = args; | |
| 66 | 68 | return true; |
| 67 | 69 | } |
| 68 | 70 | fn foo2(args: anytype) bool { |
| 71 | _ = args; | |
| 69 | 72 | return false; |
| 70 | 73 | } |
| 71 | 74 | |
| ... | ... | @@ -79,5 +82,5 @@ test "pass zero length array to var args param" { |
| 79 | 82 | } |
| 80 | 83 | |
| 81 | 84 | fn doNothingWithFirstArg(args: anytype) void { |
| 82 | const a = args[0]; | |
| 85 | _ = args[0]; | |
| 83 | 86 | } |
test/behavior/vector.zig+2| ... | ... | @@ -113,6 +113,7 @@ test "array to vector" { |
| 113 | 113 | var foo: f32 = 3.14; |
| 114 | 114 | var arr = [4]f32{ foo, 1.5, 0.0, 0.0 }; |
| 115 | 115 | var vec: Vector(4, f32) = arr; |
| 116 | _ = vec; | |
| 116 | 117 | } |
| 117 | 118 | |
| 118 | 119 | test "vector casts of sizes not divisable by 8" { |
| ... | ... | @@ -264,6 +265,7 @@ test "initialize vector which is a struct field" { |
| 264 | 265 | var foo = Vec4Obj{ |
| 265 | 266 | .data = [_]f32{ 1, 2, 3, 4 }, |
| 266 | 267 | }; |
| 268 | _ = foo; | |
| 267 | 269 | } |
| 268 | 270 | }; |
| 269 | 271 | try S.doTheTest(); |
test/behavior/void.zig+1-1| ... | ... | @@ -36,5 +36,5 @@ test "void optional" { |
| 36 | 36 | |
| 37 | 37 | test "void array as a local variable initializer" { |
| 38 | 38 | var x = [_]void{{}} ** 1004; |
| 39 | var y = x[0]; | |
| 39 | _ = x[0]; | |
| 40 | 40 | } |
test/behavior/while.zig+2-2| ... | ... | @@ -151,14 +151,14 @@ test "while on optional with else result follow break prong" { |
| 151 | 151 | test "while on error union with else result follow else prong" { |
| 152 | 152 | const result = while (returnError()) |value| { |
| 153 | 153 | break value; |
| 154 | } else |err| @as(i32, 2); | |
| 154 | } else |_| @as(i32, 2); | |
| 155 | 155 | try expect(result == 2); |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | test "while on error union with else result follow break prong" { |
| 159 | 159 | const result = while (returnSuccess(10)) |value| { |
| 160 | 160 | break value; |
| 161 | } else |err| @as(i32, 2); | |
| 161 | } else |_| @as(i32, 2); | |
| 162 | 162 | try expect(result == 10); |
| 163 | 163 | } |
| 164 | 164 |
test/stage2/cbe.zig+37-28| ... | ... | @@ -93,16 +93,16 @@ pub fn addCases(ctx: *TestContext) !void { |
| 93 | 93 | , ""); |
| 94 | 94 | case.addError( |
| 95 | 95 | \\pub export fn main() c_int { |
| 96 | \\ const c = @intToError(0); | |
| 96 | \\ _ = @intToError(0); | |
| 97 | 97 | \\ return 0; |
| 98 | 98 | \\} |
| 99 | , &.{":2:27: error: integer value 0 represents no error"}); | |
| 99 | , &.{":2:21: error: integer value 0 represents no error"}); | |
| 100 | 100 | case.addError( |
| 101 | 101 | \\pub export fn main() c_int { |
| 102 | \\ const c = @intToError(3); | |
| 102 | \\ _ = @intToError(3); | |
| 103 | 103 | \\ return 0; |
| 104 | 104 | \\} |
| 105 | , &.{":2:27: error: integer value 3 represents no error"}); | |
| 105 | , &.{":2:21: error: integer value 3 represents no error"}); | |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | { |
| ... | ... | @@ -383,6 +383,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 383 | 383 | \\ true => 2, |
| 384 | 384 | \\ false => 3, |
| 385 | 385 | \\ }; |
| 386 | \\ _ = b; | |
| 386 | 387 | \\} |
| 387 | 388 | , &.{ |
| 388 | 389 | ":6:9: error: duplicate switch value", |
| ... | ... | @@ -398,6 +399,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 398 | 399 | \\ f64, i32 => 3, |
| 399 | 400 | \\ else => 4, |
| 400 | 401 | \\ }; |
| 402 | \\ _ = b; | |
| 401 | 403 | \\} |
| 402 | 404 | , &.{ |
| 403 | 405 | ":6:14: error: duplicate switch value", |
| ... | ... | @@ -414,6 +416,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 414 | 416 | \\ f16...f64 => 3, |
| 415 | 417 | \\ else => 4, |
| 416 | 418 | \\ }; |
| 419 | \\ _ = b; | |
| 417 | 420 | \\} |
| 418 | 421 | , &.{ |
| 419 | 422 | ":3:30: error: ranges not allowed when switching on type 'type'", |
| ... | ... | @@ -431,6 +434,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 431 | 434 | \\ 3 => 40, |
| 432 | 435 | \\ else => 50, |
| 433 | 436 | \\ }; |
| 437 | \\ _ = b; | |
| 434 | 438 | \\} |
| 435 | 439 | , &.{ |
| 436 | 440 | ":8:14: error: unreachable else prong; all cases already handled", |
| ... | ... | @@ -556,10 +560,10 @@ pub fn addCases(ctx: *TestContext) !void { |
| 556 | 560 | \\const E1 = packed enum { a, b, c }; |
| 557 | 561 | \\const E2 = extern enum { a, b, c }; |
| 558 | 562 | \\export fn foo() void { |
| 559 | \\ const x = E1.a; | |
| 563 | \\ _ = E1.a; | |
| 560 | 564 | \\} |
| 561 | 565 | \\export fn bar() void { |
| 562 | \\ const x = E2.a; | |
| 566 | \\ _ = E2.a; | |
| 563 | 567 | \\} |
| 564 | 568 | , &.{ |
| 565 | 569 | ":1:12: error: enums do not support 'packed' or 'extern'; instead provide an explicit integer tag type", |
| ... | ... | @@ -579,10 +583,10 @@ pub fn addCases(ctx: *TestContext) !void { |
| 579 | 583 | \\ c, |
| 580 | 584 | \\}; |
| 581 | 585 | \\export fn foo() void { |
| 582 | \\ const x = E1.a; | |
| 586 | \\ _ = E1.a; | |
| 583 | 587 | \\} |
| 584 | 588 | \\export fn bar() void { |
| 585 | \\ const x = E2.a; | |
| 589 | \\ _ = E2.a; | |
| 586 | 590 | \\} |
| 587 | 591 | , &.{ |
| 588 | 592 | ":3:5: error: enum fields cannot be marked comptime", |
| ... | ... | @@ -621,7 +625,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 621 | 625 | \\ c, |
| 622 | 626 | \\}; |
| 623 | 627 | \\export fn foo() void { |
| 624 | \\ const x = E1.a; | |
| 628 | \\ _ = E1.a; | |
| 625 | 629 | \\} |
| 626 | 630 | , &.{ |
| 627 | 631 | ":3:7: error: expected ',', found 'align'", |
| ... | ... | @@ -638,7 +642,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 638 | 642 | \\ _, |
| 639 | 643 | \\}; |
| 640 | 644 | \\export fn foo() void { |
| 641 | \\ const x = E1.a; | |
| 645 | \\ _ = E1.a; | |
| 642 | 646 | \\} |
| 643 | 647 | , &.{ |
| 644 | 648 | ":6:5: error: redundant non-exhaustive enum mark", |
| ... | ... | @@ -653,7 +657,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 653 | 657 | \\ _ = 10, |
| 654 | 658 | \\}; |
| 655 | 659 | \\export fn foo() void { |
| 656 | \\ const x = E1.a; | |
| 660 | \\ _ = E1.a; | |
| 657 | 661 | \\} |
| 658 | 662 | , &.{ |
| 659 | 663 | ":5:9: error: '_' is used to mark an enum as non-exhaustive and cannot be assigned a value", |
| ... | ... | @@ -662,7 +666,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 662 | 666 | case.addError( |
| 663 | 667 | \\const E1 = enum {}; |
| 664 | 668 | \\export fn foo() void { |
| 665 | \\ const x = E1.a; | |
| 669 | \\ _ = E1.a; | |
| 666 | 670 | \\} |
| 667 | 671 | , &.{ |
| 668 | 672 | ":1:12: error: enum declarations must have at least one tag", |
| ... | ... | @@ -671,7 +675,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 671 | 675 | case.addError( |
| 672 | 676 | \\const E1 = enum { a, b, _ }; |
| 673 | 677 | \\export fn foo() void { |
| 674 | \\ const x = E1.a; | |
| 678 | \\ _ = E1.a; | |
| 675 | 679 | \\} |
| 676 | 680 | , &.{ |
| 677 | 681 | ":1:12: error: non-exhaustive enum missing integer tag type", |
| ... | ... | @@ -681,7 +685,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 681 | 685 | case.addError( |
| 682 | 686 | \\const E1 = enum { a, b, c, b, d }; |
| 683 | 687 | \\pub export fn main() c_int { |
| 684 | \\ const x = E1.a; | |
| 688 | \\ _ = E1.a; | |
| 685 | 689 | \\} |
| 686 | 690 | , &.{ |
| 687 | 691 | ":1:28: error: duplicate enum tag", |
| ... | ... | @@ -691,28 +695,28 @@ pub fn addCases(ctx: *TestContext) !void { |
| 691 | 695 | case.addError( |
| 692 | 696 | \\pub export fn main() c_int { |
| 693 | 697 | \\ const a = true; |
| 694 | \\ const b = @enumToInt(a); | |
| 698 | \\ _ = @enumToInt(a); | |
| 695 | 699 | \\} |
| 696 | 700 | , &.{ |
| 697 | ":3:26: error: expected enum or tagged union, found bool", | |
| 701 | ":3:20: error: expected enum or tagged union, found bool", | |
| 698 | 702 | }); |
| 699 | 703 | |
| 700 | 704 | case.addError( |
| 701 | 705 | \\pub export fn main() c_int { |
| 702 | 706 | \\ const a = 1; |
| 703 | \\ const b = @intToEnum(bool, a); | |
| 707 | \\ _ = @intToEnum(bool, a); | |
| 704 | 708 | \\} |
| 705 | 709 | , &.{ |
| 706 | ":3:26: error: expected enum, found bool", | |
| 710 | ":3:20: error: expected enum, found bool", | |
| 707 | 711 | }); |
| 708 | 712 | |
| 709 | 713 | case.addError( |
| 710 | 714 | \\const E = enum { a, b, c }; |
| 711 | 715 | \\pub export fn main() c_int { |
| 712 | \\ const b = @intToEnum(E, 3); | |
| 716 | \\ _ = @intToEnum(E, 3); | |
| 713 | 717 | \\} |
| 714 | 718 | , &.{ |
| 715 | ":3:15: error: enum 'test_case.E' has no tag with value 3", | |
| 719 | ":3:9: error: enum 'test_case.E' has no tag with value 3", | |
| 716 | 720 | ":1:11: note: enum declared here", |
| 717 | 721 | }); |
| 718 | 722 | |
| ... | ... | @@ -780,10 +784,10 @@ pub fn addCases(ctx: *TestContext) !void { |
| 780 | 784 | case.addError( |
| 781 | 785 | \\const E = enum { a, b, c }; |
| 782 | 786 | \\pub export fn main() c_int { |
| 783 | \\ var x = E.d; | |
| 787 | \\ _ = E.d; | |
| 784 | 788 | \\} |
| 785 | 789 | , &.{ |
| 786 | ":3:14: error: enum 'test_case.E' has no member named 'd'", | |
| 790 | ":3:10: error: enum 'test_case.E' has no member named 'd'", | |
| 787 | 791 | ":1:11: note: enum declared here", |
| 788 | 792 | }); |
| 789 | 793 | |
| ... | ... | @@ -791,6 +795,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 791 | 795 | \\const E = enum { a, b, c }; |
| 792 | 796 | \\pub export fn main() c_int { |
| 793 | 797 | \\ var x: E = .d; |
| 798 | \\ _ = x; | |
| 794 | 799 | \\} |
| 795 | 800 | , &.{ |
| 796 | 801 | ":3:17: error: enum 'test_case.E' has no field named 'd'", |
| ... | ... | @@ -818,31 +823,35 @@ pub fn addCases(ctx: *TestContext) !void { |
| 818 | 823 | \\ |
| 819 | 824 | ); |
| 820 | 825 | ctx.h("header with single param function", linux_x64, |
| 821 | \\export fn start(a: u8) void{} | |
| 826 | \\export fn start(a: u8) void{ | |
| 827 | \\ _ = a; | |
| 828 | \\} | |
| 822 | 829 | , |
| 823 | 830 | \\ZIG_EXTERN_C void start(uint8_t a0); |
| 824 | 831 | \\ |
| 825 | 832 | ); |
| 826 | 833 | ctx.h("header with multiple param function", linux_x64, |
| 827 | \\export fn start(a: u8, b: u8, c: u8) void{} | |
| 834 | \\export fn start(a: u8, b: u8, c: u8) void{ | |
| 835 | \\ _ = a; _ = b; _ = c; | |
| 836 | \\} | |
| 828 | 837 | , |
| 829 | 838 | \\ZIG_EXTERN_C void start(uint8_t a0, uint8_t a1, uint8_t a2); |
| 830 | 839 | \\ |
| 831 | 840 | ); |
| 832 | 841 | ctx.h("header with u32 param function", linux_x64, |
| 833 | \\export fn start(a: u32) void{} | |
| 842 | \\export fn start(a: u32) void{ _ = a; } | |
| 834 | 843 | , |
| 835 | 844 | \\ZIG_EXTERN_C void start(uint32_t a0); |
| 836 | 845 | \\ |
| 837 | 846 | ); |
| 838 | 847 | ctx.h("header with usize param function", linux_x64, |
| 839 | \\export fn start(a: usize) void{} | |
| 848 | \\export fn start(a: usize) void{ _ = a; } | |
| 840 | 849 | , |
| 841 | 850 | \\ZIG_EXTERN_C void start(uintptr_t a0); |
| 842 | 851 | \\ |
| 843 | 852 | ); |
| 844 | 853 | ctx.h("header with bool param function", linux_x64, |
| 845 | \\export fn start(a: bool) void{} | |
| 854 | \\export fn start(a: bool) void{_ = a;} | |
| 846 | 855 | , |
| 847 | 856 | \\ZIG_EXTERN_C void start(bool a0); |
| 848 | 857 | \\ |
| ... | ... | @@ -866,7 +875,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 866 | 875 | \\ |
| 867 | 876 | ); |
| 868 | 877 | ctx.h("header with multiple includes", linux_x64, |
| 869 | \\export fn start(a: u32, b: usize) void{} | |
| 878 | \\export fn start(a: u32, b: usize) void{ _ = a; _ = b; } | |
| 870 | 879 | , |
| 871 | 880 | \\ZIG_EXTERN_C void start(uint32_t a0, uintptr_t a1); |
| 872 | 881 | \\ |
test/stage2/test.zig+27-10| ... | ... | @@ -246,11 +246,20 @@ pub fn addCases(ctx: *TestContext) !void { |
| 246 | 246 | "", |
| 247 | 247 | ); |
| 248 | 248 | } |
| 249 | { | |
| 250 | var case = ctx.exe("unused vars", linux_x64); | |
| 251 | case.addError( | |
| 252 | \\pub fn main() void { | |
| 253 | \\ const x = 1; | |
| 254 | \\} | |
| 255 | , &.{":2:11: error: unused local constant"}); | |
| 256 | } | |
| 249 | 257 | { |
| 250 | 258 | var case = ctx.exe("@TypeOf", linux_x64); |
| 251 | 259 | case.addCompareOutput( |
| 252 | 260 | \\pub fn main() void { |
| 253 | 261 | \\ var x: usize = 0; |
| 262 | \\ _ = x; | |
| 254 | 263 | \\ const z = @TypeOf(x, @as(u128, 5)); |
| 255 | 264 | \\ assert(z == u128); |
| 256 | 265 | \\} |
| ... | ... | @@ -275,9 +284,9 @@ pub fn addCases(ctx: *TestContext) !void { |
| 275 | 284 | ); |
| 276 | 285 | case.addError( |
| 277 | 286 | \\pub fn main() void { |
| 278 | \\ const z = @TypeOf(true, 1); | |
| 287 | \\ _ = @TypeOf(true, 1); | |
| 279 | 288 | \\} |
| 280 | , &[_][]const u8{":2:15: error: incompatible types: 'bool' and 'comptime_int'"}); | |
| 289 | , &[_][]const u8{":2:9: error: incompatible types: 'bool' and 'comptime_int'"}); | |
| 281 | 290 | } |
| 282 | 291 | |
| 283 | 292 | { |
| ... | ... | @@ -738,6 +747,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 738 | 747 | \\ \\ cool thx |
| 739 | 748 | \\ \\ |
| 740 | 749 | \\ ; |
| 750 | \\ _ = ignore; | |
| 741 | 751 | \\ add('ぁ', '\x03'); |
| 742 | 752 | \\} |
| 743 | 753 | \\ |
| ... | ... | @@ -889,6 +899,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 889 | 899 | \\ try expect(false); |
| 890 | 900 | \\ } |
| 891 | 901 | \\ }; |
| 902 | \\ _ = S; | |
| 892 | 903 | \\} |
| 893 | 904 | , |
| 894 | 905 | &.{":4:13: error: invalid 'try' outside function scope"}, |
| ... | ... | @@ -979,6 +990,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 979 | 990 | \\ return bar; |
| 980 | 991 | \\ } |
| 981 | 992 | \\ }; |
| 993 | \\ _ = S; | |
| 982 | 994 | \\} |
| 983 | 995 | , &.{ |
| 984 | 996 | ":5:20: error: 'bar' not accessible from inner function", |
| ... | ... | @@ -1064,6 +1076,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 1064 | 1076 | \\ @compileLog(b, 20, f, x); |
| 1065 | 1077 | \\ @compileLog(1000); |
| 1066 | 1078 | \\ var bruh: usize = true; |
| 1079 | \\ _ = bruh; | |
| 1067 | 1080 | \\ unreachable; |
| 1068 | 1081 | \\} |
| 1069 | 1082 | \\export fn other() void { |
| ... | ... | @@ -1209,6 +1222,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 1209 | 1222 | case.addError( |
| 1210 | 1223 | \\pub fn main() void { |
| 1211 | 1224 | \\ var x = null; |
| 1225 | \\ _ = x; | |
| 1212 | 1226 | \\} |
| 1213 | 1227 | , &[_][]const u8{ |
| 1214 | 1228 | ":2:9: error: variable of type '@Type(.Null)' must be const or comptime", |
| ... | ... | @@ -1378,7 +1392,9 @@ pub fn addCases(ctx: *TestContext) !void { |
| 1378 | 1392 | \\pub fn main() void { |
| 1379 | 1393 | \\ doNothing(0); |
| 1380 | 1394 | \\} |
| 1381 | \\fn doNothing(arg: u0) void {} | |
| 1395 | \\fn doNothing(arg: u0) void { | |
| 1396 | \\ _ = arg; | |
| 1397 | \\} | |
| 1382 | 1398 | , |
| 1383 | 1399 | "", |
| 1384 | 1400 | ); |
| ... | ... | @@ -1448,14 +1464,14 @@ pub fn addCases(ctx: *TestContext) !void { |
| 1448 | 1464 | case.addCompareOutput( |
| 1449 | 1465 | \\pub fn main() void { |
| 1450 | 1466 | \\ const E = error{ A, B, D } || error { A, B, C }; |
| 1451 | \\ const a = E.A; | |
| 1452 | \\ const b = E.B; | |
| 1453 | \\ const c = E.C; | |
| 1454 | \\ const d = E.D; | |
| 1467 | \\ E.A catch {}; | |
| 1468 | \\ E.B catch {}; | |
| 1469 | \\ E.C catch {}; | |
| 1470 | \\ E.D catch {}; | |
| 1455 | 1471 | \\ const E2 = error { X, Y } || @TypeOf(error.Z); |
| 1456 | \\ const x = E2.X; | |
| 1457 | \\ const y = E2.Y; | |
| 1458 | \\ const z = E2.Z; | |
| 1472 | \\ E2.X catch {}; | |
| 1473 | \\ E2.Y catch {}; | |
| 1474 | \\ E2.Z catch {}; | |
| 1459 | 1475 | \\ assert(anyerror || error { Z } == anyerror); |
| 1460 | 1476 | \\} |
| 1461 | 1477 | \\fn assert(b: bool) void { |
| ... | ... | @@ -1477,6 +1493,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 1477 | 1493 | \\ [arg1] "{rdi}" (code) |
| 1478 | 1494 | \\ : "rcx", "r11", "memory" |
| 1479 | 1495 | \\ ); |
| 1496 | \\ _ = x; | |
| 1480 | 1497 | \\} |
| 1481 | 1498 | , &[_][]const u8{":4:27: error: expected type, found comptime_int"}); |
| 1482 | 1499 | } |
test/stage2/wasm.zig+11-1| ... | ... | @@ -64,7 +64,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 64 | 64 | \\ foo(10, 20); |
| 65 | 65 | \\ return 5; |
| 66 | 66 | \\} |
| 67 | \\fn foo(x: u32, y: u32) void {} | |
| 67 | \\fn foo(x: u32, y: u32) void { _ = x; _ = y; } | |
| 68 | 68 | , "5\n"); |
| 69 | 69 | } |
| 70 | 70 | |
| ... | ... | @@ -76,6 +76,10 @@ pub fn addCases(ctx: *TestContext) !void { |
| 76 | 76 | \\ var i: u32 = 5; |
| 77 | 77 | \\ var y: f32 = 42.0; |
| 78 | 78 | \\ var x: u32 = 10; |
| 79 | \\ if (false) { | |
| 80 | \\ y; | |
| 81 | \\ x; | |
| 82 | \\ } | |
| 79 | 83 | \\ return i; |
| 80 | 84 | \\} |
| 81 | 85 | , "5\n"); |
| ... | ... | @@ -84,12 +88,14 @@ pub fn addCases(ctx: *TestContext) !void { |
| 84 | 88 | \\pub export fn _start() u32 { |
| 85 | 89 | \\ var i: u32 = 5; |
| 86 | 90 | \\ var y: f32 = 42.0; |
| 91 | \\ _ = y; | |
| 87 | 92 | \\ var x: u32 = 10; |
| 88 | 93 | \\ foo(i, x); |
| 89 | 94 | \\ i = x; |
| 90 | 95 | \\ return i; |
| 91 | 96 | \\} |
| 92 | 97 | \\fn foo(x: u32, y: u32) void { |
| 98 | \\ _ = y; | |
| 93 | 99 | \\ var i: u32 = 10; |
| 94 | 100 | \\ i = x; |
| 95 | 101 | \\} |
| ... | ... | @@ -388,6 +394,10 @@ pub fn addCases(ctx: *TestContext) !void { |
| 388 | 394 | \\pub export fn _start() i32 { |
| 389 | 395 | \\ var number1 = Number.One; |
| 390 | 396 | \\ var number2: Number = .Two; |
| 397 | \\ if (false) { | |
| 398 | \\ number1; | |
| 399 | \\ number2; | |
| 400 | \\ } | |
| 391 | 401 | \\ const number3 = @intToEnum(Number, 2); |
| 392 | 402 | \\ |
| 393 | 403 | \\ return @enumToInt(number3); |
test/standalone/hello_world/hello_libc.zig+2| ... | ... | @@ -8,6 +8,8 @@ const c = @cImport({ |
| 8 | 8 | const msg = "Hello, world!\n"; |
| 9 | 9 | |
| 10 | 10 | pub export fn main(argc: c_int, argv: **u8) c_int { |
| 11 | _ = argv; | |
| 12 | _ = argc; | |
| 11 | 13 | if (c.printf(msg) != @intCast(c_int, c.strlen(msg))) return -1; |
| 12 | 14 | return 0; |
| 13 | 15 | } |
test/standalone/issue_339/test.zig+2| ... | ... | @@ -1,5 +1,7 @@ |
| 1 | 1 | const StackTrace = @import("std").builtin.StackTrace; |
| 2 | 2 | pub fn panic(msg: []const u8, stack_trace: ?*StackTrace) noreturn { |
| 3 | _ = msg; | |
| 4 | _ = stack_trace; | |
| 3 | 5 | @breakpoint(); |
| 4 | 6 | while (true) {} |
| 5 | 7 | } |
test/standalone/issue_8550/main.zig+5| ... | ... | @@ -1,6 +1,11 @@ |
| 1 | 1 | export fn main(r0: u32, r1: u32, atags: u32) callconv(.C) noreturn { |
| 2 | _ = r0; | |
| 3 | _ = r1; | |
| 4 | _ = atags; | |
| 2 | 5 | unreachable; // never gets run so it doesn't matter |
| 3 | 6 | } |
| 4 | 7 | pub fn panic(msg: []const u8, error_return_trace: ?*@import("std").builtin.StackTrace) noreturn { |
| 8 | _ = msg; | |
| 9 | _ = error_return_trace; | |
| 5 | 10 | while (true) {} |
| 6 | 11 | } |
test/tests.zig+2-1| ... | ... | @@ -417,6 +417,8 @@ pub fn addStandaloneTests(b: *build.Builder, test_filter: ?[]const u8, modes: [] |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | pub fn addCliTests(b: *build.Builder, test_filter: ?[]const u8, modes: []const Mode) *build.Step { |
| 420 | _ = test_filter; | |
| 421 | _ = modes; | |
| 420 | 422 | const step = b.step("test-cli", "Test the command line interface"); |
| 421 | 423 | |
| 422 | 424 | const exe = b.addExecutable("test-cli", "test/cli.zig"); |
| ... | ... | @@ -525,7 +527,6 @@ pub fn addPkgTests( |
| 525 | 527 | if (skip_single_threaded and test_target.single_threaded) |
| 526 | 528 | continue; |
| 527 | 529 | |
| 528 | const ArchTag = std.meta.Tag(std.Target.Cpu.Arch); | |
| 529 | 530 | if (test_target.disable_native and |
| 530 | 531 | test_target.target.getOsTag() == std.Target.current.os.tag and |
| 531 | 532 | test_target.target.getCpuArch() == std.Target.current.cpu.arch) |
tools/process_headers.zig+3| ... | ... | @@ -236,12 +236,14 @@ const DestTarget = struct { |
| 236 | 236 | |
| 237 | 237 | const HashContext = struct { |
| 238 | 238 | pub fn hash(self: @This(), a: DestTarget) u32 { |
| 239 | _ = self; | |
| 239 | 240 | return @enumToInt(a.arch) +% |
| 240 | 241 | (@enumToInt(a.os) *% @as(u32, 4202347608)) +% |
| 241 | 242 | (@enumToInt(a.abi) *% @as(u32, 4082223418)); |
| 242 | 243 | } |
| 243 | 244 | |
| 244 | 245 | pub fn eql(self: @This(), a: DestTarget, b: DestTarget) bool { |
| 246 | _ = self; | |
| 245 | 247 | return a.arch.eql(b.arch) and |
| 246 | 248 | a.os == b.os and |
| 247 | 249 | a.abi == b.abi; |
| ... | ... | @@ -256,6 +258,7 @@ const Contents = struct { |
| 256 | 258 | is_generic: bool, |
| 257 | 259 | |
| 258 | 260 | fn hitCountLessThan(context: void, lhs: *const Contents, rhs: *const Contents) bool { |
| 261 | _ = context; | |
| 259 | 262 | return lhs.hit_count < rhs.hit_count; |
| 260 | 263 | } |
| 261 | 264 | }; |
tools/update_clang_options.zig+3| ... | ... | @@ -585,6 +585,8 @@ const Syntax = union(enum) { |
| 585 | 585 | options: std.fmt.FormatOptions, |
| 586 | 586 | out_stream: anytype, |
| 587 | 587 | ) !void { |
| 588 | _ = fmt; | |
| 589 | _ = options; | |
| 588 | 590 | switch (self) { |
| 589 | 591 | .multi_arg => |n| return out_stream.print(".{{.{s}={}}}", .{ @tagName(self), n }), |
| 590 | 592 | else => return out_stream.print(".{s}", .{@tagName(self)}), |
| ... | ... | @@ -663,6 +665,7 @@ fn syntaxMatchesWithEql(syntax: Syntax) bool { |
| 663 | 665 | } |
| 664 | 666 | |
| 665 | 667 | fn objectLessThan(context: void, a: *json.ObjectMap, b: *json.ObjectMap) bool { |
| 668 | _ = context; | |
| 666 | 669 | // Priority is determined by exact matches first, followed by prefix matches in descending |
| 667 | 670 | // length, with key as a final tiebreaker. |
| 668 | 671 | const a_syntax = objSyntax(a); |
tools/update_cpu_features.zig+3| ... | ... | @@ -1227,14 +1227,17 @@ fn usageAndExit(file: fs.File, arg0: []const u8, code: u8) noreturn { |
| 1227 | 1227 | } |
| 1228 | 1228 | |
| 1229 | 1229 | fn featureLessThan(context: void, a: Feature, b: Feature) bool { |
| 1230 | _ = context; | |
| 1230 | 1231 | return std.ascii.lessThanIgnoreCase(a.zig_name, b.zig_name); |
| 1231 | 1232 | } |
| 1232 | 1233 | |
| 1233 | 1234 | fn cpuLessThan(context: void, a: Cpu, b: Cpu) bool { |
| 1235 | _ = context; | |
| 1234 | 1236 | return std.ascii.lessThanIgnoreCase(a.zig_name, b.zig_name); |
| 1235 | 1237 | } |
| 1236 | 1238 | |
| 1237 | 1239 | fn asciiLessThan(context: void, a: []const u8, b: []const u8) bool { |
| 1240 | _ = context; | |
| 1238 | 1241 | return std.ascii.lessThanIgnoreCase(a, b); |
| 1239 | 1242 | } |
| 1240 | 1243 |
tools/update_glibc.zig+5-3| ... | ... | @@ -155,7 +155,7 @@ pub fn main() !void { |
| 155 | 155 | } |
| 156 | 156 | const fn_set = &target_funcs_gop.value_ptr.list; |
| 157 | 157 | |
| 158 | for (lib_names) |lib_name, lib_name_index| { | |
| 158 | for (lib_names) |lib_name| { | |
| 159 | 159 | const lib_prefix = if (std.mem.eql(u8, lib_name, "ld")) "" else "lib"; |
| 160 | 160 | const basename = try fmt.allocPrint(allocator, "{s}{s}.abilist", .{ lib_prefix, lib_name }); |
| 161 | 161 | const abi_list_filename = blk: { |
| ... | ... | @@ -263,7 +263,7 @@ pub fn main() !void { |
| 263 | 263 | |
| 264 | 264 | // Now the mapping of version and function to integer index is complete. |
| 265 | 265 | // Here we create a mapping of function name to list of versions. |
| 266 | for (abi_lists) |*abi_list, abi_index| { | |
| 266 | for (abi_lists) |*abi_list| { | |
| 267 | 267 | const value = target_functions.getPtr(@ptrToInt(abi_list)).?; |
| 268 | 268 | const fn_vers_list = &value.fn_vers_list; |
| 269 | 269 | for (value.list.items) |*ver_fn| { |
| ... | ... | @@ -286,7 +286,7 @@ pub fn main() !void { |
| 286 | 286 | const abilist_txt = buffered.writer(); |
| 287 | 287 | |
| 288 | 288 | // first iterate over the abi lists |
| 289 | for (abi_lists) |*abi_list, abi_index| { | |
| 289 | for (abi_lists) |*abi_list| { | |
| 290 | 290 | const fn_vers_list = &target_functions.getPtr(@ptrToInt(abi_list)).?.fn_vers_list; |
| 291 | 291 | for (abi_list.targets) |target, it_i| { |
| 292 | 292 | if (it_i != 0) try abilist_txt.writeByte(' '); |
| ... | ... | @@ -312,10 +312,12 @@ pub fn main() !void { |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | pub fn strCmpLessThan(context: void, a: []const u8, b: []const u8) bool { |
| 315 | _ = context; | |
| 315 | 316 | return std.mem.order(u8, a, b) == .lt; |
| 316 | 317 | } |
| 317 | 318 | |
| 318 | 319 | pub fn versionLessThan(context: void, a: []const u8, b: []const u8) bool { |
| 320 | _ = context; | |
| 319 | 321 | const sep_chars = "GLIBC_."; |
| 320 | 322 | var a_tokens = std.mem.tokenize(a, sep_chars); |
| 321 | 323 | var b_tokens = std.mem.tokenize(b, sep_chars); |
tools/update_spirv_features.zig+1| ... | ... | @@ -37,6 +37,7 @@ const Version = struct { |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | fn lessThan(ctx: void, a: Version, b: Version) bool { |
| 40 | _ = ctx; | |
| 40 | 41 | return if (a.major == b.major) |
| 41 | 42 | a.minor < b.minor |
| 42 | 43 | else |