authorgravatar for jacoblevgw@gmail.comJacob G-W <jacoblevgw@gmail.com> 2021-06-19 21:10:22-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-06-21 17:03:03-07:00
log9fffffb07b081858db0c2102a0680aa166b48263
tree36caed31c5b2aaa8e08bb8e6e90e9b2c30910ff3
parentb83b3883ba0b5e965f8f7f1298c77c6d766741af

fix code broken from previous commit


162 files changed, 720 insertions(+), 148 deletions(-)

lib/std/Progress.zig+1-1
...@@ -295,7 +295,7 @@ fn refreshWithHeldLock(self: *Progress) void {...@@ -295,7 +295,7 @@ fn refreshWithHeldLock(self: *Progress) void {
295 end += 1;295 end += 1;
296 }296 }
297297
298 _ = file.write(self.output_buffer[0..end]) catch |e| {298 _ = file.write(self.output_buffer[0..end]) catch {
299 // Stop trying to write to this file once it errors.299 // Stop trying to write to this file once it errors.
300 self.terminal = null;300 self.terminal = null;
301 };301 };
lib/std/SemanticVersion.zig+2-1
...@@ -162,6 +162,7 @@ pub fn format(...@@ -162,6 +162,7 @@ pub fn format(
162 options: std.fmt.FormatOptions,162 options: std.fmt.FormatOptions,
163 out_stream: anytype,163 out_stream: anytype,
164) !void {164) !void {
165 _ = options;
165 if (fmt.len != 0) @compileError("Unknown format string: '" ++ fmt ++ "'");166 if (fmt.len != 0) @compileError("Unknown format string: '" ++ fmt ++ "'");
166 try std.fmt.format(out_stream, "{d}.{d}.{d}", .{ self.major, self.minor, self.patch });167 try std.fmt.format(out_stream, "{d}.{d}.{d}", .{ self.major, self.minor, self.patch });
167 if (self.pre) |pre| try std.fmt.format(out_stream, "-{s}", .{pre});168 if (self.pre) |pre| try std.fmt.format(out_stream, "-{s}", .{pre});
...@@ -259,7 +260,7 @@ test "SemanticVersion format" {...@@ -259,7 +260,7 @@ test "SemanticVersion format" {
259260
260 // Invalid version string that may overflow.261 // Invalid version string that may overflow.
261 const big_invalid = "99999999999999999999999.999999999999999999.99999999999999999----RC-SNAPSHOT.12.09.1--------------------------------..12";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}
264265
265test "SemanticVersion precedence" {266test "SemanticVersion precedence" {
lib/std/Thread/Condition.zig+8-2
...@@ -40,12 +40,18 @@ else...@@ -40,12 +40,18 @@ else
4040
41pub const SingleThreadedCondition = struct {41pub const SingleThreadedCondition = struct {
42 pub fn wait(cond: *SingleThreadedCondition, mutex: *Mutex) void {42 pub fn wait(cond: *SingleThreadedCondition, mutex: *Mutex) void {
43 _ = cond;
44 _ = mutex;
43 unreachable; // deadlock detected45 unreachable; // deadlock detected
44 }46 }
4547
46 pub fn signal(cond: *SingleThreadedCondition) void {}48 pub fn signal(cond: *SingleThreadedCondition) void {
49 _ = cond;
50 }
4751
48 pub fn broadcast(cond: *SingleThreadedCondition) void {}52 pub fn broadcast(cond: *SingleThreadedCondition) void {
53 _ = cond;
54 }
49};55};
5056
51pub const WindowsCondition = struct {57pub const WindowsCondition = struct {
lib/std/Thread/StaticResetEvent.zig+6-1
...@@ -105,6 +105,7 @@ pub const DebugEvent = struct {...@@ -105,6 +105,7 @@ pub const DebugEvent = struct {
105 }105 }
106106
107 pub fn timedWait(ev: *DebugEvent, timeout: u64) TimedWaitResult {107 pub fn timedWait(ev: *DebugEvent, timeout: u64) TimedWaitResult {
108 _ = timeout;
108 switch (ev.state) {109 switch (ev.state) {
109 .unset => return .timed_out,110 .unset => return .timed_out,
110 .set => return .event_set,111 .set => return .event_set,
...@@ -174,7 +175,10 @@ pub const AtomicEvent = struct {...@@ -174,7 +175,10 @@ pub const AtomicEvent = struct {
174 };175 };
175176
176 pub const SpinFutex = struct {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 }
178182
179 fn wait(waiters: *u32, timeout: ?u64) !void {183 fn wait(waiters: *u32, timeout: ?u64) !void {
180 var timer: time.Timer = undefined;184 var timer: time.Timer = undefined;
...@@ -193,6 +197,7 @@ pub const AtomicEvent = struct {...@@ -193,6 +197,7 @@ pub const AtomicEvent = struct {
193197
194 pub const LinuxFutex = struct {198 pub const LinuxFutex = struct {
195 fn wake(waiters: *u32, wake_count: u32) void {199 fn wake(waiters: *u32, wake_count: u32) void {
200 _ = wake_count;
196 const waiting = std.math.maxInt(i32); // wake_count201 const waiting = std.math.maxInt(i32); // wake_count
197 const ptr = @ptrCast(*const i32, waiters);202 const ptr = @ptrCast(*const i32, waiters);
198 const rc = linux.futex_wake(ptr, linux.FUTEX_WAKE | linux.FUTEX_PRIVATE_FLAG, waiting);203 const rc = linux.futex_wake(ptr, linux.FUTEX_WAKE | linux.FUTEX_PRIVATE_FLAG, waiting);
lib/std/array_hash_map.zig+11-2
...@@ -40,9 +40,11 @@ pub fn StringArrayHashMapUnmanaged(comptime V: type) type {...@@ -40,9 +40,11 @@ pub fn StringArrayHashMapUnmanaged(comptime V: type) type {
4040
41pub const StringContext = struct {41pub const StringContext = struct {
42 pub fn hash(self: @This(), s: []const u8) u32 {42 pub fn hash(self: @This(), s: []const u8) u32 {
43 _ = self;
43 return hashString(s);44 return hashString(s);
44 }45 }
45 pub fn eql(self: @This(), a: []const u8, b: []const u8) bool {46 pub fn eql(self: @This(), a: []const u8, b: []const u8) bool {
47 _ = self;
46 return eqlString(a, b);48 return eqlString(a, b);
47 }49 }
48};50};
...@@ -1335,6 +1337,7 @@ pub fn ArrayHashMapUnmanaged(...@@ -1335,6 +1337,7 @@ pub fn ArrayHashMapUnmanaged(
1335 }1337 }
13361338
1337 fn removeSlot(self: *Self, removed_slot: usize, header: *IndexHeader, comptime I: type, indexes: []Index(I)) void {1339 fn removeSlot(self: *Self, removed_slot: usize, header: *IndexHeader, comptime I: type, indexes: []Index(I)) void {
1340 _ = self;
1338 const start_index = removed_slot +% 1;1341 const start_index = removed_slot +% 1;
1339 const end_index = start_index +% indexes.len;1342 const end_index = start_index +% indexes.len;
13401343
...@@ -1626,6 +1629,7 @@ pub fn ArrayHashMapUnmanaged(...@@ -1626,6 +1629,7 @@ pub fn ArrayHashMapUnmanaged(
1626 }1629 }
1627 }1630 }
1628 fn dumpIndex(self: Self, header: *IndexHeader, comptime I: type) void {1631 fn dumpIndex(self: Self, header: *IndexHeader, comptime I: type) void {
1632 _ = self;
1629 const p = std.debug.print;1633 const p = std.debug.print;
1630 p(" index len=0x{x} type={}\n", .{ header.length(), header.capacityIndexType() });1634 p(" index len=0x{x} type={}\n", .{ header.length(), header.capacityIndexType() });
1631 const indexes = header.indexes(I);1635 const indexes = header.indexes(I);
...@@ -1918,7 +1922,7 @@ test "iterator hash map" {...@@ -1918,7 +1922,7 @@ test "iterator hash map" {
1918 try testing.expect(count == 3);1922 try testing.expect(count == 3);
1919 try testing.expect(it.next() == null);1923 try testing.expect(it.next() == null);
19201924
1921 for (buffer) |v, i| {1925 for (buffer) |_, i| {
1922 try testing.expect(buffer[@intCast(usize, keys[i])] == values[i]);1926 try testing.expect(buffer[@intCast(usize, keys[i])] == values[i]);
1923 }1927 }
19241928
...@@ -1930,7 +1934,7 @@ test "iterator hash map" {...@@ -1930,7 +1934,7 @@ test "iterator hash map" {
1930 if (count >= 2) break;1934 if (count >= 2) break;
1931 }1935 }
19321936
1933 for (buffer[0..2]) |v, i| {1937 for (buffer[0..2]) |_, i| {
1934 try testing.expect(buffer[@intCast(usize, keys[i])] == values[i]);1938 try testing.expect(buffer[@intCast(usize, keys[i])] == values[i]);
1935 }1939 }
19361940
...@@ -2154,6 +2158,7 @@ test "compile everything" {...@@ -2154,6 +2158,7 @@ test "compile everything" {
2154pub fn getHashPtrAddrFn(comptime K: type, comptime Context: type) (fn (Context, K) u32) {2158pub fn getHashPtrAddrFn(comptime K: type, comptime Context: type) (fn (Context, K) u32) {
2155 return struct {2159 return struct {
2156 fn hash(ctx: Context, key: K) u32 {2160 fn hash(ctx: Context, key: K) u32 {
2161 _ = ctx;
2157 return getAutoHashFn(usize, void)({}, @ptrToInt(key));2162 return getAutoHashFn(usize, void)({}, @ptrToInt(key));
2158 }2163 }
2159 }.hash;2164 }.hash;
...@@ -2162,6 +2167,7 @@ pub fn getHashPtrAddrFn(comptime K: type, comptime Context: type) (fn (Context,...@@ -2162,6 +2167,7 @@ pub fn getHashPtrAddrFn(comptime K: type, comptime Context: type) (fn (Context,
2162pub fn getTrivialEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K) bool) {2167pub fn getTrivialEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K) bool) {
2163 return struct {2168 return struct {
2164 fn eql(ctx: Context, a: K, b: K) bool {2169 fn eql(ctx: Context, a: K, b: K) bool {
2170 _ = ctx;
2165 return a == b;2171 return a == b;
2166 }2172 }
2167 }.eql;2173 }.eql;
...@@ -2177,6 +2183,7 @@ pub fn AutoContext(comptime K: type) type {...@@ -2177,6 +2183,7 @@ pub fn AutoContext(comptime K: type) type {
2177pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K) u32) {2183pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K) u32) {
2178 return struct {2184 return struct {
2179 fn hash(ctx: Context, key: K) u32 {2185 fn hash(ctx: Context, key: K) u32 {
2186 _ = ctx;
2180 if (comptime trait.hasUniqueRepresentation(K)) {2187 if (comptime trait.hasUniqueRepresentation(K)) {
2181 return @truncate(u32, Wyhash.hash(0, std.mem.asBytes(&key)));2188 return @truncate(u32, Wyhash.hash(0, std.mem.asBytes(&key)));
2182 } else {2189 } else {
...@@ -2191,6 +2198,7 @@ pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K)...@@ -2191,6 +2198,7 @@ pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K)
2191pub fn getAutoEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K) bool) {2198pub fn getAutoEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K) bool) {
2192 return struct {2199 return struct {
2193 fn eql(ctx: Context, a: K, b: K) bool {2200 fn eql(ctx: Context, a: K, b: K) bool {
2201 _ = ctx;
2194 return meta.eql(a, b);2202 return meta.eql(a, b);
2195 }2203 }
2196 }.eql;2204 }.eql;
...@@ -2217,6 +2225,7 @@ pub fn autoEqlIsCheap(comptime K: type) bool {...@@ -2217,6 +2225,7 @@ pub fn autoEqlIsCheap(comptime K: type) bool {
2217pub fn getAutoHashStratFn(comptime K: type, comptime Context: type, comptime strategy: std.hash.Strategy) (fn (Context, K) u32) {2225pub fn getAutoHashStratFn(comptime K: type, comptime Context: type, comptime strategy: std.hash.Strategy) (fn (Context, K) u32) {
2218 return struct {2226 return struct {
2219 fn hash(ctx: Context, key: K) u32 {2227 fn hash(ctx: Context, key: K) u32 {
2228 _ = ctx;
2220 var hasher = Wyhash.init(0);2229 var hasher = Wyhash.init(0);
2221 std.hash.autoHashStrat(&hasher, key, strategy);2230 std.hash.autoHashStrat(&hasher, key, strategy);
2222 return @truncate(u32, hasher.final());2231 return @truncate(u32, hasher.final());
lib/std/atomic/Atomic.zig+2
...@@ -232,6 +232,7 @@ test "Atomic.loadUnchecked" {...@@ -232,6 +232,7 @@ test "Atomic.loadUnchecked" {
232232
233test "Atomic.storeUnchecked" {233test "Atomic.storeUnchecked" {
234 inline for (atomicIntTypes()) |Int| {234 inline for (atomicIntTypes()) |Int| {
235 _ = Int;
235 var x = Atomic(usize).init(5);236 var x = Atomic(usize).init(5);
236 x.storeUnchecked(10);237 x.storeUnchecked(10);
237 try testing.expectEqual(x.loadUnchecked(), 10);238 try testing.expectEqual(x.loadUnchecked(), 10);
...@@ -250,6 +251,7 @@ test "Atomic.load" {...@@ -250,6 +251,7 @@ test "Atomic.load" {
250test "Atomic.store" {251test "Atomic.store" {
251 inline for (atomicIntTypes()) |Int| {252 inline for (atomicIntTypes()) |Int| {
252 inline for (.{ .Unordered, .Monotonic, .Release, .SeqCst }) |ordering| {253 inline for (.{ .Unordered, .Monotonic, .Release, .SeqCst }) |ordering| {
254 _ = Int;
253 var x = Atomic(usize).init(5);255 var x = Atomic(usize).init(5);
254 x.store(10, ordering);256 x.store(10, ordering);
255 try testing.expectEqual(x.load(.SeqCst), 10);257 try testing.expectEqual(x.load(.SeqCst), 10);
lib/std/bit_set.zig+4-2
...@@ -84,6 +84,7 @@ pub fn IntegerBitSet(comptime size: u16) type {...@@ -84,6 +84,7 @@ pub fn IntegerBitSet(comptime size: u16) type {
8484
85 /// Returns the number of bits in this bit set85 /// Returns the number of bits in this bit set
86 pub inline fn capacity(self: Self) usize {86 pub inline fn capacity(self: Self) usize {
87 _ = self;
87 return bit_length;88 return bit_length;
88 }89 }
8990
...@@ -311,6 +312,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {...@@ -311,6 +312,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
311312
312 /// Returns the number of bits in this bit set313 /// Returns the number of bits in this bit set
313 pub inline fn capacity(self: Self) usize {314 pub inline fn capacity(self: Self) usize {
315 _ = self;
314 return bit_length;316 return bit_length;
315 }317 }
316318
...@@ -373,7 +375,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {...@@ -373,7 +375,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
373375
374 /// Flips every bit in the bit set.376 /// Flips every bit in the bit set.
375 pub fn toggleAll(self: *Self) void {377 pub fn toggleAll(self: *Self) void {
376 for (self.masks) |*mask, i| {378 for (self.masks) |*mask| {
377 mask.* = ~mask.*;379 mask.* = ~mask.*;
378 }380 }
379381
...@@ -642,7 +644,7 @@ pub const DynamicBitSetUnmanaged = struct {...@@ -642,7 +644,7 @@ pub const DynamicBitSetUnmanaged = struct {
642 if (bit_length == 0) return;644 if (bit_length == 0) return;
643645
644 const num_masks = numMasks(self.bit_length);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 mask.* = ~mask.*;648 mask.* = ~mask.*;
647 }649 }
648650
lib/std/build.zig+5-2
...@@ -390,6 +390,7 @@ pub const Builder = struct {...@@ -390,6 +390,7 @@ pub const Builder = struct {
390 }390 }
391391
392 pub fn version(self: *const Builder, major: u32, minor: u32, patch: u32) LibExeObjStep.SharedLibKind {392 pub fn version(self: *const Builder, major: u32, minor: u32, patch: u32) LibExeObjStep.SharedLibKind {
393 _ = self;
393 return .{394 return .{
394 .versioned = .{395 .versioned = .{
395 .major = major,396 .major = major,
...@@ -543,7 +544,7 @@ pub const Builder = struct {...@@ -543,7 +544,7 @@ pub const Builder = struct {
543 return null;544 return null;
544 },545 },
545 .scalar => |s| {546 .scalar => |s| {
546 const n = std.fmt.parseFloat(T, s) catch |err| {547 const n = std.fmt.parseFloat(T, s) catch {
547 warn("Expected -D{s} to be a float of type {s}.\n\n", .{ name, @typeName(T) });548 warn("Expected -D{s} to be a float of type {s}.\n\n", .{ name, @typeName(T) });
548 self.markInvalidUserInput();549 self.markInvalidUserInput();
549 return null;550 return null;
...@@ -3129,7 +3130,9 @@ pub const Step = struct {...@@ -3129,7 +3130,9 @@ pub const Step = struct {
3129 self.dependencies.append(other) catch unreachable;3130 self.dependencies.append(other) catch unreachable;
3130 }3131 }
31313132
3132 fn makeNoOp(self: *Step) anyerror!void {}3133 fn makeNoOp(self: *Step) anyerror!void {
3134 _ = self;
3135 }
31333136
3134 pub fn cast(step: *Step, comptime T: type) ?*T {3137 pub fn cast(step: *Step, comptime T: type) ?*T {
3135 if (step.id == T.base_id) {3138 if (step.id == T.base_id) {
lib/std/build/InstallRawStep.zig+2
...@@ -139,6 +139,7 @@ const BinaryElfOutput = struct {...@@ -139,6 +139,7 @@ const BinaryElfOutput = struct {
139 }139 }
140140
141 fn segmentSortCompare(context: void, left: *BinaryElfSegment, right: *BinaryElfSegment) bool {141 fn segmentSortCompare(context: void, left: *BinaryElfSegment, right: *BinaryElfSegment) bool {
142 _ = context;
142 if (left.physicalAddress < right.physicalAddress) {143 if (left.physicalAddress < right.physicalAddress) {
143 return true;144 return true;
144 }145 }
...@@ -149,6 +150,7 @@ const BinaryElfOutput = struct {...@@ -149,6 +150,7 @@ const BinaryElfOutput = struct {
149 }150 }
150151
151 fn sectionSortCompare(context: void, left: *BinaryElfSection, right: *BinaryElfSection) bool {152 fn sectionSortCompare(context: void, left: *BinaryElfSection, right: *BinaryElfSection) bool {
153 _ = context;
152 return left.binaryOffset < right.binaryOffset;154 return left.binaryOffset < right.binaryOffset;
153 }155 }
154};156};
lib/std/builtin.zig+3
...@@ -65,6 +65,8 @@ pub const StackTrace = struct {...@@ -65,6 +65,8 @@ pub const StackTrace = struct {
65 options: std.fmt.FormatOptions,65 options: std.fmt.FormatOptions,
66 writer: anytype,66 writer: anytype,
67 ) !void {67 ) !void {
68 _ = fmt;
69 _ = options;
68 var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);70 var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
69 defer arena.deinit();71 defer arena.deinit();
70 const debug_info = std.debug.getSelfDebugInfo() catch |err| {72 const debug_info = std.debug.getSelfDebugInfo() catch |err| {
...@@ -521,6 +523,7 @@ pub const Version = struct {...@@ -521,6 +523,7 @@ pub const Version = struct {
521 options: std.fmt.FormatOptions,523 options: std.fmt.FormatOptions,
522 out_stream: anytype,524 out_stream: anytype,
523 ) !void {525 ) !void {
526 _ = options;
524 if (fmt.len == 0) {527 if (fmt.len == 0) {
525 if (self.patch == 0) {528 if (self.patch == 0) {
526 if (self.minor == 0) {529 if (self.minor == 0) {
lib/std/comptime_string_map.zig+1
...@@ -23,6 +23,7 @@ pub fn ComptimeStringMap(comptime V: type, comptime kvs: anytype) type {...@@ -23,6 +23,7 @@ pub fn ComptimeStringMap(comptime V: type, comptime kvs: anytype) type {
23 var sorted_kvs: [kvs.len]KV = undefined;23 var sorted_kvs: [kvs.len]KV = undefined;
24 const lenAsc = (struct {24 const lenAsc = (struct {
25 fn lenAsc(context: void, a: KV, b: KV) bool {25 fn lenAsc(context: void, a: KV, b: KV) bool {
26 _ = context;
26 return a.key.len < b.key.len;27 return a.key.len < b.key.len;
27 }28 }
28 }).lenAsc;29 }).lenAsc;
lib/std/crypto/25519/ed25519.zig+1-1
...@@ -346,7 +346,7 @@ test "ed25519 test vectors" {...@@ -346,7 +346,7 @@ test "ed25519 test vectors" {
346 .expected = error.IdentityElement, // 11 - small-order A346 .expected = error.IdentityElement, // 11 - small-order A
347 },347 },
348 };348 };
349 for (entries) |entry, i| {349 for (entries) |entry| {
350 var msg: [entry.msg_hex.len / 2]u8 = undefined;350 var msg: [entry.msg_hex.len / 2]u8 = undefined;
351 _ = try fmt.hexToBytes(&msg, entry.msg_hex);351 _ = try fmt.hexToBytes(&msg, entry.msg_hex);
352 var public_key: [32]u8 = undefined;352 var public_key: [32]u8 = undefined;
lib/std/crypto/blake3.zig+1
...@@ -394,6 +394,7 @@ pub const Blake3 = struct {...@@ -394,6 +394,7 @@ pub const Blake3 = struct {
394 /// Construct a new `Blake3` for the key derivation function. The context394 /// Construct a new `Blake3` for the key derivation function. The context
395 /// string should be hardcoded, globally unique, and application-specific.395 /// string should be hardcoded, globally unique, and application-specific.
396 pub fn initKdf(context: []const u8, options: KdfOptions) Blake3 {396 pub fn initKdf(context: []const u8, options: KdfOptions) Blake3 {
397 _ = options;
397 var context_hasher = Blake3.init_internal(IV, DERIVE_KEY_CONTEXT);398 var context_hasher = Blake3.init_internal(IV, DERIVE_KEY_CONTEXT);
398 context_hasher.update(context);399 context_hasher.update(context);
399 var context_key: [KEY_LEN]u8 = undefined;400 var context_key: [KEY_LEN]u8 = undefined;
lib/std/crypto/gimli.zig+1
...@@ -219,6 +219,7 @@ pub const Hash = struct {...@@ -219,6 +219,7 @@ pub const Hash = struct {
219 const Self = @This();219 const Self = @This();
220220
221 pub fn init(options: Options) Self {221 pub fn init(options: Options) Self {
222 _ = options;
222 return Self{223 return Self{
223 .state = State{ .data = [_]u32{0} ** (State.BLOCKBYTES / 4) },224 .state = State{ .data = [_]u32{0} ** (State.BLOCKBYTES / 4) },
224 .buf_off = 0,225 .buf_off = 0,
lib/std/crypto/md5.zig+1
...@@ -45,6 +45,7 @@ pub const Md5 = struct {...@@ -45,6 +45,7 @@ pub const Md5 = struct {
45 total_len: u64,45 total_len: u64,
4646
47 pub fn init(options: Options) Self {47 pub fn init(options: Options) Self {
48 _ = options;
48 return Self{49 return Self{
49 .s = [_]u32{50 .s = [_]u32{
50 0x67452301,51 0x67452301,
lib/std/crypto/pcurves/p256/scalar.zig+1
...@@ -63,6 +63,7 @@ pub fn add(a: CompressedScalar, b: CompressedScalar, endian: builtin.Endian) Non...@@ -63,6 +63,7 @@ pub fn add(a: CompressedScalar, b: CompressedScalar, endian: builtin.Endian) Non
6363
64/// Return -s (mod L)64/// Return -s (mod L)
65pub fn neg(s: CompressedScalar, endian: builtin.Endian) NonCanonicalError!CompressedScalar {65pub fn neg(s: CompressedScalar, endian: builtin.Endian) NonCanonicalError!CompressedScalar {
66 _ = s;
66 return (try Scalar.fromBytes(a, endian)).neg().toBytes(endian);67 return (try Scalar.fromBytes(a, endian)).neg().toBytes(endian);
67}68}
6869
lib/std/crypto/sha1.zig+1
...@@ -43,6 +43,7 @@ pub const Sha1 = struct {...@@ -43,6 +43,7 @@ pub const Sha1 = struct {
43 total_len: u64 = 0,43 total_len: u64 = 0,
4444
45 pub fn init(options: Options) Self {45 pub fn init(options: Options) Self {
46 _ = options;
46 return Self{47 return Self{
47 .s = [_]u32{48 .s = [_]u32{
48 0x67452301,49 0x67452301,
lib/std/crypto/sha2.zig+2
...@@ -95,6 +95,7 @@ fn Sha2x32(comptime params: Sha2Params32) type {...@@ -95,6 +95,7 @@ fn Sha2x32(comptime params: Sha2Params32) type {
95 total_len: u64 = 0,95 total_len: u64 = 0,
9696
97 pub fn init(options: Options) Self {97 pub fn init(options: Options) Self {
98 _ = options;
98 return Self{99 return Self{
99 .s = [_]u32{100 .s = [_]u32{
100 params.iv0,101 params.iv0,
...@@ -462,6 +463,7 @@ fn Sha2x64(comptime params: Sha2Params64) type {...@@ -462,6 +463,7 @@ fn Sha2x64(comptime params: Sha2Params64) type {
462 total_len: u128 = 0,463 total_len: u128 = 0,
463464
464 pub fn init(options: Options) Self {465 pub fn init(options: Options) Self {
466 _ = options;
465 return Self{467 return Self{
466 .s = [_]u64{468 .s = [_]u64{
467 params.iv0,469 params.iv0,
lib/std/crypto/sha3.zig+1
...@@ -28,6 +28,7 @@ fn Keccak(comptime bits: usize, comptime delim: u8) type {...@@ -28,6 +28,7 @@ fn Keccak(comptime bits: usize, comptime delim: u8) type {
28 rate: usize,28 rate: usize,
2929
30 pub fn init(options: Options) Self {30 pub fn init(options: Options) Self {
31 _ = options;
31 return Self{ .s = [_]u8{0} ** 200, .offset = 0, .rate = 200 - (bits / 4) };32 return Self{ .s = [_]u8{0} ** 200, .offset = 0, .rate = 200 - (bits / 4) };
32 }33 }
3334
lib/std/crypto/tlcsprng.zig+1-1
...@@ -84,7 +84,7 @@ fn tlsCsprngFill(_: *const std.rand.Random, buffer: []u8) void {...@@ -84,7 +84,7 @@ fn tlsCsprngFill(_: *const std.rand.Random, buffer: []u8) void {
84 os.MAP_PRIVATE | os.MAP_ANONYMOUS,84 os.MAP_PRIVATE | os.MAP_ANONYMOUS,
85 -1,85 -1,
86 0,86 0,
87 ) catch |err| {87 ) catch {
88 // Could not allocate memory for the local state, fall back to88 // Could not allocate memory for the local state, fall back to
89 // the OS syscall.89 // the OS syscall.
90 return fillWithOsEntropy(buffer);90 return fillWithOsEntropy(buffer);
lib/std/debug.zig+5
...@@ -325,6 +325,7 @@ pub fn writeStackTrace(...@@ -325,6 +325,7 @@ pub fn writeStackTrace(
325 debug_info: *DebugInfo,325 debug_info: *DebugInfo,
326 tty_config: TTY.Config,326 tty_config: TTY.Config,
327) !void {327) !void {
328 _ = allocator;
328 if (builtin.strip_debug_info) return error.MissingDebugInfo;329 if (builtin.strip_debug_info) return error.MissingDebugInfo;
329 var frame_index: usize = 0;330 var frame_index: usize = 0;
330 var frames_left: usize = std.math.min(stack_trace.index, stack_trace.instruction_addresses.len);331 var frames_left: usize = std.math.min(stack_trace.index, stack_trace.instruction_addresses.len);
...@@ -930,6 +931,7 @@ const MachoSymbol = struct {...@@ -930,6 +931,7 @@ const MachoSymbol = struct {
930 }931 }
931932
932 fn addressLessThan(context: void, lhs: MachoSymbol, rhs: MachoSymbol) bool {933 fn addressLessThan(context: void, lhs: MachoSymbol, rhs: MachoSymbol) bool {
934 _ = context;
933 return lhs.address() < rhs.address();935 return lhs.address() < rhs.address();
934 }936 }
935};937};
...@@ -1134,6 +1136,7 @@ pub const DebugInfo = struct {...@@ -1134,6 +1136,7 @@ pub const DebugInfo = struct {
11341136
1135 if (os.dl_iterate_phdr(&ctx, anyerror, struct {1137 if (os.dl_iterate_phdr(&ctx, anyerror, struct {
1136 fn callback(info: *os.dl_phdr_info, size: usize, context: *CtxTy) !void {1138 fn callback(info: *os.dl_phdr_info, size: usize, context: *CtxTy) !void {
1139 _ = size;
1137 // The base address is too high1140 // The base address is too high
1138 if (context.address < info.dlpi_addr)1141 if (context.address < info.dlpi_addr)
1139 return;1142 return;
...@@ -1189,6 +1192,8 @@ pub const DebugInfo = struct {...@@ -1189,6 +1192,8 @@ pub const DebugInfo = struct {
1189 }1192 }
11901193
1191 fn lookupModuleHaiku(self: *DebugInfo, address: usize) !*ModuleDebugInfo {1194 fn lookupModuleHaiku(self: *DebugInfo, address: usize) !*ModuleDebugInfo {
1195 _ = self;
1196 _ = address;
1192 @panic("TODO implement lookup module for Haiku");1197 @panic("TODO implement lookup module for Haiku");
1193 }1198 }
1194};1199};
lib/std/dwarf.zig+4-2
...@@ -283,6 +283,7 @@ fn parseFormValueBlock(allocator: *mem.Allocator, in_stream: anytype, endian: bu...@@ -283,6 +283,7 @@ fn parseFormValueBlock(allocator: *mem.Allocator, in_stream: anytype, endian: bu
283}283}
284284
285fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: anytype, signed: bool, endian: builtin.Endian, comptime size: i32) !FormValue {285fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: anytype, signed: bool, endian: builtin.Endian, comptime size: i32) !FormValue {
286 _ = allocator;
286 // TODO: Please forgive me, I've worked around zig not properly spilling some intermediate values here.287 // TODO: Please forgive me, I've worked around zig not properly spilling some intermediate values here.
287 // `nosuspend` should be removed from all the function calls once it is fixed.288 // `nosuspend` should be removed from all the function calls once it is fixed.
288 return FormValue{289 return FormValue{
...@@ -310,6 +311,7 @@ fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: anytype, signed:...@@ -310,6 +311,7 @@ fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: anytype, signed:
310311
311// TODO the nosuspends here are workarounds312// TODO the nosuspends here are workarounds
312fn parseFormValueRef(allocator: *mem.Allocator, in_stream: anytype, endian: builtin.Endian, size: i32) !FormValue {313fn parseFormValueRef(allocator: *mem.Allocator, in_stream: anytype, endian: builtin.Endian, size: i32) !FormValue {
314 _ = allocator;
313 return FormValue{315 return FormValue{
314 .Ref = switch (size) {316 .Ref = switch (size) {
315 1 => try nosuspend in_stream.readInt(u8, endian),317 1 => try nosuspend in_stream.readInt(u8, endian),
...@@ -453,13 +455,13 @@ pub const DwarfInfo = struct {...@@ -453,13 +455,13 @@ pub const DwarfInfo = struct {
453 if (this_die_obj.getAttr(AT_name)) |_| {455 if (this_die_obj.getAttr(AT_name)) |_| {
454 const name = try this_die_obj.getAttrString(di, AT_name);456 const name = try this_die_obj.getAttrString(di, AT_name);
455 break :x name;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 // Follow the DIE it points to and repeat459 // Follow the DIE it points to and repeat
458 const ref_offset = try this_die_obj.getAttrRef(AT_abstract_origin);460 const ref_offset = try this_die_obj.getAttrRef(AT_abstract_origin);
459 if (ref_offset > next_offset) return error.InvalidDebugInfo;461 if (ref_offset > next_offset) return error.InvalidDebugInfo;
460 try seekable.seekTo(this_unit_offset + ref_offset);462 try seekable.seekTo(this_unit_offset + ref_offset);
461 this_die_obj = (try di.parseDie(in, abbrev_table, is_64)) orelse return error.InvalidDebugInfo;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 // Follow the DIE it points to and repeat465 // Follow the DIE it points to and repeat
464 const ref_offset = try this_die_obj.getAttrRef(AT_specification);466 const ref_offset = try this_die_obj.getAttrRef(AT_specification);
465 if (ref_offset > next_offset) return error.InvalidDebugInfo;467 if (ref_offset > next_offset) return error.InvalidDebugInfo;
lib/std/dynamic_library.zig+1
...@@ -66,6 +66,7 @@ pub fn get_DYNAMIC() ?[*]elf.Dyn {...@@ -66,6 +66,7 @@ pub fn get_DYNAMIC() ?[*]elf.Dyn {
66}66}
6767
68pub fn linkmap_iterator(phdrs: []elf.Phdr) !LinkMap.Iterator {68pub fn linkmap_iterator(phdrs: []elf.Phdr) !LinkMap.Iterator {
69 _ = phdrs;
69 const _DYNAMIC = get_DYNAMIC() orelse {70 const _DYNAMIC = get_DYNAMIC() orelse {
70 // No PT_DYNAMIC means this is either a statically-linked program or a71 // No PT_DYNAMIC means this is either a statically-linked program or a
71 // badly corrupted dynamically-linked one.72 // badly corrupted dynamically-linked one.
lib/std/enums.zig+6-2
...@@ -18,7 +18,7 @@ const EnumField = std.builtin.TypeInfo.EnumField;...@@ -18,7 +18,7 @@ const EnumField = std.builtin.TypeInfo.EnumField;
18pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_default: ?Data) type {18pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_default: ?Data) type {
19 const StructField = std.builtin.TypeInfo.StructField;19 const StructField = std.builtin.TypeInfo.StructField;
20 var fields: []const StructField = &[_]StructField{};20 var fields: []const StructField = &[_]StructField{};
21 for (std.meta.fields(E)) |field, i| {21 for (std.meta.fields(E)) |field| {
22 fields = fields ++ &[_]StructField{.{22 fields = fields ++ &[_]StructField{.{
23 .name = field.name,23 .name = field.name,
24 .field_type = Data,24 .field_type = Data,
...@@ -144,7 +144,7 @@ pub fn directEnumArrayDefault(...@@ -144,7 +144,7 @@ pub fn directEnumArrayDefault(
144) [directEnumArrayLen(E, max_unused_slots)]Data {144) [directEnumArrayLen(E, max_unused_slots)]Data {
145 const len = comptime directEnumArrayLen(E, max_unused_slots);145 const len = comptime directEnumArrayLen(E, max_unused_slots);
146 var result: [len]Data = if (default) |d| [_]Data{d} ** len else undefined;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 const enum_value = @field(E, f.name);148 const enum_value = @field(E, f.name);
149 const index = @intCast(usize, @enumToInt(enum_value));149 const index = @intCast(usize, @enumToInt(enum_value));
150 result[index] = @field(init_values, f.name);150 result[index] = @field(init_values, f.name);
...@@ -334,6 +334,7 @@ pub fn EnumArray(comptime E: type, comptime V: type) type {...@@ -334,6 +334,7 @@ pub fn EnumArray(comptime E: type, comptime V: type) type {
334/// TODO: Once #8169 is fixed, consider switching this param334/// TODO: Once #8169 is fixed, consider switching this param
335/// back to an optional.335/// back to an optional.
336pub fn NoExtension(comptime Self: type) type {336pub fn NoExtension(comptime Self: type) type {
337 _ = Self;
337 return NoExt;338 return NoExt;
338}339}
339const NoExt = struct {};340const NoExt = struct {};
...@@ -729,6 +730,7 @@ test "std.enums.ensureIndexer" {...@@ -729,6 +730,7 @@ test "std.enums.ensureIndexer" {
729}730}
730731
731fn ascByValue(ctx: void, comptime a: EnumField, comptime b: EnumField) bool {732fn ascByValue(ctx: void, comptime a: EnumField, comptime b: EnumField) bool {
733 _ = ctx;
732 return a.value < b.value;734 return a.value < b.value;
733}735}
734pub fn EnumIndexer(comptime E: type) type {736pub fn EnumIndexer(comptime E: type) type {
...@@ -743,9 +745,11 @@ pub fn EnumIndexer(comptime E: type) type {...@@ -743,9 +745,11 @@ pub fn EnumIndexer(comptime E: type) type {
743 pub const Key = E;745 pub const Key = E;
744 pub const count: usize = 0;746 pub const count: usize = 0;
745 pub fn indexOf(e: E) usize {747 pub fn indexOf(e: E) usize {
748 _ = e;
746 unreachable;749 unreachable;
747 }750 }
748 pub fn keyForIndex(i: usize) E {751 pub fn keyForIndex(i: usize) E {
752 _ = i;
749 unreachable;753 unreachable;
750 }754 }
751 };755 };
lib/std/event/loop.zig+1-1
...@@ -345,7 +345,7 @@ pub const Loop = struct {...@@ -345,7 +345,7 @@ pub const Loop = struct {
345 );345 );
346 errdefer windows.CloseHandle(self.os_data.io_port);346 errdefer windows.CloseHandle(self.os_data.io_port);
347347
348 for (self.eventfd_resume_nodes) |*eventfd_node, i| {348 for (self.eventfd_resume_nodes) |*eventfd_node| {
349 eventfd_node.* = std.atomic.Stack(ResumeNode.EventFd).Node{349 eventfd_node.* = std.atomic.Stack(ResumeNode.EventFd).Node{
350 .data = ResumeNode.EventFd{350 .data = ResumeNode.EventFd{
351 .base = ResumeNode{351 .base = ResumeNode{
lib/std/fmt.zig+12-1
...@@ -369,6 +369,7 @@ pub fn format(...@@ -369,6 +369,7 @@ pub fn format(
369}369}
370370
371pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @TypeOf(writer).Error!void {371pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @TypeOf(writer).Error!void {
372 _ = options;
372 const T = @TypeOf(value);373 const T = @TypeOf(value);
373374
374 switch (@typeInfo(T)) {375 switch (@typeInfo(T)) {
...@@ -553,7 +554,7 @@ pub fn formatType(...@@ -553,7 +554,7 @@ pub fn formatType(
553 .Many, .C => {554 .Many, .C => {
554 if (actual_fmt.len == 0)555 if (actual_fmt.len == 0)
555 @compileError("cannot format pointer without a specifier (i.e. {s} or {*})");556 @compileError("cannot format pointer without a specifier (i.e. {s} or {*})");
556 if (ptr_info.sentinel) |sentinel| {557 if (ptr_info.sentinel) |_| {
557 return formatType(mem.span(value), actual_fmt, options, writer, max_depth);558 return formatType(mem.span(value), actual_fmt, options, writer, max_depth);
558 }559 }
559 if (ptr_info.child == u8) {560 if (ptr_info.child == u8) {
...@@ -741,6 +742,8 @@ fn formatSliceHexImpl(comptime case: Case) type {...@@ -741,6 +742,8 @@ fn formatSliceHexImpl(comptime case: Case) type {
741 options: std.fmt.FormatOptions,742 options: std.fmt.FormatOptions,
742 writer: anytype,743 writer: anytype,
743 ) !void {744 ) !void {
745 _ = fmt;
746 _ = options;
744 var buf: [2]u8 = undefined;747 var buf: [2]u8 = undefined;
745748
746 for (bytes) |c| {749 for (bytes) |c| {
...@@ -777,6 +780,8 @@ fn formatSliceEscapeImpl(comptime case: Case) type {...@@ -777,6 +780,8 @@ fn formatSliceEscapeImpl(comptime case: Case) type {
777 options: std.fmt.FormatOptions,780 options: std.fmt.FormatOptions,
778 writer: anytype,781 writer: anytype,
779 ) !void {782 ) !void {
783 _ = fmt;
784 _ = options;
780 var buf: [4]u8 = undefined;785 var buf: [4]u8 = undefined;
781786
782 buf[0] = '\\';787 buf[0] = '\\';
...@@ -820,6 +825,7 @@ fn formatSizeImpl(comptime radix: comptime_int) type {...@@ -820,6 +825,7 @@ fn formatSizeImpl(comptime radix: comptime_int) type {
820 options: FormatOptions,825 options: FormatOptions,
821 writer: anytype,826 writer: anytype,
822 ) !void {827 ) !void {
828 _ = fmt;
823 if (value == 0) {829 if (value == 0) {
824 return writer.writeAll("0B");830 return writer.writeAll("0B");
825 }831 }
...@@ -903,6 +909,7 @@ pub fn formatAsciiChar(...@@ -903,6 +909,7 @@ pub fn formatAsciiChar(
903 options: FormatOptions,909 options: FormatOptions,
904 writer: anytype,910 writer: anytype,
905) !void {911) !void {
912 _ = options;
906 return writer.writeAll(@as(*const [1]u8, &c));913 return writer.writeAll(@as(*const [1]u8, &c));
907}914}
908915
...@@ -1362,6 +1369,8 @@ pub fn formatIntBuf(out_buf: []u8, value: anytype, base: u8, case: Case, options...@@ -1362,6 +1369,8 @@ pub fn formatIntBuf(out_buf: []u8, value: anytype, base: u8, case: Case, options
1362}1369}
13631370
1364fn formatDuration(ns: u64, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {1371fn formatDuration(ns: u64, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
1372 _ = fmt;
1373 _ = options;
1365 var ns_remaining = ns;1374 var ns_remaining = ns;
1366 inline for (.{1375 inline for (.{
1367 .{ .ns = 365 * std.time.ns_per_day, .sep = 'y' },1376 .{ .ns = 365 * std.time.ns_per_day, .sep = 'y' },
...@@ -2152,6 +2161,7 @@ test "custom" {...@@ -2152,6 +2161,7 @@ test "custom" {
2152 options: FormatOptions,2161 options: FormatOptions,
2153 writer: anytype,2162 writer: anytype,
2154 ) !void {2163 ) !void {
2164 _ = options;
2155 if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "p")) {2165 if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "p")) {
2156 return std.fmt.format(writer, "({d:.3},{d:.3})", .{ self.x, self.y });2166 return std.fmt.format(writer, "({d:.3},{d:.3})", .{ self.x, self.y });
2157 } else if (comptime std.mem.eql(u8, fmt, "d")) {2167 } else if (comptime std.mem.eql(u8, fmt, "d")) {
...@@ -2340,6 +2350,7 @@ test "formatType max_depth" {...@@ -2340,6 +2350,7 @@ test "formatType max_depth" {
2340 options: FormatOptions,2350 options: FormatOptions,
2341 writer: anytype,2351 writer: anytype,
2342 ) !void {2352 ) !void {
2353 _ = options;
2343 if (fmt.len == 0) {2354 if (fmt.len == 0) {
2344 return std.fmt.format(writer, "({d:.3},{d:.3})", .{ self.x, self.y });2355 return std.fmt.format(writer, "({d:.3},{d:.3})", .{ self.x, self.y });
2345 } else {2356 } else {
lib/std/fs.zig+2-1
...@@ -1541,7 +1541,7 @@ pub const Dir = struct {...@@ -1541,7 +1541,7 @@ pub const Dir = struct {
1541 self: Dir,1541 self: Dir,
1542 target_path: []const u8,1542 target_path: []const u8,
1543 sym_link_path: []const u8,1543 sym_link_path: []const u8,
1544 flags: SymLinkFlags,1544 _: SymLinkFlags,
1545 ) !void {1545 ) !void {
1546 return os.symlinkatWasi(target_path, self.fd, sym_link_path);1546 return os.symlinkatWasi(target_path, self.fd, sym_link_path);
1547 }1547 }
...@@ -1879,6 +1879,7 @@ pub const Dir = struct {...@@ -1879,6 +1879,7 @@ pub const Dir = struct {
1879 /// * NtDll prefixed1879 /// * NtDll prefixed
1880 /// TODO currently this ignores `flags`.1880 /// TODO currently this ignores `flags`.
1881 pub fn accessW(self: Dir, sub_path_w: [*:0]const u16, flags: File.OpenFlags) AccessError!void {1881 pub fn accessW(self: Dir, sub_path_w: [*:0]const u16, flags: File.OpenFlags) AccessError!void {
1882 _ = flags;
1882 return os.faccessatW(self.fd, sub_path_w, 0, 0);1883 return os.faccessatW(self.fd, sub_path_w, 0, 0);
1883 }1884 }
18841885
lib/std/fs/path.zig+2-2
...@@ -579,7 +579,7 @@ pub fn resolveWindows(allocator: *Allocator, paths: []const []const u8) ![]u8 {...@@ -579,7 +579,7 @@ pub fn resolveWindows(allocator: *Allocator, paths: []const []const u8) ![]u8 {
579 // Now we know the disk designator to use, if any, and what kind it is. And our result579 // Now we know the disk designator to use, if any, and what kind it is. And our result
580 // is big enough to append all the paths to.580 // is big enough to append all the paths to.
581 var correct_disk_designator = true;581 var correct_disk_designator = true;
582 for (paths[first_index..]) |p, i| {582 for (paths[first_index..]) |p| {
583 const parsed = windowsParsePath(p);583 const parsed = windowsParsePath(p);
584584
585 if (parsed.kind != WindowsPath.Kind.None) {585 if (parsed.kind != WindowsPath.Kind.None) {
...@@ -660,7 +660,7 @@ pub fn resolvePosix(allocator: *Allocator, paths: []const []const u8) ![]u8 {...@@ -660,7 +660,7 @@ pub fn resolvePosix(allocator: *Allocator, paths: []const []const u8) ![]u8 {
660 }660 }
661 errdefer allocator.free(result);661 errdefer allocator.free(result);
662662
663 for (paths[first_index..]) |p, i| {663 for (paths[first_index..]) |p| {
664 var it = mem.tokenize(p, "/");664 var it = mem.tokenize(p, "/");
665 while (it.next()) |component| {665 while (it.next()) |component| {
666 if (mem.eql(u8, component, ".")) {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,6 +541,7 @@ test "makePath, put some files in it, deleteTree" {
541 try tmp.dir.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "file2.txt", "blah");541 try tmp.dir.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "file2.txt", "blah");
542 try tmp.dir.deleteTree("os_test_tmp");542 try tmp.dir.deleteTree("os_test_tmp");
543 if (tmp.dir.openDir("os_test_tmp", .{})) |dir| {543 if (tmp.dir.openDir("os_test_tmp", .{})) |dir| {
544 _ = dir;
544 @panic("expected error");545 @panic("expected error");
545 } else |err| {546 } else |err| {
546 try testing.expect(err == error.FileNotFound);547 try testing.expect(err == error.FileNotFound);
...@@ -638,6 +639,7 @@ test "access file" {...@@ -638,6 +639,7 @@ test "access file" {
638639
639 try tmp.dir.makePath("os_test_tmp");640 try tmp.dir.makePath("os_test_tmp");
640 if (tmp.dir.access("os_test_tmp" ++ fs.path.sep_str ++ "file.txt", .{})) |ok| {641 if (tmp.dir.access("os_test_tmp" ++ fs.path.sep_str ++ "file.txt", .{})) |ok| {
642 _ = ok;
641 @panic("expected error");643 @panic("expected error");
642 } else |err| {644 } else |err| {
643 try testing.expect(err == error.FileNotFound);645 try testing.expect(err == error.FileNotFound);
lib/std/fs/wasi.zig+2
...@@ -36,6 +36,8 @@ pub const PreopenType = union(PreopenTypeTag) {...@@ -36,6 +36,8 @@ pub const PreopenType = union(PreopenTypeTag) {
36 }36 }
3737
38 pub fn format(self: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: anytype) !void {38 pub fn format(self: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: anytype) !void {
39 _ = fmt;
40 _ = options;
39 try out_stream.print("PreopenType{{ ", .{});41 try out_stream.print("PreopenType{{ ", .{});
40 switch (self) {42 switch (self) {
41 PreopenType.Dir => |path| try out_stream.print(".Dir = '{}'", .{std.zig.fmtId(path)}),43 PreopenType.Dir => |path| try out_stream.print(".Dir = '{}'", .{std.zig.fmtId(path)}),
lib/std/hash/cityhash.zig+1
...@@ -375,6 +375,7 @@ fn SMHasherTest(comptime hash_fn: anytype) u32 {...@@ -375,6 +375,7 @@ fn SMHasherTest(comptime hash_fn: anytype) u32 {
375}375}
376376
377fn CityHash32hashIgnoreSeed(str: []const u8, seed: u32) u32 {377fn CityHash32hashIgnoreSeed(str: []const u8, seed: u32) u32 {
378 _ = seed;
378 return CityHash32.hash(str);379 return CityHash32.hash(str);
379}380}
380381
lib/std/hash_map.zig+6
...@@ -29,6 +29,7 @@ pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K)...@@ -29,6 +29,7 @@ pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K)
2929
30 return struct {30 return struct {
31 fn hash(ctx: Context, key: K) u64 {31 fn hash(ctx: Context, key: K) u64 {
32 _ = ctx;
32 if (comptime trait.hasUniqueRepresentation(K)) {33 if (comptime trait.hasUniqueRepresentation(K)) {
33 return Wyhash.hash(0, std.mem.asBytes(&key));34 return Wyhash.hash(0, std.mem.asBytes(&key));
34 } else {35 } else {
...@@ -43,6 +44,7 @@ pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K)...@@ -43,6 +44,7 @@ pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K)
43pub fn getAutoEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K) bool) {44pub fn getAutoEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K) bool) {
44 return struct {45 return struct {
45 fn eql(ctx: Context, a: K, b: K) bool {46 fn eql(ctx: Context, a: K, b: K) bool {
47 _ = ctx;
46 return meta.eql(a, b);48 return meta.eql(a, b);
47 }49 }
48 }.eql;50 }.eql;
...@@ -78,9 +80,11 @@ pub fn StringHashMapUnmanaged(comptime V: type) type {...@@ -78,9 +80,11 @@ pub fn StringHashMapUnmanaged(comptime V: type) type {
7880
79pub const StringContext = struct {81pub const StringContext = struct {
80 pub fn hash(self: @This(), s: []const u8) u64 {82 pub fn hash(self: @This(), s: []const u8) u64 {
83 _ = self;
81 return hashString(s);84 return hashString(s);
82 }85 }
83 pub fn eql(self: @This(), a: []const u8, b: []const u8) bool {86 pub fn eql(self: @This(), a: []const u8, b: []const u8) bool {
87 _ = self;
84 return eqlString(a, b);88 return eqlString(a, b);
85 }89 }
86};90};
...@@ -1887,9 +1891,11 @@ test "std.hash_map clone" {...@@ -1887,9 +1891,11 @@ test "std.hash_map clone" {
1887test "std.hash_map getOrPutAdapted" {1891test "std.hash_map getOrPutAdapted" {
1888 const AdaptedContext = struct {1892 const AdaptedContext = struct {
1889 fn eql(self: @This(), adapted_key: []const u8, test_key: u64) bool {1893 fn eql(self: @This(), adapted_key: []const u8, test_key: u64) bool {
1894 _ = self;
1890 return std.fmt.parseInt(u64, adapted_key, 10) catch unreachable == test_key;1895 return std.fmt.parseInt(u64, adapted_key, 10) catch unreachable == test_key;
1891 }1896 }
1892 fn hash(self: @This(), adapted_key: []const u8) u64 {1897 fn hash(self: @This(), adapted_key: []const u8) u64 {
1898 _ = self;
1893 const key = std.fmt.parseInt(u64, adapted_key, 10) catch unreachable;1899 const key = std.fmt.parseInt(u64, adapted_key, 10) catch unreachable;
1894 return (AutoContext(u64){}).hash(key);1900 return (AutoContext(u64){}).hash(key);
1895 }1901 }
lib/std/heap.zig+30
...@@ -108,6 +108,8 @@ const CAllocator = struct {...@@ -108,6 +108,8 @@ const CAllocator = struct {
108 len_align: u29,108 len_align: u29,
109 return_address: usize,109 return_address: usize,
110 ) error{OutOfMemory}![]u8 {110 ) error{OutOfMemory}![]u8 {
111 _ = allocator;
112 _ = return_address;
111 assert(len > 0);113 assert(len > 0);
112 assert(std.math.isPowerOfTwo(alignment));114 assert(std.math.isPowerOfTwo(alignment));
113115
...@@ -134,6 +136,9 @@ const CAllocator = struct {...@@ -134,6 +136,9 @@ const CAllocator = struct {
134 len_align: u29,136 len_align: u29,
135 return_address: usize,137 return_address: usize,
136 ) Allocator.Error!usize {138 ) Allocator.Error!usize {
139 _ = allocator;
140 _ = buf_align;
141 _ = return_address;
137 if (new_len == 0) {142 if (new_len == 0) {
138 alignedFree(buf.ptr);143 alignedFree(buf.ptr);
139 return 0;144 return 0;
...@@ -178,6 +183,9 @@ fn rawCAlloc(...@@ -178,6 +183,9 @@ fn rawCAlloc(
178 len_align: u29,183 len_align: u29,
179 ret_addr: usize,184 ret_addr: usize,
180) Allocator.Error![]u8 {185) Allocator.Error![]u8 {
186 _ = self;
187 _ = len_align;
188 _ = ret_addr;
181 assert(ptr_align <= @alignOf(std.c.max_align_t));189 assert(ptr_align <= @alignOf(std.c.max_align_t));
182 const ptr = @ptrCast([*]u8, c.malloc(len) orelse return error.OutOfMemory);190 const ptr = @ptrCast([*]u8, c.malloc(len) orelse return error.OutOfMemory);
183 return ptr[0..len];191 return ptr[0..len];
...@@ -191,6 +199,9 @@ fn rawCResize(...@@ -191,6 +199,9 @@ fn rawCResize(
191 len_align: u29,199 len_align: u29,
192 ret_addr: usize,200 ret_addr: usize,
193) Allocator.Error!usize {201) Allocator.Error!usize {
202 _ = self;
203 _ = old_align;
204 _ = ret_addr;
194 if (new_len == 0) {205 if (new_len == 0) {
195 c.free(buf.ptr);206 c.free(buf.ptr);
196 return 0;207 return 0;
...@@ -231,6 +242,8 @@ pub var next_mmap_addr_hint: ?[*]align(mem.page_size) u8 = null;...@@ -231,6 +242,8 @@ pub var next_mmap_addr_hint: ?[*]align(mem.page_size) u8 = null;
231242
232const PageAllocator = struct {243const PageAllocator = struct {
233 fn alloc(allocator: *Allocator, n: usize, alignment: u29, len_align: u29, ra: usize) error{OutOfMemory}![]u8 {244 fn alloc(allocator: *Allocator, n: usize, alignment: u29, len_align: u29, ra: usize) error{OutOfMemory}![]u8 {
245 _ = allocator;
246 _ = ra;
234 assert(n > 0);247 assert(n > 0);
235 const aligned_len = mem.alignForward(n, mem.page_size);248 const aligned_len = mem.alignForward(n, mem.page_size);
236249
...@@ -334,6 +347,9 @@ const PageAllocator = struct {...@@ -334,6 +347,9 @@ const PageAllocator = struct {
334 len_align: u29,347 len_align: u29,
335 return_address: usize,348 return_address: usize,
336 ) Allocator.Error!usize {349 ) Allocator.Error!usize {
350 _ = allocator;
351 _ = buf_align;
352 _ = return_address;
337 const new_size_aligned = mem.alignForward(new_size, mem.page_size);353 const new_size_aligned = mem.alignForward(new_size, mem.page_size);
338354
339 if (builtin.os.tag == .windows) {355 if (builtin.os.tag == .windows) {
...@@ -482,6 +498,8 @@ const WasmPageAllocator = struct {...@@ -482,6 +498,8 @@ const WasmPageAllocator = struct {
482 }498 }
483499
484 fn alloc(allocator: *Allocator, len: usize, alignment: u29, len_align: u29, ra: usize) error{OutOfMemory}![]u8 {500 fn alloc(allocator: *Allocator, len: usize, alignment: u29, len_align: u29, ra: usize) error{OutOfMemory}![]u8 {
501 _ = allocator;
502 _ = ra;
485 const page_count = nPages(len);503 const page_count = nPages(len);
486 const page_idx = try allocPages(page_count, alignment);504 const page_idx = try allocPages(page_count, alignment);
487 return @intToPtr([*]u8, page_idx * mem.page_size)[0..alignPageAllocLen(page_count * mem.page_size, len, len_align)];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,6 +560,9 @@ const WasmPageAllocator = struct {
542 len_align: u29,560 len_align: u29,
543 return_address: usize,561 return_address: usize,
544 ) error{OutOfMemory}!usize {562 ) error{OutOfMemory}!usize {
563 _ = allocator;
564 _ = buf_align;
565 _ = return_address;
545 const aligned_len = mem.alignForward(buf.len, mem.page_size);566 const aligned_len = mem.alignForward(buf.len, mem.page_size);
546 if (new_len > aligned_len) return error.OutOfMemory;567 if (new_len > aligned_len) return error.OutOfMemory;
547 const current_n = nPages(aligned_len);568 const current_n = nPages(aligned_len);
...@@ -588,6 +609,7 @@ pub const HeapAllocator = switch (builtin.os.tag) {...@@ -588,6 +609,7 @@ pub const HeapAllocator = switch (builtin.os.tag) {
588 len_align: u29,609 len_align: u29,
589 return_address: usize,610 return_address: usize,
590 ) error{OutOfMemory}![]u8 {611 ) error{OutOfMemory}![]u8 {
612 _ = return_address;
591 const self = @fieldParentPtr(HeapAllocator, "allocator", allocator);613 const self = @fieldParentPtr(HeapAllocator, "allocator", allocator);
592614
593 const amt = n + ptr_align - 1 + @sizeOf(usize);615 const amt = n + ptr_align - 1 + @sizeOf(usize);
...@@ -622,6 +644,8 @@ pub const HeapAllocator = switch (builtin.os.tag) {...@@ -622,6 +644,8 @@ pub const HeapAllocator = switch (builtin.os.tag) {
622 len_align: u29,644 len_align: u29,
623 return_address: usize,645 return_address: usize,
624 ) error{OutOfMemory}!usize {646 ) error{OutOfMemory}!usize {
647 _ = buf_align;
648 _ = return_address;
625 const self = @fieldParentPtr(HeapAllocator, "allocator", allocator);649 const self = @fieldParentPtr(HeapAllocator, "allocator", allocator);
626 if (new_size == 0) {650 if (new_size == 0) {
627 os.windows.HeapFree(self.heap_handle.?, 0, @intToPtr(*c_void, getRecordPtr(buf).*));651 os.windows.HeapFree(self.heap_handle.?, 0, @intToPtr(*c_void, getRecordPtr(buf).*));
...@@ -694,6 +718,8 @@ pub const FixedBufferAllocator = struct {...@@ -694,6 +718,8 @@ pub const FixedBufferAllocator = struct {
694 }718 }
695719
696 fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29, ra: usize) ![]u8 {720 fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29, ra: usize) ![]u8 {
721 _ = len_align;
722 _ = ra;
697 const self = @fieldParentPtr(FixedBufferAllocator, "allocator", allocator);723 const self = @fieldParentPtr(FixedBufferAllocator, "allocator", allocator);
698 const adjust_off = mem.alignPointerOffset(self.buffer.ptr + self.end_index, ptr_align) orelse724 const adjust_off = mem.alignPointerOffset(self.buffer.ptr + self.end_index, ptr_align) orelse
699 return error.OutOfMemory;725 return error.OutOfMemory;
...@@ -716,6 +742,8 @@ pub const FixedBufferAllocator = struct {...@@ -716,6 +742,8 @@ pub const FixedBufferAllocator = struct {
716 len_align: u29,742 len_align: u29,
717 return_address: usize,743 return_address: usize,
718 ) Allocator.Error!usize {744 ) Allocator.Error!usize {
745 _ = buf_align;
746 _ = return_address;
719 const self = @fieldParentPtr(FixedBufferAllocator, "allocator", allocator);747 const self = @fieldParentPtr(FixedBufferAllocator, "allocator", allocator);
720 assert(self.ownsSlice(buf)); // sanity check748 assert(self.ownsSlice(buf)); // sanity check
721749
...@@ -766,6 +794,8 @@ pub const ThreadSafeFixedBufferAllocator = blk: {...@@ -766,6 +794,8 @@ pub const ThreadSafeFixedBufferAllocator = blk: {
766 }794 }
767795
768 fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29, ra: usize) ![]u8 {796 fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29, ra: usize) ![]u8 {
797 _ = len_align;
798 _ = ra;
769 const self = @fieldParentPtr(ThreadSafeFixedBufferAllocator, "allocator", allocator);799 const self = @fieldParentPtr(ThreadSafeFixedBufferAllocator, "allocator", allocator);
770 var end_index = @atomicLoad(usize, &self.end_index, builtin.AtomicOrder.SeqCst);800 var end_index = @atomicLoad(usize, &self.end_index, builtin.AtomicOrder.SeqCst);
771 while (true) {801 while (true) {
lib/std/heap/arena_allocator.zig+5
...@@ -66,6 +66,8 @@ pub const ArenaAllocator = struct {...@@ -66,6 +66,8 @@ pub const ArenaAllocator = struct {
66 }66 }
6767
68 fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29, ra: usize) ![]u8 {68 fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29, ra: usize) ![]u8 {
69 _ = len_align;
70 _ = ra;
69 const self = @fieldParentPtr(ArenaAllocator, "allocator", allocator);71 const self = @fieldParentPtr(ArenaAllocator, "allocator", allocator);
7072
71 var cur_node = if (self.state.buffer_list.first) |first_node| first_node else try self.createNode(0, n + ptr_align);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,6 +97,9 @@ pub const ArenaAllocator = struct {
95 }97 }
9698
97 fn resize(allocator: *Allocator, buf: []u8, buf_align: u29, new_len: usize, len_align: u29, ret_addr: usize) Allocator.Error!usize {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 const self = @fieldParentPtr(ArenaAllocator, "allocator", allocator);103 const self = @fieldParentPtr(ArenaAllocator, "allocator", allocator);
99104
100 const cur_node = self.state.buffer_list.first orelse return error.OutOfMemory;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,9 +37,9 @@ pub fn LogToWriterAllocator(comptime Writer: type) type {
37 const self = @fieldParentPtr(Self, "allocator", allocator);37 const self = @fieldParentPtr(Self, "allocator", allocator);
38 self.writer.print("alloc : {}", .{len}) catch {};38 self.writer.print("alloc : {}", .{len}) catch {};
39 const result = self.parent_allocator.allocFn(self.parent_allocator, len, ptr_align, len_align, ra);39 const result = self.parent_allocator.allocFn(self.parent_allocator, len, ptr_align, len_align, ra);
40 if (result) |buff| {40 if (result) |_| {
41 self.writer.print(" success!\n", .{}) catch {};41 self.writer.print(" success!\n", .{}) catch {};
42 } else |err| {42 } else |_| {
43 self.writer.print(" failure!\n", .{}) catch {};43 self.writer.print(" failure!\n", .{}) catch {};
44 }44 }
45 return result;45 return result;
lib/std/heap/logging_allocator.zig+1-1
...@@ -65,7 +65,7 @@ pub fn ScopedLoggingAllocator(...@@ -65,7 +65,7 @@ pub fn ScopedLoggingAllocator(
65 ) error{OutOfMemory}![]u8 {65 ) error{OutOfMemory}![]u8 {
66 const self = @fieldParentPtr(Self, "allocator", allocator);66 const self = @fieldParentPtr(Self, "allocator", allocator);
67 const result = self.parent_allocator.allocFn(self.parent_allocator, len, ptr_align, len_align, ra);67 const result = self.parent_allocator.allocFn(self.parent_allocator, len, ptr_align, len_align, ra);
68 if (result) |buff| {68 if (result) |_| {
69 logHelper(69 logHelper(
70 success_log_level,70 success_log_level,
71 "alloc - success - len: {}, ptr_align: {}, len_align: {}",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,6 +161,7 @@ pub const null_writer = @as(NullWriter, .{ .context = {} });
161161
162const NullWriter = Writer(void, error{}, dummyWrite);162const NullWriter = Writer(void, error{}, dummyWrite);
163fn dummyWrite(context: void, data: []const u8) error{}!usize {163fn dummyWrite(context: void, data: []const u8) error{}!usize {
164 _ = context;
164 return data.len;165 return data.len;
165}166}
166167
lib/std/io/bit_reader.zig+1-1
...@@ -149,7 +149,7 @@ pub fn BitReader(endian: builtin.Endian, comptime ReaderType: type) type {...@@ -149,7 +149,7 @@ pub fn BitReader(endian: builtin.Endian, comptime ReaderType: type) type {
149 var out_bits_total = @as(usize, 0);149 var out_bits_total = @as(usize, 0);
150 //@NOTE: I'm not sure this is a good idea, maybe alignToByte should be forced150 //@NOTE: I'm not sure this is a good idea, maybe alignToByte should be forced
151 if (self.bit_count > 0) {151 if (self.bit_count > 0) {
152 for (buffer) |*b, i| {152 for (buffer) |*b| {
153 b.* = try self.readBits(u8, u8_bit_count, &out_bits);153 b.* = try self.readBits(u8, u8_bit_count, &out_bits);
154 out_bits_total += out_bits;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,7 +128,7 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type {
128 pub fn write(self: *Self, buffer: []const u8) Error!usize {128 pub fn write(self: *Self, buffer: []const u8) Error!usize {
129 // TODO: I'm not sure this is a good idea, maybe flushBits should be forced129 // TODO: I'm not sure this is a good idea, maybe flushBits should be forced
130 if (self.bit_count > 0) {130 if (self.bit_count > 0) {
131 for (buffer) |b, i|131 for (buffer) |b|
132 try self.writeBits(b, u8_bit_count);132 try self.writeBits(b, u8_bit_count);
133 return buffer.len;133 return buffer.len;
134 }134 }
lib/std/json.zig+8-6
...@@ -1221,11 +1221,11 @@ test "json.token premature object close" {...@@ -1221,11 +1221,11 @@ test "json.token premature object close" {
1221pub fn validate(s: []const u8) bool {1221pub fn validate(s: []const u8) bool {
1222 var p = StreamingParser.init();1222 var p = StreamingParser.init();
12231223
1224 for (s) |c, i| {1224 for (s) |c| {
1225 var token1: ?Token = undefined;1225 var token1: ?Token = undefined;
1226 var token2: ?Token = undefined;1226 var token2: ?Token = undefined;
12271227
1228 p.feed(c, &token1, &token2) catch |err| {1228 p.feed(c, &token1, &token2) catch {
1229 return false;1229 return false;
1230 };1230 };
1231 }1231 }
...@@ -1410,7 +1410,7 @@ fn parsedEqual(a: anytype, b: @TypeOf(a)) bool {...@@ -1410,7 +1410,7 @@ fn parsedEqual(a: anytype, b: @TypeOf(a)) bool {
1410 if (a == null or b == null) return false;1410 if (a == null or b == null) return false;
1411 return parsedEqual(a.?, b.?);1411 return parsedEqual(a.?, b.?);
1412 },1412 },
1413 .Union => |unionInfo| {1413 .Union => {
1414 if (info.tag_type) |UnionTag| {1414 if (info.tag_type) |UnionTag| {
1415 const tag_a = std.meta.activeTag(a);1415 const tag_a = std.meta.activeTag(a);
1416 const tag_b = std.meta.activeTag(b);1416 const tag_b = std.meta.activeTag(b);
...@@ -1771,7 +1771,7 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options:...@@ -1771,7 +1771,7 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options:
1771 const source_slice = stringToken.slice(tokens.slice, tokens.i - 1);1771 const source_slice = stringToken.slice(tokens.slice, tokens.i - 1);
1772 switch (stringToken.escapes) {1772 switch (stringToken.escapes) {
1773 .None => return allocator.dupe(u8, source_slice),1773 .None => return allocator.dupe(u8, source_slice),
1774 .Some => |some_escapes| {1774 .Some => {
1775 const output = try allocator.alloc(u8, stringToken.decodedLength());1775 const output = try allocator.alloc(u8, stringToken.decodedLength());
1776 errdefer allocator.free(output);1776 errdefer allocator.free(output);
1777 try unescapeValidString(output, source_slice);1777 try unescapeValidString(output, source_slice);
...@@ -2391,7 +2391,7 @@ pub const Parser = struct {...@@ -2391,7 +2391,7 @@ pub const Parser = struct {
2391 const slice = s.slice(input, i);2391 const slice = s.slice(input, i);
2392 switch (s.escapes) {2392 switch (s.escapes) {
2393 .None => return Value{ .String = if (p.copy_strings) try allocator.dupe(u8, slice) else slice },2393 .None => return Value{ .String = if (p.copy_strings) try allocator.dupe(u8, slice) else slice },
2394 .Some => |some_escapes| {2394 .Some => {
2395 const output = try allocator.alloc(u8, s.decodedLength());2395 const output = try allocator.alloc(u8, s.decodedLength());
2396 errdefer allocator.free(output);2396 errdefer allocator.free(output);
2397 try unescapeValidString(output, slice);2397 try unescapeValidString(output, slice);
...@@ -2401,6 +2401,7 @@ pub const Parser = struct {...@@ -2401,6 +2401,7 @@ pub const Parser = struct {
2401 }2401 }
24022402
2403 fn parseNumber(p: *Parser, n: std.meta.TagPayload(Token, Token.Number), input: []const u8, i: usize) !Value {2403 fn parseNumber(p: *Parser, n: std.meta.TagPayload(Token, Token.Number), input: []const u8, i: usize) !Value {
2404 _ = p;
2404 return if (n.is_integer)2405 return if (n.is_integer)
2405 Value{2406 Value{
2406 .Integer = std.fmt.parseInt(i64, n.slice(input, i), 10) catch |e| switch (e) {2407 .Integer = std.fmt.parseInt(i64, n.slice(input, i), 10) catch |e| switch (e) {
...@@ -2815,7 +2816,7 @@ pub fn stringify(...@@ -2815,7 +2816,7 @@ pub fn stringify(
2815 if (child_options.whitespace) |*child_whitespace| {2816 if (child_options.whitespace) |*child_whitespace| {
2816 child_whitespace.indent_level += 1;2817 child_whitespace.indent_level += 1;
2817 }2818 }
2818 inline for (S.fields) |Field, field_i| {2819 inline for (S.fields) |Field| {
2819 // don't include void fields2820 // don't include void fields
2820 if (Field.field_type == void) continue;2821 if (Field.field_type == void) continue;
28212822
...@@ -3114,6 +3115,7 @@ test "stringify struct with custom stringifier" {...@@ -3114,6 +3115,7 @@ test "stringify struct with custom stringifier" {
3114 options: StringifyOptions,3115 options: StringifyOptions,
3115 out_stream: anytype,3116 out_stream: anytype,
3116 ) !void {3117 ) !void {
3118 _ = value;
3117 try out_stream.writeAll("[\"something special\",");3119 try out_stream.writeAll("[\"something special\",");
3118 try stringify(42, options, out_stream);3120 try stringify(42, options, out_stream);
3119 try out_stream.writeByte(']');3121 try out_stream.writeByte(']');
lib/std/linked_list.zig+1-1
...@@ -63,7 +63,7 @@ pub fn SinglyLinkedList(comptime T: type) type {...@@ -63,7 +63,7 @@ pub fn SinglyLinkedList(comptime T: type) type {
63 pub fn countChildren(node: *const Node) usize {63 pub fn countChildren(node: *const Node) usize {
64 var count: usize = 0;64 var count: usize = 0;
65 var it: ?*const Node = node.next;65 var it: ?*const Node = node.next;
66 while (it) |n| : (it = n.next) {66 while (it) |_| : (it = n.next) {
67 count += 1;67 count += 1;
68 }68 }
69 return count;69 return count;
lib/std/math/big/int.zig+4
...@@ -458,6 +458,7 @@ pub const Mutable = struct {...@@ -458,6 +458,7 @@ pub const Mutable = struct {
458 /// If `allocator` is provided, it will be used for temporary storage to improve458 /// If `allocator` is provided, it will be used for temporary storage to improve
459 /// multiplication performance. `error.OutOfMemory` is handled with a fallback algorithm.459 /// multiplication performance. `error.OutOfMemory` is handled with a fallback algorithm.
460 pub fn sqrNoAlias(rma: *Mutable, a: Const, opt_allocator: ?*Allocator) void {460 pub fn sqrNoAlias(rma: *Mutable, a: Const, opt_allocator: ?*Allocator) void {
461 _ = opt_allocator;
461 assert(rma.limbs.ptr != a.limbs.ptr); // illegal aliasing462 assert(rma.limbs.ptr != a.limbs.ptr); // illegal aliasing
462463
463 mem.set(Limb, rma.limbs, 0);464 mem.set(Limb, rma.limbs, 0);
...@@ -676,6 +677,7 @@ pub const Mutable = struct {...@@ -676,6 +677,7 @@ pub const Mutable = struct {
676 ///677 ///
677 /// `limbs_buffer` is used for temporary storage during the operation.678 /// `limbs_buffer` is used for temporary storage during the operation.
678 pub fn gcdNoAlias(rma: *Mutable, x: Const, y: Const, limbs_buffer: *std.ArrayList(Limb)) !void {679 pub fn gcdNoAlias(rma: *Mutable, x: Const, y: Const, limbs_buffer: *std.ArrayList(Limb)) !void {
680 _ = limbs_buffer;
679 assert(rma.limbs.ptr != x.limbs.ptr); // illegal aliasing681 assert(rma.limbs.ptr != x.limbs.ptr); // illegal aliasing
680 assert(rma.limbs.ptr != y.limbs.ptr); // illegal aliasing682 assert(rma.limbs.ptr != y.limbs.ptr); // illegal aliasing
681 return gcdLehmer(rma, x, y, allocator);683 return gcdLehmer(rma, x, y, allocator);
...@@ -1141,6 +1143,7 @@ pub const Const = struct {...@@ -1141,6 +1143,7 @@ pub const Const = struct {
1141 options: std.fmt.FormatOptions,1143 options: std.fmt.FormatOptions,
1142 out_stream: anytype,1144 out_stream: anytype,
1143 ) !void {1145 ) !void {
1146 _ = options;
1144 comptime var radix = 10;1147 comptime var radix = 10;
1145 comptime var case: std.fmt.Case = .lower;1148 comptime var case: std.fmt.Case = .lower;
11461149
...@@ -1618,6 +1621,7 @@ pub const Managed = struct {...@@ -1618,6 +1621,7 @@ pub const Managed = struct {
1618 /// Converts self to a string in the requested base. Memory is allocated from the provided1621 /// Converts self to a string in the requested base. Memory is allocated from the provided
1619 /// allocator and not the one present in self.1622 /// allocator and not the one present in self.
1620 pub fn toString(self: Managed, allocator: *Allocator, base: u8, case: std.fmt.Case) ![]u8 {1623 pub fn toString(self: Managed, allocator: *Allocator, base: u8, case: std.fmt.Case) ![]u8 {
1624 _ = allocator;
1621 if (base < 2 or base > 16) return error.InvalidBase;1625 if (base < 2 or base > 16) return error.InvalidBase;
1622 return self.toConst().toStringAlloc(self.allocator, base, case);1626 return self.toConst().toStringAlloc(self.allocator, base, case);
1623 }1627 }
lib/std/mem.zig+5
...@@ -139,6 +139,11 @@ var failAllocator = Allocator{...@@ -139,6 +139,11 @@ var failAllocator = Allocator{
139 .resizeFn = Allocator.noResize,139 .resizeFn = Allocator.noResize,
140};140};
141fn failAllocatorAlloc(self: *Allocator, n: usize, alignment: u29, len_align: u29, ra: usize) Allocator.Error![]u8 {141fn 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 return error.OutOfMemory;147 return error.OutOfMemory;
143}148}
144149
lib/std/mem/Allocator.zig+4
...@@ -55,6 +55,10 @@ pub fn noResize(...@@ -55,6 +55,10 @@ pub fn noResize(
55 len_align: u29,55 len_align: u29,
56 ret_addr: usize,56 ret_addr: usize,
57) Error!usize {57) Error!usize {
58 _ = self;
59 _ = buf_align;
60 _ = len_align;
61 _ = ret_addr;
58 if (new_len > buf.len)62 if (new_len > buf.len)
59 return error.OutOfMemory;63 return error.OutOfMemory;
60 return new_len;64 return new_len;
lib/std/meta.zig+1
...@@ -843,6 +843,7 @@ pub const refAllDecls = @compileError("refAllDecls has been moved from std.meta...@@ -843,6 +843,7 @@ pub const refAllDecls = @compileError("refAllDecls has been moved from std.meta
843pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const Decl {843pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const Decl {
844 const S = struct {844 const S = struct {
845 fn declNameLessThan(context: void, lhs: *const Decl, rhs: *const Decl) bool {845 fn declNameLessThan(context: void, lhs: *const Decl, rhs: *const Decl) bool {
846 _ = context;
846 return mem.lessThan(u8, lhs.name, rhs.name);847 return mem.lessThan(u8, lhs.name, rhs.name);
847 }848 }
848 };849 };
lib/std/meta/trailer_flags.zig+1
...@@ -108,6 +108,7 @@ pub fn TrailerFlags(comptime Fields: type) type {...@@ -108,6 +108,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
108 }108 }
109109
110 pub fn offset(self: Self, p: [*]align(@alignOf(Fields)) const u8, comptime field: FieldEnum) usize {110 pub fn offset(self: Self, p: [*]align(@alignOf(Fields)) const u8, comptime field: FieldEnum) usize {
111 _ = p;
111 var off: usize = 0;112 var off: usize = 0;
112 inline for (@typeInfo(Fields).Struct.fields) |field_info, i| {113 inline for (@typeInfo(Fields).Struct.fields) |field_info, i| {
113 const active = (self.bits & (1 << i)) != 0;114 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,6 +92,7 @@ pub fn MultiArrayList(comptime S: type) type {
92 }92 }
93 const Sort = struct {93 const Sort = struct {
94 fn lessThan(trash: *i32, lhs: Data, rhs: Data) bool {94 fn lessThan(trash: *i32, lhs: Data, rhs: Data) bool {
95 _ = trash;
95 return lhs.alignment > rhs.alignment;96 return lhs.alignment > rhs.alignment;
96 }97 }
97 };98 };
...@@ -221,7 +222,7 @@ pub fn MultiArrayList(comptime S: type) type {...@@ -221,7 +222,7 @@ pub fn MultiArrayList(comptime S: type) type {
221 /// retain list ordering.222 /// retain list ordering.
222 pub fn swapRemove(self: *Self, index: usize) void {223 pub fn swapRemove(self: *Self, index: usize) void {
223 const slices = self.slice();224 const slices = self.slice();
224 inline for (fields) |field_info, i| {225 inline for (fields) |_, i| {
225 const field_slice = slices.items(@intToEnum(Field, i));226 const field_slice = slices.items(@intToEnum(Field, i));
226 field_slice[index] = field_slice[self.len - 1];227 field_slice[index] = field_slice[self.len - 1];
227 field_slice[self.len - 1] = undefined;228 field_slice[self.len - 1] = undefined;
...@@ -233,7 +234,7 @@ pub fn MultiArrayList(comptime S: type) type {...@@ -233,7 +234,7 @@ pub fn MultiArrayList(comptime S: type) type {
233 /// after it to preserve order.234 /// after it to preserve order.
234 pub fn orderedRemove(self: *Self, index: usize) void {235 pub fn orderedRemove(self: *Self, index: usize) void {
235 const slices = self.slice();236 const slices = self.slice();
236 inline for (fields) |field_info, field_index| {237 inline for (fields) |_, field_index| {
237 const field_slice = slices.items(@intToEnum(Field, field_index));238 const field_slice = slices.items(@intToEnum(Field, field_index));
238 var i = index;239 var i = index;
239 while (i < self.len - 1) : (i += 1) {240 while (i < self.len - 1) : (i += 1) {
lib/std/net.zig+7
...@@ -270,6 +270,8 @@ pub const Ip4Address = extern struct {...@@ -270,6 +270,8 @@ pub const Ip4Address = extern struct {
270 options: std.fmt.FormatOptions,270 options: std.fmt.FormatOptions,
271 out_stream: anytype,271 out_stream: anytype,
272 ) !void {272 ) !void {
273 _ = fmt;
274 _ = options;
273 const bytes = @ptrCast(*const [4]u8, &self.sa.addr);275 const bytes = @ptrCast(*const [4]u8, &self.sa.addr);
274 try std.fmt.format(out_stream, "{}.{}.{}.{}:{}", .{276 try std.fmt.format(out_stream, "{}.{}.{}.{}:{}", .{
275 bytes[0],277 bytes[0],
...@@ -281,6 +283,7 @@ pub const Ip4Address = extern struct {...@@ -281,6 +283,7 @@ pub const Ip4Address = extern struct {
281 }283 }
282284
283 pub fn getOsSockLen(self: Ip4Address) os.socklen_t {285 pub fn getOsSockLen(self: Ip4Address) os.socklen_t {
286 _ = self;
284 return @sizeOf(os.sockaddr_in);287 return @sizeOf(os.sockaddr_in);
285 }288 }
286};289};
...@@ -556,6 +559,8 @@ pub const Ip6Address = extern struct {...@@ -556,6 +559,8 @@ pub const Ip6Address = extern struct {
556 options: std.fmt.FormatOptions,559 options: std.fmt.FormatOptions,
557 out_stream: anytype,560 out_stream: anytype,
558 ) !void {561 ) !void {
562 _ = fmt;
563 _ = options;
559 const port = mem.bigToNative(u16, self.sa.port);564 const port = mem.bigToNative(u16, self.sa.port);
560 if (mem.eql(u8, self.sa.addr[0..12], &[_]u8{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff })) {565 if (mem.eql(u8, self.sa.addr[0..12], &[_]u8{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff })) {
561 try std.fmt.format(out_stream, "[::ffff:{}.{}.{}.{}]:{}", .{566 try std.fmt.format(out_stream, "[::ffff:{}.{}.{}.{}]:{}", .{
...@@ -598,6 +603,7 @@ pub const Ip6Address = extern struct {...@@ -598,6 +603,7 @@ pub const Ip6Address = extern struct {
598 }603 }
599604
600 pub fn getOsSockLen(self: Ip6Address) os.socklen_t {605 pub fn getOsSockLen(self: Ip6Address) os.socklen_t {
606 _ = self;
601 return @sizeOf(os.sockaddr_in6);607 return @sizeOf(os.sockaddr_in6);
602 }608 }
603};609};
...@@ -1062,6 +1068,7 @@ fn IN6_IS_ADDR_SITELOCAL(a: [16]u8) bool {...@@ -1062,6 +1068,7 @@ fn IN6_IS_ADDR_SITELOCAL(a: [16]u8) bool {
10621068
1063// Parameters `b` and `a` swapped to make this descending.1069// Parameters `b` and `a` swapped to make this descending.
1064fn addrCmpLessThan(context: void, b: LookupAddr, a: LookupAddr) bool {1070fn addrCmpLessThan(context: void, b: LookupAddr, a: LookupAddr) bool {
1071 _ = context;
1065 return a.sortkey < b.sortkey;1072 return a.sortkey < b.sortkey;
1066}1073}
10671074
lib/std/once.zig+1
...@@ -61,6 +61,7 @@ test "Once executes its function just once" {...@@ -61,6 +61,7 @@ test "Once executes its function just once" {
61 for (threads) |*handle| {61 for (threads) |*handle| {
62 handle.* = try std.Thread.spawn(struct {62 handle.* = try std.Thread.spawn(struct {
63 fn thread_fn(x: u8) void {63 fn thread_fn(x: u8) void {
64 _ = x;
64 global_once.call();65 global_once.call();
65 }66 }
66 }.thread_fn, 0);67 }.thread_fn, 0);
lib/std/os.zig+10
...@@ -1164,6 +1164,7 @@ fn openOptionsFromFlags(flags: u32) windows.OpenFileOptions {...@@ -1164,6 +1164,7 @@ fn openOptionsFromFlags(flags: u32) windows.OpenFileOptions {
1164/// TODO currently, this function does not handle all flag combinations1164/// TODO currently, this function does not handle all flag combinations
1165/// or makes use of perm argument.1165/// or makes use of perm argument.
1166pub fn openW(file_path_w: []const u16, flags: u32, perm: mode_t) OpenError!fd_t {1166pub fn openW(file_path_w: []const u16, flags: u32, perm: mode_t) OpenError!fd_t {
1167 _ = perm;
1167 var options = openOptionsFromFlags(flags);1168 var options = openOptionsFromFlags(flags);
1168 options.dir = std.fs.cwd().fd;1169 options.dir = std.fs.cwd().fd;
1169 return windows.OpenFile(file_path_w, options) catch |err| switch (err) {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,6 +1274,7 @@ pub fn openatZ(dir_fd: fd_t, file_path: [*:0]const u8, flags: u32, mode: mode_t)
1273/// TODO currently, this function does not handle all flag combinations1274/// TODO currently, this function does not handle all flag combinations
1274/// or makes use of perm argument.1275/// or makes use of perm argument.
1275pub fn openatW(dir_fd: fd_t, file_path_w: []const u16, flags: u32, mode: mode_t) OpenError!fd_t {1276pub fn openatW(dir_fd: fd_t, file_path_w: []const u16, flags: u32, mode: mode_t) OpenError!fd_t {
1277 _ = mode;
1276 var options = openOptionsFromFlags(flags);1278 var options = openOptionsFromFlags(flags);
1277 options.dir = dir_fd;1279 options.dir = dir_fd;
1278 return windows.OpenFile(file_path_w, options) catch |err| switch (err) {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,6 +2171,7 @@ pub fn mkdirat(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirError!v
2169pub const mkdiratC = @compileError("deprecated: renamed to mkdiratZ");2171pub const mkdiratC = @compileError("deprecated: renamed to mkdiratZ");
21702172
2171pub fn mkdiratWasi(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirError!void {2173pub fn mkdiratWasi(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirError!void {
2174 _ = mode;
2172 switch (wasi.path_create_directory(dir_fd, sub_dir_path.ptr, sub_dir_path.len)) {2175 switch (wasi.path_create_directory(dir_fd, sub_dir_path.ptr, sub_dir_path.len)) {
2173 wasi.ESUCCESS => return,2176 wasi.ESUCCESS => return,
2174 wasi.EACCES => return error.AccessDenied,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,6 +2219,7 @@ pub fn mkdiratZ(dir_fd: fd_t, sub_dir_path: [*:0]const u8, mode: u32) MakeDirErr
2216}2219}
22172220
2218pub fn mkdiratW(dir_fd: fd_t, sub_path_w: []const u16, mode: u32) MakeDirError!void {2221pub fn mkdiratW(dir_fd: fd_t, sub_path_w: []const u16, mode: u32) MakeDirError!void {
2222 _ = mode;
2219 const sub_dir_handle = windows.OpenFile(sub_path_w, .{2223 const sub_dir_handle = windows.OpenFile(sub_path_w, .{
2220 .dir = dir_fd,2224 .dir = dir_fd,
2221 .access_mask = windows.GENERIC_READ | windows.SYNCHRONIZE,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,6 +2295,7 @@ pub fn mkdirZ(dir_path: [*:0]const u8, mode: u32) MakeDirError!void {
22912295
2292/// Windows-only. Same as `mkdir` but the parameters is WTF16 encoded.2296/// Windows-only. Same as `mkdir` but the parameters is WTF16 encoded.
2293pub fn mkdirW(dir_path_w: []const u16, mode: u32) MakeDirError!void {2297pub fn mkdirW(dir_path_w: []const u16, mode: u32) MakeDirError!void {
2298 _ = mode;
2294 const sub_dir_handle = windows.OpenFile(dir_path_w, .{2299 const sub_dir_handle = windows.OpenFile(dir_path_w, .{
2295 .dir = std.fs.cwd().fd,2300 .dir = std.fs.cwd().fd,
2296 .access_mask = windows.GENERIC_READ | windows.SYNCHRONIZE,2301 .access_mask = windows.GENERIC_READ | windows.SYNCHRONIZE,
...@@ -3868,6 +3873,7 @@ pub fn accessZ(path: [*:0]const u8, mode: u32) AccessError!void {...@@ -3868,6 +3873,7 @@ pub fn accessZ(path: [*:0]const u8, mode: u32) AccessError!void {
3868/// Otherwise use `access` or `accessC`.3873/// Otherwise use `access` or `accessC`.
3869/// TODO currently this ignores `mode`.3874/// TODO currently this ignores `mode`.
3870pub fn accessW(path: [*:0]const u16, mode: u32) windows.GetFileAttributesError!void {3875pub fn accessW(path: [*:0]const u16, mode: u32) windows.GetFileAttributesError!void {
3876 _ = mode;
3871 const ret = try windows.GetFileAttributesW(path);3877 const ret = try windows.GetFileAttributesW(path);
3872 if (ret != windows.INVALID_FILE_ATTRIBUTES) {3878 if (ret != windows.INVALID_FILE_ATTRIBUTES) {
3873 return;3879 return;
...@@ -3918,6 +3924,8 @@ pub fn faccessatZ(dirfd: fd_t, path: [*:0]const u8, mode: u32, flags: u32) Acces...@@ -3918,6 +3924,8 @@ pub fn faccessatZ(dirfd: fd_t, path: [*:0]const u8, mode: u32, flags: u32) Acces
3918/// is NtDll-prefixed, null-terminated, WTF-16 encoded.3924/// is NtDll-prefixed, null-terminated, WTF-16 encoded.
3919/// TODO currently this ignores `mode` and `flags`3925/// TODO currently this ignores `mode` and `flags`
3920pub fn faccessatW(dirfd: fd_t, sub_path_w: [*:0]const u16, mode: u32, flags: u32) AccessError!void {3926pub fn faccessatW(dirfd: fd_t, sub_path_w: [*:0]const u16, mode: u32, flags: u32) AccessError!void {
3927 _ = mode;
3928 _ = flags;
3921 if (sub_path_w[0] == '.' and sub_path_w[1] == 0) {3929 if (sub_path_w[0] == '.' and sub_path_w[1] == 0) {
3922 return;3930 return;
3923 }3931 }
...@@ -4895,6 +4903,8 @@ pub fn res_mkquery(...@@ -4895,6 +4903,8 @@ pub fn res_mkquery(
4895 newrr: ?[*]const u8,4903 newrr: ?[*]const u8,
4896 buf: []u8,4904 buf: []u8,
4897) usize {4905) usize {
4906 _ = data;
4907 _ = newrr;
4898 // This implementation is ported from musl libc.4908 // This implementation is ported from musl libc.
4899 // A more idiomatic "ziggy" implementation would be welcome.4909 // A more idiomatic "ziggy" implementation would be welcome.
4900 var name = dname;4910 var name = dname;
lib/std/os/bits/linux.zig+1-1
...@@ -1286,7 +1286,7 @@ pub const CAP_BLOCK_SUSPEND = 36;...@@ -1286,7 +1286,7 @@ pub const CAP_BLOCK_SUSPEND = 36;
1286pub const CAP_AUDIT_READ = 37;1286pub const CAP_AUDIT_READ = 37;
1287pub const CAP_LAST_CAP = CAP_AUDIT_READ;1287pub const CAP_LAST_CAP = CAP_AUDIT_READ;
12881288
1289pub fn cap_valid(u8: x) bool {1289pub fn cap_valid(x: u8) bool {
1290 return x >= 0 and x <= CAP_LAST_CAP;1290 return x >= 0 and x <= CAP_LAST_CAP;
1291}1291}
12921292
lib/std/os/linux.zig+2-1
...@@ -70,6 +70,7 @@ fn splitValueLE64(val: i64) [2]u32 {...@@ -70,6 +70,7 @@ fn splitValueLE64(val: i64) [2]u32 {
70 };70 };
71}71}
72fn splitValueBE64(val: i64) [2]u32 {72fn splitValueBE64(val: i64) [2]u32 {
73 _ = val;
73 return [2]u32{74 return [2]u32{
74 @truncate(u32, u >> 32),75 @truncate(u32, u >> 32),
75 @truncate(u32, u),76 @truncate(u32, u),
...@@ -1022,7 +1023,7 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize...@@ -1022,7 +1023,7 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize
1022 for (msgvec[0..kvlen]) |*msg, i| {1023 for (msgvec[0..kvlen]) |*msg, i| {
1023 var size: i32 = 0;1024 var size: i32 = 0;
1024 const msg_iovlen = @intCast(usize, msg.msg_hdr.msg_iovlen); // kernel side this is treated as unsigned1025 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 if (iov.iov_len > std.math.maxInt(i32) or @addWithOverflow(i32, size, @intCast(i32, iov.iov_len), &size)) {1027 if (iov.iov_len > std.math.maxInt(i32) or @addWithOverflow(i32, size, @intCast(i32, iov.iov_len), &size)) {
1027 // batch-send all messages up to the current message1028 // batch-send all messages up to the current message
1028 if (next_unsent < i) {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,7 +1513,7 @@ pub fn map_create(map_type: MapType, key_size: u32, value_size: u32, max_entries
1513 EINVAL => error.MapTypeOrAttrInvalid,1513 EINVAL => error.MapTypeOrAttrInvalid,
1514 ENOMEM => error.SystemResources,1514 ENOMEM => error.SystemResources,
1515 EPERM => error.AccessDenied,1515 EPERM => error.AccessDenied,
1516 else => |err| unexpectedErrno(rc),1516 else => unexpectedErrno(rc),
1517 };1517 };
1518}1518}
15191519
...@@ -1539,7 +1539,7 @@ pub fn map_lookup_elem(fd: fd_t, key: []const u8, value: []u8) !void {...@@ -1539,7 +1539,7 @@ pub fn map_lookup_elem(fd: fd_t, key: []const u8, value: []u8) !void {
1539 EINVAL => return error.FieldInAttrNeedsZeroing,1539 EINVAL => return error.FieldInAttrNeedsZeroing,
1540 ENOENT => return error.NotFound,1540 ENOENT => return error.NotFound,
1541 EPERM => return error.AccessDenied,1541 EPERM => return error.AccessDenied,
1542 else => |err| return unexpectedErrno(rc),1542 else => return unexpectedErrno(rc),
1543 }1543 }
1544}1544}
15451545
lib/std/os/linux/io_uring.zig+3
...@@ -284,6 +284,7 @@ pub const IO_Uring = struct {...@@ -284,6 +284,7 @@ pub const IO_Uring = struct {
284 }284 }
285285
286 fn copy_cqes_ready(self: *IO_Uring, cqes: []io_uring_cqe, wait_nr: u32) u32 {286 fn copy_cqes_ready(self: *IO_Uring, cqes: []io_uring_cqe, wait_nr: u32) u32 {
287 _ = wait_nr;
287 const ready = self.cq_ready();288 const ready = self.cq_ready();
288 const count = std.math.min(cqes.len, ready);289 const count = std.math.min(cqes.len, ready);
289 var head = self.cq.head.*;290 var head = self.cq.head.*;
...@@ -320,6 +321,7 @@ pub const IO_Uring = struct {...@@ -320,6 +321,7 @@ pub const IO_Uring = struct {
320 /// Not idempotent, calling more than once will result in other CQEs being lost.321 /// Not idempotent, calling more than once will result in other CQEs being lost.
321 /// Matches the implementation of cqe_seen() in liburing.322 /// Matches the implementation of cqe_seen() in liburing.
322 pub fn cqe_seen(self: *IO_Uring, cqe: *io_uring_cqe) void {323 pub fn cqe_seen(self: *IO_Uring, cqe: *io_uring_cqe) void {
324 _ = cqe;
323 self.cq_advance(1);325 self.cq_advance(1);
324 }326 }
325327
...@@ -728,6 +730,7 @@ pub const CompletionQueue = struct {...@@ -728,6 +730,7 @@ pub const CompletionQueue = struct {
728 }730 }
729731
730 pub fn deinit(self: *CompletionQueue) void {732 pub fn deinit(self: *CompletionQueue) void {
733 _ = self;
731 // A no-op since we now share the mmap with the submission queue.734 // A no-op since we now share the mmap with the submission queue.
732 // Here for symmetry with the submission queue, and for any future feature support.735 // Here for symmetry with the submission queue, and for any future feature support.
733 }736 }
lib/std/os/linux/mips.zig+1
...@@ -18,6 +18,7 @@ pub fn syscall0(number: SYS) usize {...@@ -18,6 +18,7 @@ pub fn syscall0(number: SYS) usize {
18}18}
1919
20pub fn syscall_pipe(fd: *[2]i32) usize {20pub fn syscall_pipe(fd: *[2]i32) usize {
21 _ = fd;
21 return asm volatile (22 return asm volatile (
22 \\ .set noat23 \\ .set noat
23 \\ .set noreorder24 \\ .set noreorder
lib/std/os/test.zig+4
...@@ -353,6 +353,7 @@ test "spawn threads" {...@@ -353,6 +353,7 @@ test "spawn threads" {
353}353}
354354
355fn start1(ctx: void) u8 {355fn start1(ctx: void) u8 {
356 _ = ctx;
356 return 0;357 return 0;
357}358}
358359
...@@ -379,6 +380,7 @@ test "thread local storage" {...@@ -379,6 +380,7 @@ test "thread local storage" {
379380
380threadlocal var x: i32 = 1234;381threadlocal var x: i32 = 1234;
381fn testTls(context: void) !void {382fn testTls(context: void) !void {
383 _ = context;
382 if (x != 1234) return error.TlsBadStartValue;384 if (x != 1234) return error.TlsBadStartValue;
383 x += 1;385 x += 1;
384 if (x != 1235) return error.TlsBadEndValue;386 if (x != 1235) return error.TlsBadEndValue;
...@@ -425,6 +427,7 @@ const IterFnError = error{...@@ -425,6 +427,7 @@ const IterFnError = error{
425};427};
426428
427fn iter_fn(info: *dl_phdr_info, size: usize, counter: *usize) IterFnError!void {429fn iter_fn(info: *dl_phdr_info, size: usize, counter: *usize) IterFnError!void {
430 _ = size;
428 // Count how many libraries are loaded431 // Count how many libraries are loaded
429 counter.* += @as(usize, 1);432 counter.* += @as(usize, 1);
430433
...@@ -731,6 +734,7 @@ test "sigaction" {...@@ -731,6 +734,7 @@ test "sigaction" {
731734
732 const S = struct {735 const S = struct {
733 fn handler(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_void) callconv(.C) void {736 fn handler(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_void) callconv(.C) void {
737 _ = ctx_ptr;
734 // Check that we received the correct signal.738 // Check that we received the correct signal.
735 switch (native_os) {739 switch (native_os) {
736 .netbsd => {740 .netbsd => {
lib/std/os/uefi.zig+1
...@@ -37,6 +37,7 @@ pub const Guid = extern struct {...@@ -37,6 +37,7 @@ pub const Guid = extern struct {
37 options: std.fmt.FormatOptions,37 options: std.fmt.FormatOptions,
38 writer: anytype,38 writer: anytype,
39 ) !void {39 ) !void {
40 _ = options;
40 if (f.len == 0) {41 if (f.len == 0) {
41 return std.fmt.format(writer, "{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x:0>12}", .{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 self.time_low,43 self.time_low,
lib/std/os/uefi/protocols/managed_network_protocol.zig+1
...@@ -35,6 +35,7 @@ pub const ManagedNetworkProtocol = extern struct {...@@ -35,6 +35,7 @@ pub const ManagedNetworkProtocol = extern struct {
35 /// Translates an IP multicast address to a hardware (MAC) multicast address.35 /// Translates an IP multicast address to a hardware (MAC) multicast address.
36 /// This function may be unsupported in some MNP implementations.36 /// This function may be unsupported in some MNP implementations.
37 pub fn mcastIpToMac(self: *const ManagedNetworkProtocol, ipv6flag: bool, ipaddress: *const c_void, mac_address: *MacAddress) Status {37 pub fn mcastIpToMac(self: *const ManagedNetworkProtocol, ipv6flag: bool, ipaddress: *const c_void, mac_address: *MacAddress) Status {
38 _ = mac_address;
38 return self._mcast_ip_to_mac(self, ipv6flag, ipaddress);39 return self._mcast_ip_to_mac(self, ipv6flag, ipaddress);
39 }40 }
4041
lib/std/packed_int_array.zig+1
...@@ -194,6 +194,7 @@ pub fn PackedIntArrayEndian(comptime Int: type, comptime endian: Endian, comptim...@@ -194,6 +194,7 @@ pub fn PackedIntArrayEndian(comptime Int: type, comptime endian: Endian, comptim
194194
195 ///Returns the number of elements in the packed array195 ///Returns the number of elements in the packed array
196 pub fn len(self: Self) usize {196 pub fn len(self: Self) usize {
197 _ = self;
197 return int_count;198 return int_count;
198 }199 }
199200
lib/std/pdb.zig+2-1
...@@ -675,6 +675,7 @@ pub const Pdb = struct {...@@ -675,6 +675,7 @@ pub const Pdb = struct {
675 }675 }
676676
677 pub fn getSymbolName(self: *Pdb, module: *Module, address: u64) ?[]const u8 {677 pub fn getSymbolName(self: *Pdb, module: *Module, address: u64) ?[]const u8 {
678 _ = self;
678 std.debug.assert(module.populated);679 std.debug.assert(module.populated);
679680
680 var symbol_i: usize = 0;681 var symbol_i: usize = 0;
...@@ -906,7 +907,7 @@ const Msf = struct {...@@ -906,7 +907,7 @@ const Msf = struct {
906 // These streams are not used, but still participate in the file907 // These streams are not used, but still participate in the file
907 // and must be taken into account when resolving stream indices.908 // and must be taken into account when resolving stream indices.
908 const Nil = 0xFFFFFFFF;909 const Nil = 0xFFFFFFFF;
909 for (stream_sizes) |*s, i| {910 for (stream_sizes) |*s| {
910 const size = try directory.reader().readIntLittle(u32);911 const size = try directory.reader().readIntLittle(u32);
911 s.* = if (size == Nil) 0 else blockCountFromSize(size, superblock.BlockSize);912 s.* = if (size == Nil) 0 else blockCountFromSize(size, superblock.BlockSize);
912 }913 }
lib/std/priority_dequeue.zig+1-1
...@@ -428,7 +428,7 @@ pub fn PriorityDequeue(comptime T: type) type {...@@ -428,7 +428,7 @@ pub fn PriorityDequeue(comptime T: type) type {
428 warn("{}, ", .{e});428 warn("{}, ", .{e});
429 }429 }
430 warn("array: ", .{});430 warn("array: ", .{});
431 for (self.items) |e, i| {431 for (self.items) |e| {
432 warn("{}, ", .{e});432 warn("{}, ", .{e});
433 }433 }
434 warn("len: {} ", .{self.len});434 warn("len: {} ", .{self.len});
lib/std/priority_queue.zig+1-1
...@@ -249,7 +249,7 @@ pub fn PriorityQueue(comptime T: type) type {...@@ -249,7 +249,7 @@ pub fn PriorityQueue(comptime T: type) type {
249 warn("{}, ", .{e});249 warn("{}, ", .{e});
250 }250 }
251 warn("array: ", .{});251 warn("array: ", .{});
252 for (self.items) |e, i| {252 for (self.items) |e| {
253 warn("{}, ", .{e});253 warn("{}, ", .{e});
254 }254 }
255 warn("len: {} ", .{self.len});255 warn("len: {} ", .{self.len});
lib/std/process.zig+2
...@@ -419,6 +419,7 @@ pub const ArgIteratorWindows = struct {...@@ -419,6 +419,7 @@ pub const ArgIteratorWindows = struct {
419 };419 };
420 }420 }
421 fn emitBackslashes(self: *ArgIteratorWindows, buf: *std.ArrayList(u16), emit_count: usize) !void {421 fn emitBackslashes(self: *ArgIteratorWindows, buf: *std.ArrayList(u16), emit_count: usize) !void {
422 _ = self;
422 var i: usize = 0;423 var i: usize = 0;
423 while (i < emit_count) : (i += 1) {424 while (i < emit_count) : (i += 1) {
424 try buf.append(std.mem.nativeToLittle(u16, '\\'));425 try buf.append(std.mem.nativeToLittle(u16, '\\'));
...@@ -748,6 +749,7 @@ pub fn getSelfExeSharedLibPaths(allocator: *Allocator) error{OutOfMemory}![][:0]...@@ -748,6 +749,7 @@ pub fn getSelfExeSharedLibPaths(allocator: *Allocator) error{OutOfMemory}![][:0]
748 }749 }
749 try os.dl_iterate_phdr(&paths, error{OutOfMemory}, struct {750 try os.dl_iterate_phdr(&paths, error{OutOfMemory}, struct {
750 fn callback(info: *os.dl_phdr_info, size: usize, list: *List) !void {751 fn callback(info: *os.dl_phdr_info, size: usize, list: *List) !void {
752 _ = size;
751 const name = info.dlpi_name orelse return;753 const name = info.dlpi_name orelse return;
752 if (name[0] == '/') {754 if (name[0] == '/') {
753 const item = try list.allocator.dupeZ(u8, mem.spanZ(name));755 const item = try list.allocator.dupeZ(u8, mem.spanZ(name));
lib/std/sort.zig+4
...@@ -37,9 +37,11 @@ pub fn binarySearch(...@@ -37,9 +37,11 @@ pub fn binarySearch(
37test "binarySearch" {37test "binarySearch" {
38 const S = struct {38 const S = struct {
39 fn order_u32(context: void, lhs: u32, rhs: u32) math.Order {39 fn order_u32(context: void, lhs: u32, rhs: u32) math.Order {
40 _ = context;
40 return math.order(lhs, rhs);41 return math.order(lhs, rhs);
41 }42 }
42 fn order_i32(context: void, lhs: i32, rhs: i32) math.Order {43 fn order_i32(context: void, lhs: i32, rhs: i32) math.Order {
44 _ = context;
43 return math.order(lhs, rhs);45 return math.order(lhs, rhs);
44 }46 }
45 };47 };
...@@ -1133,6 +1135,7 @@ fn swap(...@@ -1133,6 +1135,7 @@ fn swap(
1133pub fn asc(comptime T: type) fn (void, T, T) bool {1135pub fn asc(comptime T: type) fn (void, T, T) bool {
1134 const impl = struct {1136 const impl = struct {
1135 fn inner(context: void, a: T, b: T) bool {1137 fn inner(context: void, a: T, b: T) bool {
1138 _ = context;
1136 return a < b;1139 return a < b;
1137 }1140 }
1138 };1141 };
...@@ -1144,6 +1147,7 @@ pub fn asc(comptime T: type) fn (void, T, T) bool {...@@ -1144,6 +1147,7 @@ pub fn asc(comptime T: type) fn (void, T, T) bool {
1144pub fn desc(comptime T: type) fn (void, T, T) bool {1147pub fn desc(comptime T: type) fn (void, T, T) bool {
1145 const impl = struct {1148 const impl = struct {
1146 fn inner(context: void, a: T, b: T) bool {1149 fn inner(context: void, a: T, b: T) bool {
1150 _ = context;
1147 return a > b;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,6 +160,7 @@ fn strncmp(_l: [*:0]const u8, _r: [*:0]const u8, _n: usize) callconv(.C) c_int {
160}160}
161161
162fn strerror(errnum: c_int) callconv(.C) [*:0]const u8 {162fn strerror(errnum: c_int) callconv(.C) [*:0]const u8 {
163 _ = errnum;
163 return "TODO strerror implementation";164 return "TODO strerror implementation";
164}165}
165166
...@@ -173,6 +174,7 @@ test "strncmp" {...@@ -173,6 +174,7 @@ test "strncmp" {
173// Avoid dragging in the runtime safety mechanisms into this .o file,174// Avoid dragging in the runtime safety mechanisms into this .o file,
174// unless we're trying to test this file.175// unless we're trying to test this file.
175pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {176pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
177 _ = error_return_trace;
176 if (builtin.is_test) {178 if (builtin.is_test) {
177 @setCold(true);179 @setCold(true);
178 std.debug.panic("{s}", .{msg});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,6 +602,7 @@ pub usingnamespace @import("compiler_rt/atomics.zig");
602// Avoid dragging in the runtime safety mechanisms into this .o file,602// Avoid dragging in the runtime safety mechanisms into this .o file,
603// unless we're trying to test this file.603// unless we're trying to test this file.
604pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {604pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
605 _ = error_return_trace;
605 @setCold(true);606 @setCold(true);
606 if (is_test) {607 if (is_test) {
607 std.debug.panic("{s}", .{msg});608 std.debug.panic("{s}", .{msg});
lib/std/special/compiler_rt/atomics.zig+11
...@@ -80,18 +80,21 @@ var spinlocks: SpinlockTable = SpinlockTable{};...@@ -80,18 +80,21 @@ var spinlocks: SpinlockTable = SpinlockTable{};
80// Those work on any object no matter the pointer alignment nor its size.80// Those work on any object no matter the pointer alignment nor its size.
8181
82fn __atomic_load(size: u32, src: [*]u8, dest: [*]u8, model: i32) callconv(.C) void {82fn __atomic_load(size: u32, src: [*]u8, dest: [*]u8, model: i32) callconv(.C) void {
83 _ = model;
83 var sl = spinlocks.get(@ptrToInt(src));84 var sl = spinlocks.get(@ptrToInt(src));
84 defer sl.release();85 defer sl.release();
85 @memcpy(dest, src, size);86 @memcpy(dest, src, size);
86}87}
8788
88fn __atomic_store(size: u32, dest: [*]u8, src: [*]u8, model: i32) callconv(.C) void {89fn __atomic_store(size: u32, dest: [*]u8, src: [*]u8, model: i32) callconv(.C) void {
90 _ = model;
89 var sl = spinlocks.get(@ptrToInt(dest));91 var sl = spinlocks.get(@ptrToInt(dest));
90 defer sl.release();92 defer sl.release();
91 @memcpy(dest, src, size);93 @memcpy(dest, src, size);
92}94}
9395
94fn __atomic_exchange(size: u32, ptr: [*]u8, val: [*]u8, old: [*]u8, model: i32) callconv(.C) void {96fn __atomic_exchange(size: u32, ptr: [*]u8, val: [*]u8, old: [*]u8, model: i32) callconv(.C) void {
97 _ = model;
95 var sl = spinlocks.get(@ptrToInt(ptr));98 var sl = spinlocks.get(@ptrToInt(ptr));
96 defer sl.release();99 defer sl.release();
97 @memcpy(old, ptr, size);100 @memcpy(old, ptr, size);
...@@ -106,6 +109,8 @@ fn __atomic_compare_exchange(...@@ -106,6 +109,8 @@ fn __atomic_compare_exchange(
106 success: i32,109 success: i32,
107 failure: i32,110 failure: i32,
108) callconv(.C) i32 {111) callconv(.C) i32 {
112 _ = success;
113 _ = failure;
109 var sl = spinlocks.get(@ptrToInt(ptr));114 var sl = spinlocks.get(@ptrToInt(ptr));
110 defer sl.release();115 defer sl.release();
111 for (ptr[0..size]) |b, i| {116 for (ptr[0..size]) |b, i| {
...@@ -135,6 +140,7 @@ comptime {...@@ -135,6 +140,7 @@ comptime {
135fn atomicLoadFn(comptime T: type) fn (*T, i32) callconv(.C) T {140fn atomicLoadFn(comptime T: type) fn (*T, i32) callconv(.C) T {
136 return struct {141 return struct {
137 fn atomic_load_N(src: *T, model: i32) callconv(.C) T {142 fn atomic_load_N(src: *T, model: i32) callconv(.C) T {
143 _ = model;
138 if (@sizeOf(T) > largest_atomic_size) {144 if (@sizeOf(T) > largest_atomic_size) {
139 var sl = spinlocks.get(@ptrToInt(src));145 var sl = spinlocks.get(@ptrToInt(src));
140 defer sl.release();146 defer sl.release();
...@@ -162,6 +168,7 @@ comptime {...@@ -162,6 +168,7 @@ comptime {
162fn atomicStoreFn(comptime T: type) fn (*T, T, i32) callconv(.C) void {168fn atomicStoreFn(comptime T: type) fn (*T, T, i32) callconv(.C) void {
163 return struct {169 return struct {
164 fn atomic_store_N(dst: *T, value: T, model: i32) callconv(.C) void {170 fn atomic_store_N(dst: *T, value: T, model: i32) callconv(.C) void {
171 _ = model;
165 if (@sizeOf(T) > largest_atomic_size) {172 if (@sizeOf(T) > largest_atomic_size) {
166 var sl = spinlocks.get(@ptrToInt(dst));173 var sl = spinlocks.get(@ptrToInt(dst));
167 defer sl.release();174 defer sl.release();
...@@ -189,6 +196,7 @@ comptime {...@@ -189,6 +196,7 @@ comptime {
189fn atomicExchangeFn(comptime T: type) fn (*T, T, i32) callconv(.C) T {196fn atomicExchangeFn(comptime T: type) fn (*T, T, i32) callconv(.C) T {
190 return struct {197 return struct {
191 fn atomic_exchange_N(ptr: *T, val: T, model: i32) callconv(.C) T {198 fn atomic_exchange_N(ptr: *T, val: T, model: i32) callconv(.C) T {
199 _ = model;
192 if (@sizeOf(T) > largest_atomic_size) {200 if (@sizeOf(T) > largest_atomic_size) {
193 var sl = spinlocks.get(@ptrToInt(ptr));201 var sl = spinlocks.get(@ptrToInt(ptr));
194 defer sl.release();202 defer sl.release();
...@@ -218,6 +226,8 @@ comptime {...@@ -218,6 +226,8 @@ comptime {
218fn atomicCompareExchangeFn(comptime T: type) fn (*T, *T, T, i32, i32) callconv(.C) i32 {226fn atomicCompareExchangeFn(comptime T: type) fn (*T, *T, T, i32, i32) callconv(.C) i32 {
219 return struct {227 return struct {
220 fn atomic_compare_exchange_N(ptr: *T, expected: *T, desired: T, success: i32, failure: i32) callconv(.C) i32 {228 fn atomic_compare_exchange_N(ptr: *T, expected: *T, desired: T, success: i32, failure: i32) callconv(.C) i32 {
229 _ = success;
230 _ = failure;
221 if (@sizeOf(T) > largest_atomic_size) {231 if (@sizeOf(T) > largest_atomic_size) {
222 var sl = spinlocks.get(@ptrToInt(ptr));232 var sl = spinlocks.get(@ptrToInt(ptr));
223 defer sl.release();233 defer sl.release();
...@@ -255,6 +265,7 @@ comptime {...@@ -255,6 +265,7 @@ comptime {
255fn fetchFn(comptime T: type, comptime op: builtin.AtomicRmwOp) fn (*T, T, i32) callconv(.C) T {265fn fetchFn(comptime T: type, comptime op: builtin.AtomicRmwOp) fn (*T, T, i32) callconv(.C) T {
256 return struct {266 return struct {
257 pub fn fetch_op_N(ptr: *T, val: T, model: i32) callconv(.C) T {267 pub fn fetch_op_N(ptr: *T, val: T, model: i32) callconv(.C) T {
268 _ = model;
258 if (@sizeOf(T) > largest_atomic_size) {269 if (@sizeOf(T) > largest_atomic_size) {
259 var sl = spinlocks.get(@ptrToInt(ptr));270 var sl = spinlocks.get(@ptrToInt(ptr));
260 defer sl.release();271 defer sl.release();
lib/std/special/compiler_rt/comparedf2_test.zig+1
...@@ -101,6 +101,7 @@ const test_vectors = init: {...@@ -101,6 +101,7 @@ const test_vectors = init: {
101101
102test "compare f64" {102test "compare f64" {
103 for (test_vectors) |vector, i| {103 for (test_vectors) |vector, i| {
104 _ = i;
104 try std.testing.expect(test__cmpdf2(vector));105 try std.testing.expect(test__cmpdf2(vector));
105 }106 }
106}107}
lib/std/special/compiler_rt/comparesf2_test.zig+1
...@@ -101,6 +101,7 @@ const test_vectors = init: {...@@ -101,6 +101,7 @@ const test_vectors = init: {
101101
102test "compare f32" {102test "compare f32" {
103 for (test_vectors) |vector, i| {103 for (test_vectors) |vector, i| {
104 _ = i;
104 try std.testing.expect(test__cmpsf2(vector));105 try std.testing.expect(test__cmpsf2(vector));
105 }106 }
106}107}
lib/std/special/ssp.zig+2
...@@ -27,6 +27,8 @@ extern fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8...@@ -27,6 +27,8 @@ extern fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8
2727
28// Avoid dragging in the runtime safety mechanisms into this .o file.28// Avoid dragging in the runtime safety mechanisms into this .o file.
29pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {29pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
30 _ = msg;
31 _ = error_return_trace;
30 @setCold(true);32 @setCold(true);
31 if (@hasDecl(std.os, "abort"))33 if (@hasDecl(std.os, "abort"))
32 std.os.abort();34 std.os.abort();
lib/std/target.zig+1-1
...@@ -157,7 +157,7 @@ pub const Target = struct {...@@ -157,7 +157,7 @@ pub const Target = struct {
157 pub fn format(157 pub fn format(
158 self: WindowsVersion,158 self: WindowsVersion,
159 comptime fmt: []const u8,159 comptime fmt: []const u8,
160 options: std.fmt.FormatOptions,160 _: std.fmt.FormatOptions,
161 out_stream: anytype,161 out_stream: anytype,
162 ) !void {162 ) !void {
163 if (fmt.len > 0 and fmt[0] == 's') {163 if (fmt.len > 0 and fmt[0] == 's') {
lib/std/unicode.zig+1-1
...@@ -210,7 +210,7 @@ pub fn utf8ValidateSlice(s: []const u8) bool {...@@ -210,7 +210,7 @@ pub fn utf8ValidateSlice(s: []const u8) bool {
210 return false;210 return false;
211 }211 }
212 i += cp_len;212 i += cp_len;
213 } else |err| {213 } else |_| {
214 return false;214 return false;
215 }215 }
216 }216 }
lib/std/x/net/ip.zig+2
...@@ -53,6 +53,8 @@ pub const Address = union(enum) {...@@ -53,6 +53,8 @@ pub const Address = union(enum) {
53 opts: fmt.FormatOptions,53 opts: fmt.FormatOptions,
54 writer: anytype,54 writer: anytype,
55 ) !void {55 ) !void {
56 _ = opts;
57 _ = layout;
56 switch (self) {58 switch (self) {
57 .ipv4 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }),59 .ipv4 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }),
58 .ipv6 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }),60 .ipv6 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }),
lib/std/x/os/net.zig+2
...@@ -143,6 +143,7 @@ pub const IPv4 = extern struct {...@@ -143,6 +143,7 @@ pub const IPv4 = extern struct {
143 opts: fmt.FormatOptions,143 opts: fmt.FormatOptions,
144 writer: anytype,144 writer: anytype,
145 ) !void {145 ) !void {
146 _ = opts;
146 if (comptime layout.len != 0 and layout[0] != 's') {147 if (comptime layout.len != 0 and layout[0] != 's') {
147 @compileError("Unsupported format specifier for IPv4 type '" ++ layout ++ "'.");148 @compileError("Unsupported format specifier for IPv4 type '" ++ layout ++ "'.");
148 }149 }
...@@ -352,6 +353,7 @@ pub const IPv6 = extern struct {...@@ -352,6 +353,7 @@ pub const IPv6 = extern struct {
352 opts: fmt.FormatOptions,353 opts: fmt.FormatOptions,
353 writer: anytype,354 writer: anytype,
354 ) !void {355 ) !void {
356 _ = opts;
355 const specifier = comptime &[_]u8{if (layout.len == 0) 'x' else switch (layout[0]) {357 const specifier = comptime &[_]u8{if (layout.len == 0) 'x' else switch (layout[0]) {
356 'x', 'X' => |specifier| specifier,358 'x', 'X' => |specifier| specifier,
357 's' => 'x',359 's' => 'x',
lib/std/x/os/socket.zig+4-2
...@@ -117,7 +117,7 @@ pub const Socket = struct {...@@ -117,7 +117,7 @@ pub const Socket = struct {
117 };117 };
118 }118 }
119119
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 pub fn getNativeSize(self: Socket.Address) u32 {121 pub fn getNativeSize(self: Socket.Address) u32 {
122 return switch (self) {122 return switch (self) {
123 .ipv4 => @sizeOf(os.sockaddr_in),123 .ipv4 => @sizeOf(os.sockaddr_in),
...@@ -132,6 +132,8 @@ pub const Socket = struct {...@@ -132,6 +132,8 @@ pub const Socket = struct {
132 opts: fmt.FormatOptions,132 opts: fmt.FormatOptions,
133 writer: anytype,133 writer: anytype,
134 ) !void {134 ) !void {
135 _ = opts;
136 _ = layout;
135 switch (self) {137 switch (self) {
136 .ipv4 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }),138 .ipv4 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }),
137 .ipv6 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }),139 .ipv6 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }),
...@@ -280,7 +282,7 @@ pub const Socket = struct {...@@ -280,7 +282,7 @@ pub const Socket = struct {
280 ///282 ///
281 /// Microsoft's documentation and glibc denote the fields to be unsigned283 /// Microsoft's documentation and glibc denote the fields to be unsigned
282 /// short's on Windows, whereas glibc and musl denote the fields to be284 /// 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 pub const Linger = extern struct {286 pub const Linger = extern struct {
285 pub const Field = switch (native_os.tag) {287 pub const Field = switch (native_os.tag) {
286 .windows => c_ushort,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,6 +292,7 @@ pub fn Mixin(comptime Socket: type) type {
292 /// with a set of flags specified. It returns the number of bytes that were292 /// with a set of flags specified. It returns the number of bytes that were
293 /// read into the buffer provided.293 /// read into the buffer provided.
294 pub fn readMessage(self: Socket, msg: *Socket.Message, flags: u32) !usize {294 pub fn readMessage(self: Socket, msg: *Socket.Message, flags: u32) !usize {
295 _ = flags;
295 const call = try windows.loadWinsockExtensionFunction(ws2_32.LPFN_WSARECVMSG, self.fd, ws2_32.WSAID_WSARECVMSG);296 const call = try windows.loadWinsockExtensionFunction(ws2_32.LPFN_WSARECVMSG, self.fd, ws2_32.WSAID_WSARECVMSG);
296297
297 var num_bytes: u32 = undefined;298 var num_bytes: u32 = undefined;
...@@ -367,16 +368,19 @@ pub fn Mixin(comptime Socket: type) type {...@@ -367,16 +368,19 @@ pub fn Mixin(comptime Socket: type) type {
367368
368 /// Query and return the latest cached error on the socket.369 /// Query and return the latest cached error on the socket.
369 pub fn getError(self: Socket) !void {370 pub fn getError(self: Socket) !void {
371 _ = self;
370 return {};372 return {};
371 }373 }
372374
373 /// Query the read buffer size of the socket.375 /// Query the read buffer size of the socket.
374 pub fn getReadBufferSize(self: Socket) !u32 {376 pub fn getReadBufferSize(self: Socket) !u32 {
377 _ = self;
375 return 0;378 return 0;
376 }379 }
377380
378 /// Query the write buffer size of the socket.381 /// Query the write buffer size of the socket.
379 pub fn getWriteBufferSize(self: Socket) !u32 {382 pub fn getWriteBufferSize(self: Socket) !u32 {
383 _ = self;
380 return 0;384 return 0;
381 }385 }
382386
...@@ -406,7 +410,7 @@ pub fn Mixin(comptime Socket: type) type {...@@ -406,7 +410,7 @@ pub fn Mixin(comptime Socket: type) type {
406410
407 /// On connection-oriented sockets, have keep-alive messages be sent periodically. The timing in which keep-alive411 /// On connection-oriented sockets, have keep-alive messages be sent periodically. The timing in which keep-alive
408 /// messages are sent are dependant on operating system settings. It returns `error.UnsupportedSocketOption` if412 /// 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 pub fn setKeepAlive(self: Socket, enabled: bool) !void {414 pub fn setKeepAlive(self: Socket, enabled: bool) !void {
411 return self.setOption(ws2_32.SOL_SOCKET, ws2_32.SO_KEEPALIVE, mem.asBytes(&@as(u32, @boolToInt(enabled))));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,7 +442,7 @@ pub fn Mixin(comptime Socket: type) type {
438442
439 /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is443 /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is
440 /// set on a non-blocking socket.444 /// set on a non-blocking socket.
441 /// 445 ///
442 /// Set a timeout on the socket that is to occur if no messages are successfully written446 /// Set a timeout on the socket that is to occur if no messages are successfully written
443 /// to its bound destination after a specified number of milliseconds. A subsequent write447 /// to its bound destination after a specified number of milliseconds. A subsequent write
444 /// to the socket will thereafter return `error.WouldBlock` should the timeout be exceeded.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,7 +452,7 @@ pub fn Mixin(comptime Socket: type) type {
448452
449 /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is453 /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is
450 /// set on a non-blocking socket.454 /// set on a non-blocking socket.
451 /// 455 ///
452 /// Set a timeout on the socket that is to occur if no messages are successfully read456 /// Set a timeout on the socket that is to occur if no messages are successfully read
453 /// from its bound destination after a specified number of milliseconds. A subsequent457 /// from its bound destination after a specified number of milliseconds. A subsequent
454 /// read from the socket will thereafter return `error.WouldBlock` should the timeout be458 /// read from the socket will thereafter return `error.WouldBlock` should the timeout be
lib/std/zig/ast.zig+1
...@@ -1866,6 +1866,7 @@ pub const Tree = struct {...@@ -1866,6 +1866,7 @@ pub const Tree = struct {
1866 }1866 }
18671867
1868 fn fullStructInit(tree: Tree, info: full.StructInit.Ast) full.StructInit {1868 fn fullStructInit(tree: Tree, info: full.StructInit.Ast) full.StructInit {
1869 _ = tree;
1869 var result: full.StructInit = .{1870 var result: full.StructInit = .{
1870 .ast = info,1871 .ast = info,
1871 };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,6 +136,7 @@ pub inline fn __builtin_strcmp(s1: [*c]const u8, s2: [*c]const u8) c_int {
136}136}
137137
138pub inline fn __builtin_object_size(ptr: ?*const c_void, ty: c_int) usize {138pub inline fn __builtin_object_size(ptr: ?*const c_void, ty: c_int) usize {
139 _ = ptr;
139 // clang semantics match gcc's: https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html140 // clang semantics match gcc's: https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
140 // If it is not possible to determine which objects ptr points to at compile time,141 // If it is not possible to determine which objects ptr points to at compile time,
141 // __builtin_object_size should return (size_t) -1 for type 0 or 1 and (size_t) 0142 // __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,6 +187,7 @@ pub inline fn __builtin_memcpy(
186/// The return value of __builtin_expect is `expr`. `c` is the expected value187/// The return value of __builtin_expect is `expr`. `c` is the expected value
187/// of `expr` and is used as a hint to the compiler in C. Here it is unused.188/// of `expr` and is used as a hint to the compiler in C. Here it is unused.
188pub inline fn __builtin_expect(expr: c_long, c: c_long) c_long {189pub inline fn __builtin_expect(expr: c_long, c: c_long) c_long {
190 _ = c;
189 return expr;191 return expr;
190}192}
191193
lib/std/zig/fmt.zig+2
...@@ -8,6 +8,7 @@ pub fn formatId(...@@ -8,6 +8,7 @@ pub fn formatId(
8 options: std.fmt.FormatOptions,8 options: std.fmt.FormatOptions,
9 writer: anytype,9 writer: anytype,
10) !void {10) !void {
11 _ = fmt;
11 if (isValidId(bytes)) {12 if (isValidId(bytes)) {
12 return writer.writeAll(bytes);13 return writer.writeAll(bytes);
13 }14 }
...@@ -41,6 +42,7 @@ pub fn formatEscapes(...@@ -41,6 +42,7 @@ pub fn formatEscapes(
41 options: std.fmt.FormatOptions,42 options: std.fmt.FormatOptions,
42 writer: anytype,43 writer: anytype,
43) !void {44) !void {
45 _ = options;
44 for (bytes) |byte| switch (byte) {46 for (bytes) |byte| switch (byte) {
45 '\n' => try writer.writeAll("\\n"),47 '\n' => try writer.writeAll("\\n"),
46 '\r' => try writer.writeAll("\\r"),48 '\r' => try writer.writeAll("\\r"),
lib/std/zig/parse.zig+1-1
...@@ -2104,7 +2104,7 @@ const Parser = struct {...@@ -2104,7 +2104,7 @@ const Parser = struct {
2104 /// FnCallArguments <- LPAREN ExprList RPAREN2104 /// FnCallArguments <- LPAREN ExprList RPAREN
2105 /// ExprList <- (Expr COMMA)* Expr?2105 /// ExprList <- (Expr COMMA)* Expr?
2106 fn parseSuffixExpr(p: *Parser) !Node.Index {2106 fn parseSuffixExpr(p: *Parser) !Node.Index {
2107 if (p.eatToken(.keyword_async)) |async_token| {2107 if (p.eatToken(.keyword_async)) |_| {
2108 var res = try p.expectPrimaryTypeExpr();2108 var res = try p.expectPrimaryTypeExpr();
2109 while (true) {2109 while (true) {
2110 const node = try p.parseSuffixOp(res);2110 const node = try p.parseSuffixOp(res);
lib/std/zig/system.zig+2-1
...@@ -200,6 +200,7 @@ pub const NativePaths = struct {...@@ -200,6 +200,7 @@ pub const NativePaths = struct {
200 }200 }
201201
202 fn appendArray(self: *NativePaths, array: *ArrayList([:0]u8), s: []const u8) !void {202 fn appendArray(self: *NativePaths, array: *ArrayList([:0]u8), s: []const u8) !void {
203 _ = self;
203 const item = try array.allocator.dupeZ(u8, s);204 const item = try array.allocator.dupeZ(u8, s);
204 errdefer array.allocator.free(item);205 errdefer array.allocator.free(item);
205 try array.append(item);206 try array.append(item);
...@@ -332,7 +333,7 @@ pub const NativeTargetInfo = struct {...@@ -332,7 +333,7 @@ pub const NativeTargetInfo = struct {
332 if (std.builtin.Version.parse(buf[0 .. len - 1])) |ver| {333 if (std.builtin.Version.parse(buf[0 .. len - 1])) |ver| {
333 os.version_range.semver.min = ver;334 os.version_range.semver.min = ver;
334 os.version_range.semver.max = ver;335 os.version_range.semver.max = ver;
335 } else |err| {336 } else |_| {
336 return error.OSVersionDetectionFail;337 return error.OSVersionDetectionFail;
337 }338 }
338 },339 },
lib/std/zig/system/macos.zig+2-2
...@@ -68,10 +68,10 @@ pub fn detect(target_os: *Target.Os) !void {...@@ -68,10 +68,10 @@ pub fn detect(target_os: *Target.Os) !void {
68 return;68 return;
69 }69 }
70 continue;70 continue;
71 } else |err| {71 } else |_| {
72 return error.OSVersionDetectionFail;72 return error.OSVersionDetectionFail;
73 }73 }
74 } else |err| {74 } else |_| {
75 return error.OSVersionDetectionFail;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,6 +28,7 @@ inline fn hasMask(input: u32, mask: u32) bool {
28}28}
2929
30pub fn detectNativeCpuAndFeatures(arch: Target.Cpu.Arch, os: Target.Os, cross_target: CrossTarget) Target.Cpu {30pub fn detectNativeCpuAndFeatures(arch: Target.Cpu.Arch, os: Target.Os, cross_target: CrossTarget) Target.Cpu {
31 _ = cross_target;
31 var cpu = Target.Cpu{32 var cpu = Target.Cpu{
32 .arch = arch,33 .arch = arch,
33 .model = Target.Cpu.Model.generic(arch),34 .model = Target.Cpu.Model.generic(arch),
src/AstGen.zig+22-4
...@@ -925,6 +925,7 @@ fn suspendExpr(...@@ -925,6 +925,7 @@ fn suspendExpr(
925 rl: ResultLoc,925 rl: ResultLoc,
926 node: ast.Node.Index,926 node: ast.Node.Index,
927) InnerError!Zir.Inst.Ref {927) InnerError!Zir.Inst.Ref {
928 _ = rl;
928 const astgen = gz.astgen;929 const astgen = gz.astgen;
929 const gpa = astgen.gpa;930 const gpa = astgen.gpa;
930 const tree = astgen.tree;931 const tree = astgen.tree;
...@@ -1208,6 +1209,7 @@ fn arrayInitExprRlNone(...@@ -1208,6 +1209,7 @@ fn arrayInitExprRlNone(
1208 elements: []const ast.Node.Index,1209 elements: []const ast.Node.Index,
1209 tag: Zir.Inst.Tag,1210 tag: Zir.Inst.Tag,
1210) InnerError!Zir.Inst.Ref {1211) InnerError!Zir.Inst.Ref {
1212 _ = rl;
1211 const astgen = gz.astgen;1213 const astgen = gz.astgen;
1212 const gpa = astgen.gpa;1214 const gpa = astgen.gpa;
1213 const elem_list = try gpa.alloc(Zir.Inst.Ref, elements.len);1215 const elem_list = try gpa.alloc(Zir.Inst.Ref, elements.len);
...@@ -1233,6 +1235,9 @@ fn arrayInitExprRlTy(...@@ -1233,6 +1235,9 @@ fn arrayInitExprRlTy(
1233 elem_ty_inst: Zir.Inst.Ref,1235 elem_ty_inst: Zir.Inst.Ref,
1234 tag: Zir.Inst.Tag,1236 tag: Zir.Inst.Tag,
1235) InnerError!Zir.Inst.Ref {1237) InnerError!Zir.Inst.Ref {
1238 _ = rl;
1239 _ = array_ty_inst;
1240 _ = elem_ty_inst;
1236 const astgen = gz.astgen;1241 const astgen = gz.astgen;
1237 const gpa = astgen.gpa;1242 const gpa = astgen.gpa;
12381243
...@@ -1259,6 +1264,7 @@ fn arrayInitExprRlPtr(...@@ -1259,6 +1264,7 @@ fn arrayInitExprRlPtr(
1259 elements: []const ast.Node.Index,1264 elements: []const ast.Node.Index,
1260 result_ptr: Zir.Inst.Ref,1265 result_ptr: Zir.Inst.Ref,
1261) InnerError!Zir.Inst.Ref {1266) InnerError!Zir.Inst.Ref {
1267 _ = rl;
1262 const astgen = gz.astgen;1268 const astgen = gz.astgen;
1263 const gpa = astgen.gpa;1269 const gpa = astgen.gpa;
12641270
...@@ -1368,6 +1374,7 @@ fn structInitExprRlNone(...@@ -1368,6 +1374,7 @@ fn structInitExprRlNone(
1368 struct_init: ast.full.StructInit,1374 struct_init: ast.full.StructInit,
1369 tag: Zir.Inst.Tag,1375 tag: Zir.Inst.Tag,
1370) InnerError!Zir.Inst.Ref {1376) InnerError!Zir.Inst.Ref {
1377 _ = rl;
1371 const astgen = gz.astgen;1378 const astgen = gz.astgen;
1372 const gpa = astgen.gpa;1379 const gpa = astgen.gpa;
1373 const tree = astgen.tree;1380 const tree = astgen.tree;
...@@ -1403,6 +1410,7 @@ fn structInitExprRlPtr(...@@ -1403,6 +1410,7 @@ fn structInitExprRlPtr(
1403 struct_init: ast.full.StructInit,1410 struct_init: ast.full.StructInit,
1404 result_ptr: Zir.Inst.Ref,1411 result_ptr: Zir.Inst.Ref,
1405) InnerError!Zir.Inst.Ref {1412) InnerError!Zir.Inst.Ref {
1413 _ = rl;
1406 const astgen = gz.astgen;1414 const astgen = gz.astgen;
1407 const gpa = astgen.gpa;1415 const gpa = astgen.gpa;
1408 const tree = astgen.tree;1416 const tree = astgen.tree;
...@@ -1439,6 +1447,7 @@ fn structInitExprRlTy(...@@ -1439,6 +1447,7 @@ fn structInitExprRlTy(
1439 ty_inst: Zir.Inst.Ref,1447 ty_inst: Zir.Inst.Ref,
1440 tag: Zir.Inst.Tag,1448 tag: Zir.Inst.Tag,
1441) InnerError!Zir.Inst.Ref {1449) InnerError!Zir.Inst.Ref {
1450 _ = rl;
1442 const astgen = gz.astgen;1451 const astgen = gz.astgen;
1443 const gpa = astgen.gpa;1452 const gpa = astgen.gpa;
1444 const tree = astgen.tree;1453 const tree = astgen.tree;
...@@ -1781,6 +1790,7 @@ fn blockExprStmts(...@@ -1781,6 +1790,7 @@ fn blockExprStmts(
1781 node: ast.Node.Index,1790 node: ast.Node.Index,
1782 statements: []const ast.Node.Index,1791 statements: []const ast.Node.Index,
1783) !void {1792) !void {
1793 _ = node;
1784 const astgen = gz.astgen;1794 const astgen = gz.astgen;
1785 const tree = astgen.tree;1795 const tree = astgen.tree;
1786 const node_tags = tree.nodes.items(.tag);1796 const node_tags = tree.nodes.items(.tag);
...@@ -2117,6 +2127,7 @@ fn genDefers(...@@ -2117,6 +2127,7 @@ fn genDefers(
2117 inner_scope: *Scope,2127 inner_scope: *Scope,
2118 err_code: Zir.Inst.Ref,2128 err_code: Zir.Inst.Ref,
2119) InnerError!void {2129) InnerError!void {
2130 _ = err_code;
2120 const astgen = gz.astgen;2131 const astgen = gz.astgen;
2121 const tree = astgen.tree;2132 const tree = astgen.tree;
2122 const node_datas = tree.nodes.items(.data);2133 const node_datas = tree.nodes.items(.data);
...@@ -2201,6 +2212,7 @@ fn deferStmt(...@@ -2201,6 +2212,7 @@ fn deferStmt(
2201 block_arena: *Allocator,2212 block_arena: *Allocator,
2202 scope_tag: Scope.Tag,2213 scope_tag: Scope.Tag,
2203) InnerError!*Scope {2214) InnerError!*Scope {
2215 _ = gz;
2204 const defer_scope = try block_arena.create(Scope.Defer);2216 const defer_scope = try block_arena.create(Scope.Defer);
2205 defer_scope.* = .{2217 defer_scope.* = .{
2206 .base = .{ .tag = scope_tag },2218 .base = .{ .tag = scope_tag },
...@@ -4703,6 +4715,8 @@ fn finishThenElseBlock(...@@ -4703,6 +4715,8 @@ fn finishThenElseBlock(
4703 then_break_block: Zir.Inst.Index,4715 then_break_block: Zir.Inst.Index,
4704 break_tag: Zir.Inst.Tag,4716 break_tag: Zir.Inst.Tag,
4705) InnerError!Zir.Inst.Ref {4717) InnerError!Zir.Inst.Ref {
4718 _ = then_src;
4719 _ = else_src;
4706 // We now have enough information to decide whether the result instruction should4720 // We now have enough information to decide whether the result instruction should
4707 // be communicated via result location pointer or break instructions.4721 // be communicated via result location pointer or break instructions.
4708 const strat = rl.strategy(block_scope);4722 const strat = rl.strategy(block_scope);
...@@ -4886,7 +4900,7 @@ fn ifExpr(...@@ -4886,7 +4900,7 @@ fn ifExpr(
4886 inst: Zir.Inst.Ref,4900 inst: Zir.Inst.Ref,
4887 bool_bit: Zir.Inst.Ref,4901 bool_bit: Zir.Inst.Ref,
4888 } = c: {4902 } = c: {
4889 if (if_full.error_token) |error_token| {4903 if (if_full.error_token) |_| {
4890 const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none;4904 const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none;
4891 const err_union = try expr(&block_scope, &block_scope.base, cond_rl, if_full.ast.cond_expr);4905 const err_union = try expr(&block_scope, &block_scope.base, cond_rl, if_full.ast.cond_expr);
4892 const tag: Zir.Inst.Tag = if (payload_is_ref) .is_err_ptr else .is_err;4906 const tag: Zir.Inst.Tag = if (payload_is_ref) .is_err_ptr else .is_err;
...@@ -4894,7 +4908,7 @@ fn ifExpr(...@@ -4894,7 +4908,7 @@ fn ifExpr(
4894 .inst = err_union,4908 .inst = err_union,
4895 .bool_bit = try block_scope.addUnNode(tag, err_union, node),4909 .bool_bit = try block_scope.addUnNode(tag, err_union, node),
4896 };4910 };
4897 } else if (if_full.payload_token) |payload_token| {4911 } else if (if_full.payload_token) |_| {
4898 const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none;4912 const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none;
4899 const optional = try expr(&block_scope, &block_scope.base, cond_rl, if_full.ast.cond_expr);4913 const optional = try expr(&block_scope, &block_scope.base, cond_rl, if_full.ast.cond_expr);
4900 const tag: Zir.Inst.Tag = if (payload_is_ref) .is_non_null_ptr else .is_non_null;4914 const tag: Zir.Inst.Tag = if (payload_is_ref) .is_non_null_ptr else .is_non_null;
...@@ -5146,7 +5160,7 @@ fn whileExpr(...@@ -5146,7 +5160,7 @@ fn whileExpr(
5146 inst: Zir.Inst.Ref,5160 inst: Zir.Inst.Ref,
5147 bool_bit: Zir.Inst.Ref,5161 bool_bit: Zir.Inst.Ref,
5148 } = c: {5162 } = c: {
5149 if (while_full.error_token) |error_token| {5163 if (while_full.error_token) |_| {
5150 const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none;5164 const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none;
5151 const err_union = try expr(&continue_scope, &continue_scope.base, cond_rl, while_full.ast.cond_expr);5165 const err_union = try expr(&continue_scope, &continue_scope.base, cond_rl, while_full.ast.cond_expr);
5152 const tag: Zir.Inst.Tag = if (payload_is_ref) .is_err_ptr else .is_err;5166 const tag: Zir.Inst.Tag = if (payload_is_ref) .is_err_ptr else .is_err;
...@@ -5154,7 +5168,7 @@ fn whileExpr(...@@ -5154,7 +5168,7 @@ fn whileExpr(
5154 .inst = err_union,5168 .inst = err_union,
5155 .bool_bit = try continue_scope.addUnNode(tag, err_union, node),5169 .bool_bit = try continue_scope.addUnNode(tag, err_union, node),
5156 };5170 };
5157 } else if (while_full.payload_token) |payload_token| {5171 } else if (while_full.payload_token) |_| {
5158 const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none;5172 const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none;
5159 const optional = try expr(&continue_scope, &continue_scope.base, cond_rl, while_full.ast.cond_expr);5173 const optional = try expr(&continue_scope, &continue_scope.base, cond_rl, while_full.ast.cond_expr);
5160 const tag: Zir.Inst.Tag = if (payload_is_ref) .is_non_null_ptr else .is_non_null;5174 const tag: Zir.Inst.Tag = if (payload_is_ref) .is_non_null_ptr else .is_non_null;
...@@ -6665,6 +6679,7 @@ fn unionInitRlPtr(...@@ -6665,6 +6679,7 @@ fn unionInitRlPtr(
6665 union_type: Zir.Inst.Ref,6679 union_type: Zir.Inst.Ref,
6666 field_name: Zir.Inst.Ref,6680 field_name: Zir.Inst.Ref,
6667) InnerError!Zir.Inst.Ref {6681) InnerError!Zir.Inst.Ref {
6682 _ = rl;
6668 const union_init_ptr = try parent_gz.addPlNode(.union_init_ptr, node, Zir.Inst.UnionInitPtr{6683 const union_init_ptr = try parent_gz.addPlNode(.union_init_ptr, node, Zir.Inst.UnionInitPtr{
6669 .result_ptr = result_ptr,6684 .result_ptr = result_ptr,
6670 .union_type = union_type,6685 .union_type = union_type,
...@@ -6753,6 +6768,8 @@ fn bitCastRlPtr(...@@ -6753,6 +6768,8 @@ fn bitCastRlPtr(
6753 result_ptr: Zir.Inst.Ref,6768 result_ptr: Zir.Inst.Ref,
6754 rhs: ast.Node.Index,6769 rhs: ast.Node.Index,
6755) InnerError!Zir.Inst.Ref {6770) InnerError!Zir.Inst.Ref {
6771 _ = rl;
6772 _ = scope;
6756 const casted_result_ptr = try gz.addPlNode(.bitcast_result_ptr, node, Zir.Inst.Bin{6773 const casted_result_ptr = try gz.addPlNode(.bitcast_result_ptr, node, Zir.Inst.Bin{
6757 .lhs = dest_type,6774 .lhs = dest_type,
6758 .rhs = result_ptr,6775 .rhs = result_ptr,
...@@ -8013,6 +8030,7 @@ fn rvalue(...@@ -8013,6 +8030,7 @@ fn rvalue(
8013 result: Zir.Inst.Ref,8030 result: Zir.Inst.Ref,
8014 src_node: ast.Node.Index,8031 src_node: ast.Node.Index,
8015) InnerError!Zir.Inst.Ref {8032) InnerError!Zir.Inst.Ref {
8033 _ = scope;
8016 switch (rl) {8034 switch (rl) {
8017 .none, .none_or_ref => return result,8035 .none, .none_or_ref => return result,
8018 .discard => {8036 .discard => {
src/Compilation.zig+1
...@@ -523,6 +523,7 @@ pub const AllErrors = struct {...@@ -523,6 +523,7 @@ pub const AllErrors = struct {
523 errors: *std.ArrayList(Message),523 errors: *std.ArrayList(Message),
524 msg: []const u8,524 msg: []const u8,
525 ) !void {525 ) !void {
526 _ = arena;
526 try errors.append(.{ .plain = .{ .msg = msg } });527 try errors.append(.{ .plain = .{ .msg = msg } });
527 }528 }
528529
src/Module.zig+17-2
...@@ -774,7 +774,10 @@ pub const Fn = struct {...@@ -774,7 +774,10 @@ pub const Fn = struct {
774 ir.dumpFn(mod, func);774 ir.dumpFn(mod, func);
775 }775 }
776776
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};
779782
780pub const Var = struct {783pub const Var = struct {
...@@ -2209,6 +2212,7 @@ comptime {...@@ -2209,6 +2212,7 @@ comptime {
2209}2212}
22102213
2211pub fn astGenFile(mod: *Module, file: *Scope.File, prog_node: *std.Progress.Node) !void {2214pub fn astGenFile(mod: *Module, file: *Scope.File, prog_node: *std.Progress.Node) !void {
2215 _ = prog_node;
2212 const tracy = trace(@src());2216 const tracy = trace(@src());
2213 defer tracy.end();2217 defer tracy.end();
22142218
...@@ -3128,6 +3132,7 @@ pub const ImportFileResult = struct {...@@ -3128,6 +3132,7 @@ pub const ImportFileResult = struct {
3128};3132};
31293133
3130pub fn importPkg(mod: *Module, cur_pkg: *Package, pkg: *Package) !ImportFileResult {3134pub fn importPkg(mod: *Module, cur_pkg: *Package, pkg: *Package) !ImportFileResult {
3135 _ = cur_pkg;
3131 const gpa = mod.gpa;3136 const gpa = mod.gpa;
31323137
3133 // The resolved path is used as the key in the import table, to detect if3138 // The resolved path is used as the key in the import table, to detect if
...@@ -3384,7 +3389,7 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) InnerError!vo...@@ -3384,7 +3389,7 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) InnerError!vo
3384 decl.has_align = has_align;3389 decl.has_align = has_align;
3385 decl.has_linksection = has_linksection;3390 decl.has_linksection = has_linksection;
3386 decl.zir_decl_index = @intCast(u32, decl_sub_index);3391 decl.zir_decl_index = @intCast(u32, decl_sub_index);
3387 if (decl.getFunction()) |func| {3392 if (decl.getFunction()) |_| {
3388 switch (mod.comp.bin_file.tag) {3393 switch (mod.comp.bin_file.tag) {
3389 .coff => {3394 .coff => {
3390 // TODO Implement for COFF3395 // TODO Implement for COFF
...@@ -3753,6 +3758,7 @@ pub fn analyzeExport(...@@ -3753,6 +3758,7 @@ pub fn analyzeExport(
3753 errdefer de_gop.value_ptr.* = mod.gpa.shrink(de_gop.value_ptr.*, de_gop.value_ptr.len - 1);3758 errdefer de_gop.value_ptr.* = mod.gpa.shrink(de_gop.value_ptr.*, de_gop.value_ptr.len - 1);
3754}3759}
3755pub fn constInst(mod: *Module, arena: *Allocator, src: LazySrcLoc, typed_value: TypedValue) !*ir.Inst {3760pub fn constInst(mod: *Module, arena: *Allocator, src: LazySrcLoc, typed_value: TypedValue) !*ir.Inst {
3761 _ = mod;
3756 const const_inst = try arena.create(ir.Inst.Constant);3762 const const_inst = try arena.create(ir.Inst.Constant);
3757 const_inst.* = .{3763 const_inst.* = .{
3758 .base = .{3764 .base = .{
...@@ -4121,6 +4127,7 @@ pub fn floatAdd(...@@ -4121,6 +4127,7 @@ pub fn floatAdd(
4121 lhs: Value,4127 lhs: Value,
4122 rhs: Value,4128 rhs: Value,
4123) !Value {4129) !Value {
4130 _ = src;
4124 switch (float_type.tag()) {4131 switch (float_type.tag()) {
4125 .f16 => {4132 .f16 => {
4126 @panic("TODO add __trunctfhf2 to compiler-rt");4133 @panic("TODO add __trunctfhf2 to compiler-rt");
...@@ -4154,6 +4161,7 @@ pub fn floatSub(...@@ -4154,6 +4161,7 @@ pub fn floatSub(
4154 lhs: Value,4161 lhs: Value,
4155 rhs: Value,4162 rhs: Value,
4156) !Value {4163) !Value {
4164 _ = src;
4157 switch (float_type.tag()) {4165 switch (float_type.tag()) {
4158 .f16 => {4166 .f16 => {
4159 @panic("TODO add __trunctfhf2 to compiler-rt");4167 @panic("TODO add __trunctfhf2 to compiler-rt");
...@@ -4187,6 +4195,7 @@ pub fn floatDiv(...@@ -4187,6 +4195,7 @@ pub fn floatDiv(
4187 lhs: Value,4195 lhs: Value,
4188 rhs: Value,4196 rhs: Value,
4189) !Value {4197) !Value {
4198 _ = src;
4190 switch (float_type.tag()) {4199 switch (float_type.tag()) {
4191 .f16 => {4200 .f16 => {
4192 @panic("TODO add __trunctfhf2 to compiler-rt");4201 @panic("TODO add __trunctfhf2 to compiler-rt");
...@@ -4220,6 +4229,7 @@ pub fn floatMul(...@@ -4220,6 +4229,7 @@ pub fn floatMul(
4220 lhs: Value,4229 lhs: Value,
4221 rhs: Value,4230 rhs: Value,
4222) !Value {4231) !Value {
4232 _ = src;
4223 switch (float_type.tag()) {4233 switch (float_type.tag()) {
4224 .f16 => {4234 .f16 => {
4225 @panic("TODO add __trunctfhf2 to compiler-rt");4235 @panic("TODO add __trunctfhf2 to compiler-rt");
...@@ -4253,6 +4263,7 @@ pub fn simplePtrType(...@@ -4253,6 +4263,7 @@ pub fn simplePtrType(
4253 mutable: bool,4263 mutable: bool,
4254 size: std.builtin.TypeInfo.Pointer.Size,4264 size: std.builtin.TypeInfo.Pointer.Size,
4255) Allocator.Error!Type {4265) Allocator.Error!Type {
4266 _ = mod;
4256 if (!mutable and size == .Slice and elem_ty.eql(Type.initTag(.u8))) {4267 if (!mutable and size == .Slice and elem_ty.eql(Type.initTag(.u8))) {
4257 return Type.initTag(.const_slice_u8);4268 return Type.initTag(.const_slice_u8);
4258 }4269 }
...@@ -4287,6 +4298,7 @@ pub fn ptrType(...@@ -4287,6 +4298,7 @@ pub fn ptrType(
4287 @"volatile": bool,4298 @"volatile": bool,
4288 size: std.builtin.TypeInfo.Pointer.Size,4299 size: std.builtin.TypeInfo.Pointer.Size,
4289) Allocator.Error!Type {4300) Allocator.Error!Type {
4301 _ = mod;
4290 assert(host_size == 0 or bit_offset < host_size * 8);4302 assert(host_size == 0 or bit_offset < host_size * 8);
42914303
4292 // TODO check if type can be represented by simplePtrType4304 // TODO check if type can be represented by simplePtrType
...@@ -4304,6 +4316,7 @@ pub fn ptrType(...@@ -4304,6 +4316,7 @@ pub fn ptrType(
4304}4316}
43054317
4306pub fn optionalType(mod: *Module, arena: *Allocator, child_type: Type) Allocator.Error!Type {4318pub fn optionalType(mod: *Module, arena: *Allocator, child_type: Type) Allocator.Error!Type {
4319 _ = mod;
4307 switch (child_type.tag()) {4320 switch (child_type.tag()) {
4308 .single_const_pointer => return Type.Tag.optional_single_const_pointer.create(4321 .single_const_pointer => return Type.Tag.optional_single_const_pointer.create(
4309 arena,4322 arena,
...@@ -4324,6 +4337,7 @@ pub fn arrayType(...@@ -4324,6 +4337,7 @@ pub fn arrayType(
4324 sentinel: ?Value,4337 sentinel: ?Value,
4325 elem_type: Type,4338 elem_type: Type,
4326) Allocator.Error!Type {4339) Allocator.Error!Type {
4340 _ = mod;
4327 if (elem_type.eql(Type.initTag(.u8))) {4341 if (elem_type.eql(Type.initTag(.u8))) {
4328 if (sentinel) |some| {4342 if (sentinel) |some| {
4329 if (some.eql(Value.initTag(.zero))) {4343 if (some.eql(Value.initTag(.zero))) {
...@@ -4354,6 +4368,7 @@ pub fn errorUnionType(...@@ -4354,6 +4368,7 @@ pub fn errorUnionType(
4354 error_set: Type,4368 error_set: Type,
4355 payload: Type,4369 payload: Type,
4356) Allocator.Error!Type {4370) Allocator.Error!Type {
4371 _ = mod;
4357 assert(error_set.zigTypeTag() == .ErrorSet);4372 assert(error_set.zigTypeTag() == .ErrorSet);
4358 if (error_set.eql(Type.initTag(.anyerror)) and payload.eql(Type.initTag(.void))) {4373 if (error_set.eql(Type.initTag(.anyerror)) and payload.eql(Type.initTag(.void))) {
4359 return Type.initTag(.anyerror_void_error_union);4374 return Type.initTag(.anyerror_void_error_union);
src/Sema.zig+34
...@@ -702,6 +702,7 @@ fn zirBitcastResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) I...@@ -702,6 +702,7 @@ fn zirBitcastResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) I
702}702}
703703
704fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {704fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
705 _ = inst;
705 const tracy = trace(@src());706 const tracy = trace(@src());
706 defer tracy.end();707 defer tracy.end();
707 return sema.mod.fail(&block.base, sema.src, "TODO implement zirCoerceResultPtr", .{});708 return sema.mod.fail(&block.base, sema.src, "TODO implement zirCoerceResultPtr", .{});
...@@ -776,6 +777,7 @@ fn zirStructDecl(...@@ -776,6 +777,7 @@ fn zirStructDecl(
776}777}
777778
778fn createTypeName(sema: *Sema, block: *Scope.Block, name_strategy: Zir.Inst.NameStrategy) ![:0]u8 {779fn createTypeName(sema: *Sema, block: *Scope.Block, name_strategy: Zir.Inst.NameStrategy) ![:0]u8 {
780 _ = block;
779 switch (name_strategy) {781 switch (name_strategy) {
780 .anon => {782 .anon => {
781 // It would be neat to have "struct:line:column" but this name has783 // It would be neat to have "struct:line:column" but this name has
...@@ -1067,6 +1069,7 @@ fn zirOpaqueDecl(...@@ -1067,6 +1069,7 @@ fn zirOpaqueDecl(
1067 inst: Zir.Inst.Index,1069 inst: Zir.Inst.Index,
1068 name_strategy: Zir.Inst.NameStrategy,1070 name_strategy: Zir.Inst.NameStrategy,
1069) InnerError!*Inst {1071) InnerError!*Inst {
1072 _ = name_strategy;
1070 const tracy = trace(@src());1073 const tracy = trace(@src());
1071 defer tracy.end();1074 defer tracy.end();
10721075
...@@ -1242,6 +1245,7 @@ fn zirArg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In...@@ -1242,6 +1245,7 @@ fn zirArg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In
1242 // TODO check if arg_name shadows a Decl1245 // TODO check if arg_name shadows a Decl
12431246
1244 if (block.inlining) |inlining| {1247 if (block.inlining) |inlining| {
1248 _ = inlining;
1245 return sema.param_inst_list[arg_index];1249 return sema.param_inst_list[arg_index];
1246 }1250 }
12471251
...@@ -1640,6 +1644,7 @@ fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In...@@ -1640,6 +1644,7 @@ fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In
1640}1644}
16411645
1642fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {1646fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
1647 _ = block;
1643 const tracy = trace(@src());1648 const tracy = trace(@src());
1644 defer tracy.end();1649 defer tracy.end();
16451650
...@@ -1648,6 +1653,7 @@ fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In...@@ -1648,6 +1653,7 @@ fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In
1648}1653}
16491654
1650fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {1655fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
1656 _ = block;
1651 const tracy = trace(@src());1657 const tracy = trace(@src());
1652 defer tracy.end();1658 defer tracy.end();
16531659
...@@ -1665,6 +1671,7 @@ fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!...@@ -1665,6 +1671,7 @@ fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!
1665}1671}
16661672
1667fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {1673fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
1674 _ = block;
1668 const arena = sema.arena;1675 const arena = sema.arena;
1669 const inst_data = sema.code.instructions.items(.data)[inst].float;1676 const inst_data = sema.code.instructions.items(.data)[inst].float;
1670 const src = inst_data.src();1677 const src = inst_data.src();
...@@ -1677,6 +1684,7 @@ fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*...@@ -1677,6 +1684,7 @@ fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*
1677}1684}
16781685
1679fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {1686fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
1687 _ = block;
1680 const arena = sema.arena;1688 const arena = sema.arena;
1681 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;1689 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
1682 const extra = sema.code.extraData(Zir.Inst.Float128, inst_data.payload_index).data;1690 const extra = sema.code.extraData(Zir.Inst.Float128, inst_data.payload_index).data;
...@@ -2358,6 +2366,7 @@ fn analyzeCall(...@@ -2358,6 +2366,7 @@ fn analyzeCall(
2358}2366}
23592367
2360fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {2368fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
2369 _ = block;
2361 const tracy = trace(@src());2370 const tracy = trace(@src());
2362 defer tracy.end();2371 defer tracy.end();
23632372
...@@ -2466,6 +2475,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn...@@ -2466,6 +2475,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn
2466}2475}
24672476
2468fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {2477fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
2478 _ = block;
2469 const tracy = trace(@src());2479 const tracy = trace(@src());
2470 defer tracy.end();2480 defer tracy.end();
24712481
...@@ -2626,6 +2636,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn...@@ -2626,6 +2636,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn
2626}2636}
26272637
2628fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {2638fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
2639 _ = block;
2629 const tracy = trace(@src());2640 const tracy = trace(@src());
2630 defer tracy.end();2641 defer tracy.end();
26312642
...@@ -3056,6 +3067,7 @@ fn funcCommon(...@@ -3056,6 +3067,7 @@ fn funcCommon(
3056 src_locs: Zir.Inst.Func.SrcLocs,3067 src_locs: Zir.Inst.Func.SrcLocs,
3057 opt_lib_name: ?[]const u8,3068 opt_lib_name: ?[]const u8,
3058) InnerError!*Inst {3069) InnerError!*Inst {
3070 _ = inferred_error_set;
3059 const src: LazySrcLoc = .{ .node_offset = src_node_offset };3071 const src: LazySrcLoc = .{ .node_offset = src_node_offset };
3060 const ret_ty_src: LazySrcLoc = .{ .node_offset_fn_type_ret_ty = src_node_offset };3072 const ret_ty_src: LazySrcLoc = .{ .node_offset_fn_type_ret_ty = src_node_offset };
3061 const return_type = try sema.resolveType(block, ret_ty_src, zir_return_type);3073 const return_type = try sema.resolveType(block, ret_ty_src, zir_return_type);
...@@ -3492,6 +3504,8 @@ fn zirSwitchCapture(...@@ -3492,6 +3504,8 @@ fn zirSwitchCapture(
3492 is_multi: bool,3504 is_multi: bool,
3493 is_ref: bool,3505 is_ref: bool,
3494) InnerError!*Inst {3506) InnerError!*Inst {
3507 _ = is_ref;
3508 _ = is_multi;
3495 const tracy = trace(@src());3509 const tracy = trace(@src());
3496 defer tracy.end();3510 defer tracy.end();
34973511
...@@ -3509,6 +3523,7 @@ fn zirSwitchCaptureElse(...@@ -3509,6 +3523,7 @@ fn zirSwitchCaptureElse(
3509 inst: Zir.Inst.Index,3523 inst: Zir.Inst.Index,
3510 is_ref: bool,3524 is_ref: bool,
3511) InnerError!*Inst {3525) InnerError!*Inst {
3526 _ = is_ref;
3512 const tracy = trace(@src());3527 const tracy = trace(@src());
3513 defer tracy.end();3528 defer tracy.end();
35143529
...@@ -4511,12 +4526,15 @@ fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!...@@ -4511,12 +4526,15 @@ fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!
4511}4526}
45124527
4513fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {4528fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
4529 _ = block;
4530 _ = inst;
4514 const tracy = trace(@src());4531 const tracy = trace(@src());
4515 defer tracy.end();4532 defer tracy.end();
4516 return sema.mod.fail(&block.base, sema.src, "TODO implement zirShl", .{});4533 return sema.mod.fail(&block.base, sema.src, "TODO implement zirShl", .{});
4517}4534}
45184535
4519fn zirShr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {4536fn zirShr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
4537 _ = inst;
4520 const tracy = trace(@src());4538 const tracy = trace(@src());
4521 defer tracy.end();4539 defer tracy.end();
4522 return sema.mod.fail(&block.base, sema.src, "TODO implement zirShr", .{});4540 return sema.mod.fail(&block.base, sema.src, "TODO implement zirShr", .{});
...@@ -4586,18 +4604,21 @@ fn zirBitwise(...@@ -4586,18 +4604,21 @@ fn zirBitwise(
4586}4604}
45874605
4588fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {4606fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
4607 _ = inst;
4589 const tracy = trace(@src());4608 const tracy = trace(@src());
4590 defer tracy.end();4609 defer tracy.end();
4591 return sema.mod.fail(&block.base, sema.src, "TODO implement zirBitNot", .{});4610 return sema.mod.fail(&block.base, sema.src, "TODO implement zirBitNot", .{});
4592}4611}
45934612
4594fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {4613fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
4614 _ = inst;
4595 const tracy = trace(@src());4615 const tracy = trace(@src());
4596 defer tracy.end();4616 defer tracy.end();
4597 return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayCat", .{});4617 return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayCat", .{});
4598}4618}
45994619
4600fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {4620fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
4621 _ = inst;
4601 const tracy = trace(@src());4622 const tracy = trace(@src());
4602 defer tracy.end();4623 defer tracy.end();
4603 return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayMul", .{});4624 return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayMul", .{});
...@@ -5059,6 +5080,7 @@ fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro...@@ -5059,6 +5080,7 @@ fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
5059}5080}
50605081
5061fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {5082fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
5083 _ = block;
5062 const zir_datas = sema.code.instructions.items(.data);5084 const zir_datas = sema.code.instructions.items(.data);
5063 const inst_data = zir_datas[inst].un_node;5085 const inst_data = zir_datas[inst].un_node;
5064 const src = inst_data.src();5086 const src = inst_data.src();
...@@ -5067,6 +5089,7 @@ fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!...@@ -5067,6 +5089,7 @@ fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!
5067}5089}
50685090
5069fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {5091fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
5092 _ = block;
5070 const inst_data = sema.code.instructions.items(.data)[inst].un_node;5093 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
5071 const src = inst_data.src();5094 const src = inst_data.src();
5072 const operand_ptr = try sema.resolveInst(inst_data.operand);5095 const operand_ptr = try sema.resolveInst(inst_data.operand);
...@@ -5504,6 +5527,7 @@ fn zirUnionInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner...@@ -5504,6 +5527,7 @@ fn zirUnionInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner
5504}5527}
55055528
5506fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst {5529fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst {
5530 _ = is_ref;
5507 const mod = sema.mod;5531 const mod = sema.mod;
5508 const gpa = sema.gpa;5532 const gpa = sema.gpa;
5509 const zir_datas = sema.code.instructions.items(.data);5533 const zir_datas = sema.code.instructions.items(.data);
...@@ -5613,18 +5637,21 @@ fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref:...@@ -5613,18 +5637,21 @@ fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref:
5613}5637}
56145638
5615fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst {5639fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst {
5640 _ = is_ref;
5616 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;5641 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
5617 const src = inst_data.src();5642 const src = inst_data.src();
5618 return sema.mod.fail(&block.base, src, "TODO: Sema.zirStructInitAnon", .{});5643 return sema.mod.fail(&block.base, src, "TODO: Sema.zirStructInitAnon", .{});
5619}5644}
56205645
5621fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst {5646fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst {
5647 _ = is_ref;
5622 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;5648 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
5623 const src = inst_data.src();5649 const src = inst_data.src();
5624 return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInit", .{});5650 return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInit", .{});
5625}5651}
56265652
5627fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst {5653fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst {
5654 _ = is_ref;
5628 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;5655 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
5629 const src = inst_data.src();5656 const src = inst_data.src();
5630 return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInitAnon", .{});5657 return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInitAnon", .{});
...@@ -6021,6 +6048,7 @@ fn zirAwait(...@@ -6021,6 +6048,7 @@ fn zirAwait(
6021 inst: Zir.Inst.Index,6048 inst: Zir.Inst.Index,
6022 is_nosuspend: bool,6049 is_nosuspend: bool,
6023) InnerError!*Inst {6050) InnerError!*Inst {
6051 _ = is_nosuspend;
6024 const inst_data = sema.code.instructions.items(.data)[inst].un_node;6052 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
6025 const src = inst_data.src();6053 const src = inst_data.src();
6026 return sema.mod.fail(&block.base, src, "TODO: Sema.zirAwait", .{});6054 return sema.mod.fail(&block.base, src, "TODO: Sema.zirAwait", .{});
...@@ -6302,6 +6330,8 @@ fn addSafetyCheck(sema: *Sema, parent_block: *Scope.Block, ok: *Inst, panic_id:...@@ -6302,6 +6330,8 @@ fn addSafetyCheck(sema: *Sema, parent_block: *Scope.Block, ok: *Inst, panic_id:
6302}6330}
63036331
6304fn safetyPanic(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, panic_id: PanicId) !Zir.Inst.Index {6332fn safetyPanic(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, panic_id: PanicId) !Zir.Inst.Index {
6333 _ = sema;
6334 _ = panic_id;
6305 // TODO Once we have a panic function to call, call it here instead of breakpoint.6335 // TODO Once we have a panic function to call, call it here instead of breakpoint.
6306 _ = try block.addNoOp(src, Type.initTag(.void), .breakpoint);6336 _ = try block.addNoOp(src, Type.initTag(.void), .breakpoint);
6307 _ = try block.addNoOp(src, Type.initTag(.noreturn), .unreach);6337 _ = try block.addNoOp(src, Type.initTag(.noreturn), .unreach);
...@@ -6600,6 +6630,8 @@ fn elemPtrArray(...@@ -6600,6 +6630,8 @@ fn elemPtrArray(
6600 elem_index: *Inst,6630 elem_index: *Inst,
6601 elem_index_src: LazySrcLoc,6631 elem_index_src: LazySrcLoc,
6602) InnerError!*Inst {6632) InnerError!*Inst {
6633 _ = elem_index;
6634 _ = elem_index_src;
6603 if (array_ptr.value()) |array_ptr_val| {6635 if (array_ptr.value()) |array_ptr_val| {
6604 if (elem_index.value()) |index_val| {6636 if (elem_index.value()) |index_val| {
6605 // Both array pointer and index are compile-time known.6637 // Both array pointer and index are compile-time known.
...@@ -7510,6 +7542,8 @@ fn resolveBuiltinTypeFields(...@@ -7510,6 +7542,8 @@ fn resolveBuiltinTypeFields(
7510 ty: Type,7542 ty: Type,
7511 name: []const u8,7543 name: []const u8,
7512) InnerError!Type {7544) InnerError!Type {
7545 _ = ty;
7546 _ = name;
7513 const resolved_ty = try sema.getBuiltinType(block, src, name);7547 const resolved_ty = try sema.getBuiltinType(block, src, name);
7514 return sema.resolveTypeFields(block, src, resolved_ty);7548 return sema.resolveTypeFields(block, src, resolved_ty);
7515}7549}
src/Zir.zig+2
...@@ -4433,6 +4433,7 @@ const Writer = struct {...@@ -4433,6 +4433,7 @@ const Writer = struct {
4433 }4433 }
44344434
4435 fn writeInstIndex(self: *Writer, stream: anytype, inst: Inst.Index) !void {4435 fn writeInstIndex(self: *Writer, stream: anytype, inst: Inst.Index) !void {
4436 _ = self;
4436 return stream.print("%{d}", .{inst});4437 return stream.print("%{d}", .{inst});
4437 }4438 }
44384439
...@@ -4453,6 +4454,7 @@ const Writer = struct {...@@ -4453,6 +4454,7 @@ const Writer = struct {
4453 name: []const u8,4454 name: []const u8,
4454 flag: bool,4455 flag: bool,
4455 ) !void {4456 ) !void {
4457 _ = self;
4456 if (!flag) return;4458 if (!flag) return;
4457 try stream.writeAll(name);4459 try stream.writeAll(name);
4458 }4460 }
src/air.zig+36
...@@ -304,9 +304,12 @@ pub const Inst = struct {...@@ -304,9 +304,12 @@ pub const Inst = struct {
304 base: Inst,304 base: Inst,
305305
306 pub fn operandCount(self: *const NoOp) usize {306 pub fn operandCount(self: *const NoOp) usize {
307 _ = self;
307 return 0;308 return 0;
308 }309 }
309 pub fn getOperand(self: *const NoOp, index: usize) ?*Inst {310 pub fn getOperand(self: *const NoOp, index: usize) ?*Inst {
311 _ = self;
312 _ = index;
310 return null;313 return null;
311 }314 }
312 };315 };
...@@ -316,6 +319,7 @@ pub const Inst = struct {...@@ -316,6 +319,7 @@ pub const Inst = struct {
316 operand: *Inst,319 operand: *Inst,
317320
318 pub fn operandCount(self: *const UnOp) usize {321 pub fn operandCount(self: *const UnOp) usize {
322 _ = self;
319 return 1;323 return 1;
320 }324 }
321 pub fn getOperand(self: *const UnOp, index: usize) ?*Inst {325 pub fn getOperand(self: *const UnOp, index: usize) ?*Inst {
...@@ -331,6 +335,7 @@ pub const Inst = struct {...@@ -331,6 +335,7 @@ pub const Inst = struct {
331 rhs: *Inst,335 rhs: *Inst,
332336
333 pub fn operandCount(self: *const BinOp) usize {337 pub fn operandCount(self: *const BinOp) usize {
338 _ = self;
334 return 2;339 return 2;
335 }340 }
336 pub fn getOperand(self: *const BinOp, index: usize) ?*Inst {341 pub fn getOperand(self: *const BinOp, index: usize) ?*Inst {
...@@ -356,9 +361,12 @@ pub const Inst = struct {...@@ -356,9 +361,12 @@ pub const Inst = struct {
356 name: [*:0]const u8,361 name: [*:0]const u8,
357362
358 pub fn operandCount(self: *const Arg) usize {363 pub fn operandCount(self: *const Arg) usize {
364 _ = self;
359 return 0;365 return 0;
360 }366 }
361 pub fn getOperand(self: *const Arg, index: usize) ?*Inst {367 pub fn getOperand(self: *const Arg, index: usize) ?*Inst {
368 _ = self;
369 _ = index;
362 return null;370 return null;
363 }371 }
364 };372 };
...@@ -391,9 +399,12 @@ pub const Inst = struct {...@@ -391,9 +399,12 @@ pub const Inst = struct {
391 body: Body,399 body: Body,
392400
393 pub fn operandCount(self: *const Block) usize {401 pub fn operandCount(self: *const Block) usize {
402 _ = self;
394 return 0;403 return 0;
395 }404 }
396 pub fn getOperand(self: *const Block, index: usize) ?*Inst {405 pub fn getOperand(self: *const Block, index: usize) ?*Inst {
406 _ = self;
407 _ = index;
397 return null;408 return null;
398 }409 }
399 };410 };
...@@ -412,9 +423,12 @@ pub const Inst = struct {...@@ -412,9 +423,12 @@ pub const Inst = struct {
412 body: Body,423 body: Body,
413424
414 pub fn operandCount(self: *const BrBlockFlat) usize {425 pub fn operandCount(self: *const BrBlockFlat) usize {
426 _ = self;
415 return 0;427 return 0;
416 }428 }
417 pub fn getOperand(self: *const BrBlockFlat, index: usize) ?*Inst {429 pub fn getOperand(self: *const BrBlockFlat, index: usize) ?*Inst {
430 _ = self;
431 _ = index;
418 return null;432 return null;
419 }433 }
420 };434 };
...@@ -427,9 +441,11 @@ pub const Inst = struct {...@@ -427,9 +441,11 @@ pub const Inst = struct {
427 operand: *Inst,441 operand: *Inst,
428442
429 pub fn operandCount(self: *const Br) usize {443 pub fn operandCount(self: *const Br) usize {
444 _ = self;
430 return 1;445 return 1;
431 }446 }
432 pub fn getOperand(self: *const Br, index: usize) ?*Inst {447 pub fn getOperand(self: *const Br, index: usize) ?*Inst {
448 _ = self;
433 if (index == 0)449 if (index == 0)
434 return self.operand;450 return self.operand;
435 return null;451 return null;
...@@ -443,9 +459,12 @@ pub const Inst = struct {...@@ -443,9 +459,12 @@ pub const Inst = struct {
443 block: *Block,459 block: *Block,
444460
445 pub fn operandCount(self: *const BrVoid) usize {461 pub fn operandCount(self: *const BrVoid) usize {
462 _ = self;
446 return 0;463 return 0;
447 }464 }
448 pub fn getOperand(self: *const BrVoid, index: usize) ?*Inst {465 pub fn getOperand(self: *const BrVoid, index: usize) ?*Inst {
466 _ = self;
467 _ = index;
449 return null;468 return null;
450 }469 }
451 };470 };
...@@ -490,6 +509,7 @@ pub const Inst = struct {...@@ -490,6 +509,7 @@ pub const Inst = struct {
490 else_death_count: u32 = 0,509 else_death_count: u32 = 0,
491510
492 pub fn operandCount(self: *const CondBr) usize {511 pub fn operandCount(self: *const CondBr) usize {
512 _ = self;
493 return 1;513 return 1;
494 }514 }
495 pub fn getOperand(self: *const CondBr, index: usize) ?*Inst {515 pub fn getOperand(self: *const CondBr, index: usize) ?*Inst {
...@@ -516,9 +536,12 @@ pub const Inst = struct {...@@ -516,9 +536,12 @@ pub const Inst = struct {
516 val: Value,536 val: Value,
517537
518 pub fn operandCount(self: *const Constant) usize {538 pub fn operandCount(self: *const Constant) usize {
539 _ = self;
519 return 0;540 return 0;
520 }541 }
521 pub fn getOperand(self: *const Constant, index: usize) ?*Inst {542 pub fn getOperand(self: *const Constant, index: usize) ?*Inst {
543 _ = self;
544 _ = index;
522 return null;545 return null;
523 }546 }
524 };547 };
...@@ -530,9 +553,12 @@ pub const Inst = struct {...@@ -530,9 +553,12 @@ pub const Inst = struct {
530 body: Body,553 body: Body,
531554
532 pub fn operandCount(self: *const Loop) usize {555 pub fn operandCount(self: *const Loop) usize {
556 _ = self;
533 return 0;557 return 0;
534 }558 }
535 pub fn getOperand(self: *const Loop, index: usize) ?*Inst {559 pub fn getOperand(self: *const Loop, index: usize) ?*Inst {
560 _ = self;
561 _ = index;
536 return null;562 return null;
537 }563 }
538 };564 };
...@@ -544,9 +570,12 @@ pub const Inst = struct {...@@ -544,9 +570,12 @@ pub const Inst = struct {
544 variable: *Module.Var,570 variable: *Module.Var,
545571
546 pub fn operandCount(self: *const VarPtr) usize {572 pub fn operandCount(self: *const VarPtr) usize {
573 _ = self;
547 return 0;574 return 0;
548 }575 }
549 pub fn getOperand(self: *const VarPtr, index: usize) ?*Inst {576 pub fn getOperand(self: *const VarPtr, index: usize) ?*Inst {
577 _ = self;
578 _ = index;
550 return null;579 return null;
551 }580 }
552 };581 };
...@@ -559,9 +588,12 @@ pub const Inst = struct {...@@ -559,9 +588,12 @@ pub const Inst = struct {
559 field_index: usize,588 field_index: usize,
560589
561 pub fn operandCount(self: *const StructFieldPtr) usize {590 pub fn operandCount(self: *const StructFieldPtr) usize {
591 _ = self;
562 return 1;592 return 1;
563 }593 }
564 pub fn getOperand(self: *const StructFieldPtr, index: usize) ?*Inst {594 pub fn getOperand(self: *const StructFieldPtr, index: usize) ?*Inst {
595 _ = self;
596 _ = index;
565 var i = index;597 var i = index;
566598
567 if (i < 1)599 if (i < 1)
...@@ -593,6 +625,7 @@ pub const Inst = struct {...@@ -593,6 +625,7 @@ pub const Inst = struct {
593 };625 };
594626
595 pub fn operandCount(self: *const SwitchBr) usize {627 pub fn operandCount(self: *const SwitchBr) usize {
628 _ = self;
596 return 1;629 return 1;
597 }630 }
598 pub fn getOperand(self: *const SwitchBr, index: usize) ?*Inst {631 pub fn getOperand(self: *const SwitchBr, index: usize) ?*Inst {
...@@ -621,9 +654,12 @@ pub const Inst = struct {...@@ -621,9 +654,12 @@ pub const Inst = struct {
621 column: u32,654 column: u32,
622655
623 pub fn operandCount(self: *const DbgStmt) usize {656 pub fn operandCount(self: *const DbgStmt) usize {
657 _ = self;
624 return 0;658 return 0;
625 }659 }
626 pub fn getOperand(self: *const DbgStmt, index: usize) ?*Inst {660 pub fn getOperand(self: *const DbgStmt, index: usize) ?*Inst {
661 _ = self;
662 _ = index;
627 return null;663 return null;
628 }664 }
629 };665 };
src/codegen.zig+22-15
...@@ -564,7 +564,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -564,7 +564,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
564 .r11 = true, // fp564 .r11 = true, // fp
565 .r14 = true, // lr565 .r14 = true, // lr
566 };566 };
567 inline for (callee_preserved_regs) |reg, i| {567 inline for (callee_preserved_regs) |reg| {
568 if (self.register_manager.isRegAllocated(reg)) {568 if (self.register_manager.isRegAllocated(reg)) {
569 @field(saved_regs, @tagName(reg)) = true;569 @field(saved_regs, @tagName(reg)) = true;
570 }570 }
...@@ -602,7 +602,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -602,7 +602,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
602 } else {602 } else {
603 if (math.cast(i26, amt)) |offset| {603 if (math.cast(i26, amt)) |offset| {
604 writeInt(u32, self.code.items[jmp_reloc..][0..4], Instruction.b(.al, offset).toU32());604 writeInt(u32, self.code.items[jmp_reloc..][0..4], Instruction.b(.al, offset).toU32());
605 } else |err| {605 } else |_| {
606 return self.failSymbol("exitlude jump is too large", .{});606 return self.failSymbol("exitlude jump is too large", .{});
607 }607 }
608 }608 }
...@@ -675,7 +675,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -675,7 +675,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
675 } else {675 } else {
676 if (math.cast(i28, amt)) |offset| {676 if (math.cast(i28, amt)) |offset| {
677 writeInt(u32, self.code.items[jmp_reloc..][0..4], Instruction.b(offset).toU32());677 writeInt(u32, self.code.items[jmp_reloc..][0..4], Instruction.b(offset).toU32());
678 } else |err| {678 } else |_| {
679 return self.failSymbol("exitlude jump is too large", .{});679 return self.failSymbol("exitlude jump is too large", .{});
680 }680 }
681 }681 }
...@@ -1497,6 +1497,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -1497,6 +1497,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
1497 swap_lhs_and_rhs: bool,1497 swap_lhs_and_rhs: bool,
1498 op: ir.Inst.Tag,1498 op: ir.Inst.Tag,
1499 ) !void {1499 ) !void {
1500 _ = src;
1500 assert(lhs_mcv == .register or rhs_mcv == .register);1501 assert(lhs_mcv == .register or rhs_mcv == .register);
15011502
1502 const op1 = if (swap_lhs_and_rhs) rhs_mcv.register else lhs_mcv.register;1503 const op1 = if (swap_lhs_and_rhs) rhs_mcv.register else lhs_mcv.register;
...@@ -1905,6 +1906,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -1905,6 +1906,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
1905 try self.genX8664ModRMRegToStack(src, dst_ty, off, src_reg, mr + 0x1);1906 try self.genX8664ModRMRegToStack(src, dst_ty, off, src_reg, mr + 0x1);
1906 },1907 },
1907 .immediate => |imm| {1908 .immediate => |imm| {
1909 _ = imm;
1908 return self.fail(src, "TODO implement x86 ADD/SUB/CMP source immediate", .{});1910 return self.fail(src, "TODO implement x86 ADD/SUB/CMP source immediate", .{});
1909 },1911 },
1910 .embedded_in_code, .memory, .stack_offset => {1912 .embedded_in_code, .memory, .stack_offset => {
...@@ -2054,6 +2056,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -2054,6 +2056,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
2054 return self.genSetStack(src, dst_ty, off, MCValue{ .register = dst_reg });2056 return self.genSetStack(src, dst_ty, off, MCValue{ .register = dst_reg });
2055 },2057 },
2056 .immediate => |imm| {2058 .immediate => |imm| {
2059 _ = imm;
2057 return self.fail(src, "TODO implement x86 multiply source immediate", .{});2060 return self.fail(src, "TODO implement x86 multiply source immediate", .{});
2058 },2061 },
2059 .embedded_in_code, .memory, .stack_offset => {2062 .embedded_in_code, .memory, .stack_offset => {
...@@ -2982,14 +2985,14 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -2982,14 +2985,14 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
2982 .arm, .armeb => {2985 .arm, .armeb => {
2983 if (math.cast(i26, @intCast(i32, index) - @intCast(i32, self.code.items.len + 8))) |delta| {2986 if (math.cast(i26, @intCast(i32, index) - @intCast(i32, self.code.items.len + 8))) |delta| {
2984 writeInt(u32, try self.code.addManyAsArray(4), Instruction.b(.al, delta).toU32());2987 writeInt(u32, try self.code.addManyAsArray(4), Instruction.b(.al, delta).toU32());
2985 } else |err| {2988 } else |_| {
2986 return self.fail(src, "TODO: enable larger branch offset", .{});2989 return self.fail(src, "TODO: enable larger branch offset", .{});
2987 }2990 }
2988 },2991 },
2989 .aarch64, .aarch64_be, .aarch64_32 => {2992 .aarch64, .aarch64_be, .aarch64_32 => {
2990 if (math.cast(i28, @intCast(i32, index) - @intCast(i32, self.code.items.len + 8))) |delta| {2993 if (math.cast(i28, @intCast(i32, index) - @intCast(i32, self.code.items.len + 8))) |delta| {
2991 writeInt(u32, try self.code.addManyAsArray(4), Instruction.b(delta).toU32());2994 writeInt(u32, try self.code.addManyAsArray(4), Instruction.b(delta).toU32());
2992 } else |err| {2995 } else |_| {
2993 return self.fail(src, "TODO: enable larger branch offset", .{});2996 return self.fail(src, "TODO: enable larger branch offset", .{});
2994 }2997 }
2995 },2998 },
...@@ -3307,16 +3310,18 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -3307,16 +3310,18 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
3307 }3310 }
3308 },3311 },
3309 .compare_flags_unsigned => |op| {3312 .compare_flags_unsigned => |op| {
3313 _ = op;
3310 return self.fail(src, "TODO implement set stack variable with compare flags value (unsigned)", .{});3314 return self.fail(src, "TODO implement set stack variable with compare flags value (unsigned)", .{});
3311 },3315 },
3312 .compare_flags_signed => |op| {3316 .compare_flags_signed => |op| {
3317 _ = op;
3313 return self.fail(src, "TODO implement set stack variable with compare flags value (signed)", .{});3318 return self.fail(src, "TODO implement set stack variable with compare flags value (signed)", .{});
3314 },3319 },
3315 .immediate => {3320 .immediate => {
3316 const reg = try self.copyToTmpRegister(src, ty, mcv);3321 const reg = try self.copyToTmpRegister(src, ty, mcv);
3317 return self.genSetStack(src, ty, stack_offset, MCValue{ .register = reg });3322 return self.genSetStack(src, ty, stack_offset, MCValue{ .register = reg });
3318 },3323 },
3319 .embedded_in_code => |code_offset| {3324 .embedded_in_code => {
3320 return self.fail(src, "TODO implement set stack variable from embedded_in_code", .{});3325 return self.fail(src, "TODO implement set stack variable from embedded_in_code", .{});
3321 },3326 },
3322 .register => |reg| {3327 .register => |reg| {
...@@ -3352,7 +3357,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -3352,7 +3357,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
3352 else => return self.fail(src, "TODO implement storing other types abi_size={}", .{abi_size}),3357 else => return self.fail(src, "TODO implement storing other types abi_size={}", .{abi_size}),
3353 }3358 }
3354 },3359 },
3355 .memory => |vaddr| {3360 .memory => {
3356 return self.fail(src, "TODO implement set stack variable from memory vaddr", .{});3361 return self.fail(src, "TODO implement set stack variable from memory vaddr", .{});
3357 },3362 },
3358 .stack_offset => |off| {3363 .stack_offset => |off| {
...@@ -3380,10 +3385,10 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -3380,10 +3385,10 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
3380 else => return self.fail(src, "TODO implement memset", .{}),3385 else => return self.fail(src, "TODO implement memset", .{}),
3381 }3386 }
3382 },3387 },
3383 .compare_flags_unsigned => |op| {3388 .compare_flags_unsigned => {
3384 return self.fail(src, "TODO implement set stack variable with compare flags value (unsigned)", .{});3389 return self.fail(src, "TODO implement set stack variable with compare flags value (unsigned)", .{});
3385 },3390 },
3386 .compare_flags_signed => |op| {3391 .compare_flags_signed => {
3387 return self.fail(src, "TODO implement set stack variable with compare flags value (signed)", .{});3392 return self.fail(src, "TODO implement set stack variable with compare flags value (signed)", .{});
3388 },3393 },
3389 .immediate => |x_big| {3394 .immediate => |x_big| {
...@@ -3435,13 +3440,13 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -3435,13 +3440,13 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
3435 },3440 },
3436 }3441 }
3437 },3442 },
3438 .embedded_in_code => |code_offset| {3443 .embedded_in_code => {
3439 return self.fail(src, "TODO implement set stack variable from embedded_in_code", .{});3444 return self.fail(src, "TODO implement set stack variable from embedded_in_code", .{});
3440 },3445 },
3441 .register => |reg| {3446 .register => |reg| {
3442 try self.genX8664ModRMRegToStack(src, ty, stack_offset, reg, 0x89);3447 try self.genX8664ModRMRegToStack(src, ty, stack_offset, reg, 0x89);
3443 },3448 },
3444 .memory => |vaddr| {3449 .memory => {
3445 return self.fail(src, "TODO implement set stack variable from memory vaddr", .{});3450 return self.fail(src, "TODO implement set stack variable from memory vaddr", .{});
3446 },3451 },
3447 .stack_offset => |off| {3452 .stack_offset => |off| {
...@@ -3469,17 +3474,17 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -3469,17 +3474,17 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
3469 else => return self.fail(src, "TODO implement memset", .{}),3474 else => return self.fail(src, "TODO implement memset", .{}),
3470 }3475 }
3471 },3476 },
3472 .compare_flags_unsigned => |op| {3477 .compare_flags_unsigned => {
3473 return self.fail(src, "TODO implement set stack variable with compare flags value (unsigned)", .{});3478 return self.fail(src, "TODO implement set stack variable with compare flags value (unsigned)", .{});
3474 },3479 },
3475 .compare_flags_signed => |op| {3480 .compare_flags_signed => {
3476 return self.fail(src, "TODO implement set stack variable with compare flags value (signed)", .{});3481 return self.fail(src, "TODO implement set stack variable with compare flags value (signed)", .{});
3477 },3482 },
3478 .immediate => {3483 .immediate => {
3479 const reg = try self.copyToTmpRegister(src, ty, mcv);3484 const reg = try self.copyToTmpRegister(src, ty, mcv);
3480 return self.genSetStack(src, ty, stack_offset, MCValue{ .register = reg });3485 return self.genSetStack(src, ty, stack_offset, MCValue{ .register = reg });
3481 },3486 },
3482 .embedded_in_code => |code_offset| {3487 .embedded_in_code => {
3483 return self.fail(src, "TODO implement set stack variable from embedded_in_code", .{});3488 return self.fail(src, "TODO implement set stack variable from embedded_in_code", .{});
3484 },3489 },
3485 .register => |reg| {3490 .register => |reg| {
...@@ -3511,7 +3516,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -3511,7 +3516,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
3511 else => return self.fail(src, "TODO implement storing other types abi_size={}", .{abi_size}),3516 else => return self.fail(src, "TODO implement storing other types abi_size={}", .{abi_size}),
3512 }3517 }
3513 },3518 },
3514 .memory => |vaddr| {3519 .memory => {
3515 return self.fail(src, "TODO implement set stack variable from memory vaddr", .{});3520 return self.fail(src, "TODO implement set stack variable from memory vaddr", .{});
3516 },3521 },
3517 .stack_offset => |off| {3522 .stack_offset => |off| {
...@@ -3842,6 +3847,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -3842,6 +3847,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
3842 );3847 );
3843 },3848 },
3844 .compare_flags_signed => |op| {3849 .compare_flags_signed => |op| {
3850 _ = op;
3845 return self.fail(src, "TODO set register with compare flags value (signed)", .{});3851 return self.fail(src, "TODO set register with compare flags value (signed)", .{});
3846 },3852 },
3847 .immediate => |x| {3853 .immediate => |x| {
...@@ -4460,6 +4466,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -4460,6 +4466,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
4460 dummy,4466 dummy,
44614467
4462 pub fn allocIndex(self: Register) ?u4 {4468 pub fn allocIndex(self: Register) ?u4 {
4469 _ = self;
4463 return null;4470 return null;
4464 }4471 }
4465 };4472 };
src/codegen/arm.zig+1-1
...@@ -674,7 +674,7 @@ pub const Instruction = union(enum) {...@@ -674,7 +674,7 @@ pub const Instruction = union(enum) {
674 };674 };
675 const imm4h: u4 = switch (offset) {675 const imm4h: u4 = switch (offset) {
676 .immediate => |imm| @truncate(u4, imm >> 4),676 .immediate => |imm| @truncate(u4, imm >> 4),
677 .register => |reg| 0b0000,677 .register => 0b0000,
678 };678 };
679679
680 return Instruction{680 return Instruction{
src/codegen/c.zig+9
...@@ -47,6 +47,8 @@ fn formatTypeAsCIdentifier(...@@ -47,6 +47,8 @@ fn formatTypeAsCIdentifier(
47 options: std.fmt.FormatOptions,47 options: std.fmt.FormatOptions,
48 writer: anytype,48 writer: anytype,
49) !void {49) !void {
50 _ = fmt;
51 _ = options;
50 var buffer = [1]u8{0} ** 128;52 var buffer = [1]u8{0} ** 128;
51 // We don't care if it gets cut off, it's still more unique than a number53 // We don't care if it gets cut off, it's still more unique than a number
52 var buf = std.fmt.bufPrint(&buffer, "{}", .{data}) catch &buffer;54 var buf = std.fmt.bufPrint(&buffer, "{}", .{data}) catch &buffer;
...@@ -63,6 +65,8 @@ fn formatIdent(...@@ -63,6 +65,8 @@ fn formatIdent(
63 options: std.fmt.FormatOptions,65 options: std.fmt.FormatOptions,
64 writer: anytype,66 writer: anytype,
65) !void {67) !void {
68 _ = fmt;
69 _ = options;
66 for (ident) |c, i| {70 for (ident) |c, i| {
67 switch (c) {71 switch (c) {
68 'a'...'z', 'A'...'Z', '_' => try writer.writeByte(c),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,6 +751,7 @@ pub fn genBody(o: *Object, body: ir.Body) error{ AnalysisFail, OutOfMemory }!voi
747}751}
748752
749fn genVarPtr(o: *Object, inst: *Inst.VarPtr) !CValue {753fn genVarPtr(o: *Object, inst: *Inst.VarPtr) !CValue {
754 _ = o;
750 return CValue{ .decl_ref = inst.variable.owner_decl };755 return CValue{ .decl_ref = inst.variable.owner_decl };
751}756}
752757
...@@ -937,6 +942,8 @@ fn genCall(o: *Object, inst: *Inst.Call) !CValue {...@@ -937,6 +942,8 @@ fn genCall(o: *Object, inst: *Inst.Call) !CValue {
937}942}
938943
939fn genDbgStmt(o: *Object, inst: *Inst.DbgStmt) !CValue {944fn genDbgStmt(o: *Object, inst: *Inst.DbgStmt) !CValue {
945 _ = o;
946 _ = inst;
940 // TODO emit #line directive here with line number and filename947 // TODO emit #line directive here with line number and filename
941 return CValue.none;948 return CValue.none;
942}949}
...@@ -1016,11 +1023,13 @@ fn genBitcast(o: *Object, inst: *Inst.UnOp) !CValue {...@@ -1016,11 +1023,13 @@ fn genBitcast(o: *Object, inst: *Inst.UnOp) !CValue {
1016}1023}
10171024
1018fn genBreakpoint(o: *Object, inst: *Inst.NoOp) !CValue {1025fn genBreakpoint(o: *Object, inst: *Inst.NoOp) !CValue {
1026 _ = inst;
1019 try o.writer().writeAll("zig_breakpoint();\n");1027 try o.writer().writeAll("zig_breakpoint();\n");
1020 return CValue.none;1028 return CValue.none;
1021}1029}
10221030
1023fn genUnreach(o: *Object, inst: *Inst.NoOp) !CValue {1031fn genUnreach(o: *Object, inst: *Inst.NoOp) !CValue {
1032 _ = inst;
1024 try o.writer().writeAll("zig_unreachable();\n");1033 try o.writer().writeAll("zig_unreachable();\n");
1025 return CValue.none;1034 return CValue.none;
1026}1035}
src/codegen/llvm.zig+4
...@@ -154,6 +154,7 @@ pub const Object = struct {...@@ -154,6 +154,7 @@ pub const Object = struct {
154 object_pathZ: [:0]const u8,154 object_pathZ: [:0]const u8,
155155
156 pub fn create(allocator: *Allocator, sub_path: []const u8, options: link.Options) !*Object {156 pub fn create(allocator: *Allocator, sub_path: []const u8, options: link.Options) !*Object {
157 _ = sub_path;
157 const self = try allocator.create(Object);158 const self = try allocator.create(Object);
158 errdefer allocator.destroy(self);159 errdefer allocator.destroy(self);
159160
...@@ -742,6 +743,7 @@ pub const FuncGen = struct {...@@ -742,6 +743,7 @@ pub const FuncGen = struct {
742 }743 }
743744
744 fn genRetVoid(self: *FuncGen, inst: *Inst.NoOp) ?*const llvm.Value {745 fn genRetVoid(self: *FuncGen, inst: *Inst.NoOp) ?*const llvm.Value {
746 _ = inst;
745 _ = self.builder.buildRetVoid();747 _ = self.builder.buildRetVoid();
746 return null;748 return null;
747 }749 }
...@@ -873,6 +875,7 @@ pub const FuncGen = struct {...@@ -873,6 +875,7 @@ pub const FuncGen = struct {
873 }875 }
874876
875 fn genUnreach(self: *FuncGen, inst: *Inst.NoOp) ?*const llvm.Value {877 fn genUnreach(self: *FuncGen, inst: *Inst.NoOp) ?*const llvm.Value {
878 _ = inst;
876 _ = self.builder.buildUnreachable();879 _ = self.builder.buildUnreachable();
877 return null;880 return null;
878 }881 }
...@@ -1013,6 +1016,7 @@ pub const FuncGen = struct {...@@ -1013,6 +1016,7 @@ pub const FuncGen = struct {
1013 }1016 }
10141017
1015 fn genBreakpoint(self: *FuncGen, inst: *Inst.NoOp) !?*const llvm.Value {1018 fn genBreakpoint(self: *FuncGen, inst: *Inst.NoOp) !?*const llvm.Value {
1019 _ = inst;
1016 const llvn_fn = self.getIntrinsic("llvm.debugtrap");1020 const llvn_fn = self.getIntrinsic("llvm.debugtrap");
1017 _ = self.builder.buildCall(llvn_fn, null, 0, "");1021 _ = self.builder.buildCall(llvn_fn, null, 0, "");
1018 return null;1022 return null;
src/codegen/wasm.zig+7-3
...@@ -702,7 +702,7 @@ pub const Context = struct {...@@ -702,7 +702,7 @@ pub const Context = struct {
702 try writer.writeByte(wasm.valtype(.i32)); // error code is always an i32 integer.702 try writer.writeByte(wasm.valtype(.i32)); // error code is always an i32 integer.
703 try writer.writeByte(val_type);703 try writer.writeByte(val_type);
704 },704 },
705 else => |ret_type| {705 else => {
706 try leb.writeULEB128(writer, @as(u32, 1));706 try leb.writeULEB128(writer, @as(u32, 1));
707 // Can we maybe get the source index of the return type?707 // Can we maybe get the source index of the return type?
708 const val_type = try self.genValtype(.{ .node_offset = 0 }, return_type);708 const val_type = try self.genValtype(.{ .node_offset = 0 }, return_type);
...@@ -721,7 +721,7 @@ pub const Context = struct {...@@ -721,7 +721,7 @@ pub const Context = struct {
721 // TODO: check for and handle death of instructions721 // TODO: check for and handle death of instructions
722 const mod_fn = blk: {722 const mod_fn = blk: {
723 if (typed_value.val.castTag(.function)) |func| break :blk func.data;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 functions724 if (typed_value.val.castTag(.extern_fn)) |_| return Result.appended; // don't need code body for extern functions
725 unreachable;725 unreachable;
726 };726 };
727727
...@@ -910,7 +910,7 @@ pub const Context = struct {...@@ -910,7 +910,7 @@ pub const Context = struct {
910 },910 },
911 else => unreachable,911 else => unreachable,
912 },912 },
913 .local => |local| {913 .local => {
914 try self.emitWValue(rhs);914 try self.emitWValue(rhs);
915 try writer.writeByte(wasm.opcode(.local_set));915 try writer.writeByte(wasm.opcode(.local_set));
916 try leb.writeULEB128(writer, lhs.local);916 try leb.writeULEB128(writer, lhs.local);
...@@ -925,6 +925,7 @@ pub const Context = struct {...@@ -925,6 +925,7 @@ pub const Context = struct {
925 }925 }
926926
927 fn genArg(self: *Context, inst: *Inst.Arg) InnerError!WValue {927 fn genArg(self: *Context, inst: *Inst.Arg) InnerError!WValue {
928 _ = inst;
928 // arguments share the index with locals929 // arguments share the index with locals
929 defer self.local_index += 1;930 defer self.local_index += 1;
930 return WValue{ .local = self.local_index };931 return WValue{ .local = self.local_index };
...@@ -1213,12 +1214,15 @@ pub const Context = struct {...@@ -1213,12 +1214,15 @@ pub const Context = struct {
1213 }1214 }
12141215
1215 fn genBreakpoint(self: *Context, breakpoint: *Inst.NoOp) InnerError!WValue {1216 fn genBreakpoint(self: *Context, breakpoint: *Inst.NoOp) InnerError!WValue {
1217 _ = self;
1218 _ = breakpoint;
1216 // unsupported by wasm itself. Can be implemented once we support DWARF1219 // unsupported by wasm itself. Can be implemented once we support DWARF
1217 // for wasm1220 // for wasm
1218 return .none;1221 return .none;
1219 }1222 }
12201223
1221 fn genUnreachable(self: *Context, unreach: *Inst.NoOp) InnerError!WValue {1224 fn genUnreachable(self: *Context, unreach: *Inst.NoOp) InnerError!WValue {
1225 _ = unreach;
1222 try self.code.append(wasm.opcode(.@"unreachable"));1226 try self.code.append(wasm.opcode(.@"unreachable"));
1223 return .none;1227 return .none;
1224 }1228 }
src/link.zig+1-1
...@@ -517,7 +517,7 @@ pub const File = struct {...@@ -517,7 +517,7 @@ pub const File = struct {
517 .target = base.options.target,517 .target = base.options.target,
518 .output_mode = .Obj,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 const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename});521 const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename});
522 break :blk full_obj_path;522 break :blk full_obj_path;
523 }523 }
src/link/C.zig+14-2
...@@ -76,7 +76,12 @@ pub fn deinit(self: *C) void {...@@ -76,7 +76,12 @@ pub fn deinit(self: *C) void {
76 self.decl_table.deinit(self.base.allocator);76 self.decl_table.deinit(self.base.allocator);
77}77}
7878
79pub fn allocateDeclIndexes(self: *C, decl: *Module.Decl) !void {}79pub fn allocateDeclIndexes(self: *C, decl: *Module.Decl) !void {
80 if (false) {
81 self;
82 decl;
83 }
84}
8085
81pub fn freeDecl(self: *C, decl: *Module.Decl) void {86pub fn freeDecl(self: *C, decl: *Module.Decl) void {
82 _ = self.decl_table.swapRemove(decl);87 _ = self.decl_table.swapRemove(decl);
...@@ -307,4 +312,11 @@ pub fn updateDeclExports(...@@ -307,4 +312,11 @@ pub fn updateDeclExports(
307 module: *Module,312 module: *Module,
308 decl: *Module.Decl,313 decl: *Module.Decl,
309 exports: []const *Module.Export,314 exports: []const *Module.Export,
310) !void {}315) !void {
316 if (false) {
317 exports;
318 decl;
319 module;
320 self;
321 }
322}
src/link/Coff.zig+4-1
...@@ -831,7 +831,7 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void {...@@ -831,7 +831,7 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void {
831 .target = self.base.options.target,831 .target = self.base.options.target,
832 .output_mode = .Obj,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 const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename});835 const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename});
836 break :blk full_obj_path;836 break :blk full_obj_path;
837 }837 }
...@@ -1340,6 +1340,9 @@ pub fn getDeclVAddr(self: *Coff, decl: *const Module.Decl) u64 {...@@ -1340,6 +1340,9 @@ pub fn getDeclVAddr(self: *Coff, decl: *const Module.Decl) u64 {
1340}1340}
13411341
1342pub fn updateDeclLineNumber(self: *Coff, module: *Module, decl: *Module.Decl) !void {1342pub fn updateDeclLineNumber(self: *Coff, module: *Module, decl: *Module.Decl) !void {
1343 _ = self;
1344 _ = module;
1345 _ = decl;
1343 // TODO Implement this1346 // TODO Implement this
1344}1347}
13451348
src/link/Elf.zig+10-3
...@@ -1262,7 +1262,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {...@@ -1262,7 +1262,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
1262 .target = self.base.options.target,1262 .target = self.base.options.target,
1263 .output_mode = .Obj,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 const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename});1266 const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename});
1267 break :blk full_obj_path;1267 break :blk full_obj_path;
1268 }1268 }
...@@ -1938,6 +1938,11 @@ fn freeTextBlock(self: *Elf, text_block: *TextBlock) void {...@@ -1938,6 +1938,11 @@ fn freeTextBlock(self: *Elf, text_block: *TextBlock) void {
1938}1938}
19391939
1940fn shrinkTextBlock(self: *Elf, text_block: *TextBlock, new_block_size: u64) void {1940fn shrinkTextBlock(self: *Elf, text_block: *TextBlock, new_block_size: u64) void {
1941 if (false) {
1942 self;
1943 text_block;
1944 new_block_size;
1945 }
1941 // TODO check the new capacity, and if it crosses the size threshold into a big enough1946 // TODO check the new capacity, and if it crosses the size threshold into a big enough
1942 // capacity, insert a free list node for it.1947 // capacity, insert a free list node for it.
1943}1948}
...@@ -2706,6 +2711,7 @@ pub fn updateDeclExports(...@@ -2706,6 +2711,7 @@ pub fn updateDeclExports(
27062711
2707/// Must be called only after a successful call to `updateDecl`.2712/// Must be called only after a successful call to `updateDecl`.
2708pub fn updateDeclLineNumber(self: *Elf, module: *Module, decl: *const Module.Decl) !void {2713pub fn updateDeclLineNumber(self: *Elf, module: *Module, decl: *const Module.Decl) !void {
2714 _ = module;
2709 const tracy = trace(@src());2715 const tracy = trace(@src());
2710 defer tracy.end();2716 defer tracy.end();
27112717
...@@ -2979,6 +2985,7 @@ fn dbgLineNeededHeaderBytes(self: Elf) u32 {...@@ -2979,6 +2985,7 @@ fn dbgLineNeededHeaderBytes(self: Elf) u32 {
2979}2985}
29802986
2981fn dbgInfoNeededHeaderBytes(self: Elf) u32 {2987fn dbgInfoNeededHeaderBytes(self: Elf) u32 {
2988 _ = self;
2982 return 120;2989 return 120;
2983}2990}
29842991
...@@ -3372,7 +3379,7 @@ const CsuObjects = struct {...@@ -3372,7 +3379,7 @@ const CsuObjects = struct {
3372 if (result.crtend) |*obj| obj.* = try fs.path.join(arena, &[_][]const u8{ gcc_dir_path, obj.* });3379 if (result.crtend) |*obj| obj.* = try fs.path.join(arena, &[_][]const u8{ gcc_dir_path, obj.* });
3373 },3380 },
3374 else => {3381 else => {
3375 inline for (std.meta.fields(@TypeOf(result))) |f, i| {3382 inline for (std.meta.fields(@TypeOf(result))) |f| {
3376 if (@field(result, f.name)) |*obj| {3383 if (@field(result, f.name)) |*obj| {
3377 obj.* = try fs.path.join(arena, &[_][]const u8{ crt_dir_path, obj.* });3384 obj.* = try fs.path.join(arena, &[_][]const u8{ crt_dir_path, obj.* });
3378 }3385 }
...@@ -3380,7 +3387,7 @@ const CsuObjects = struct {...@@ -3380,7 +3387,7 @@ const CsuObjects = struct {
3380 },3387 },
3381 }3388 }
3382 } else {3389 } else {
3383 inline for (std.meta.fields(@TypeOf(result))) |f, i| {3390 inline for (std.meta.fields(@TypeOf(result))) |f| {
3384 if (@field(result, f.name)) |*obj| {3391 if (@field(result, f.name)) |*obj| {
3385 if (comp.crt_files.get(obj.*)) |crtf| {3392 if (comp.crt_files.get(obj.*)) |crtf| {
3386 obj.* = crtf.full_object_path;3393 obj.* = crtf.full_object_path;
src/link/MachO.zig+5-1
...@@ -441,6 +441,7 @@ pub fn flush(self: *MachO, comp: *Compilation) !void {...@@ -441,6 +441,7 @@ pub fn flush(self: *MachO, comp: *Compilation) !void {
441}441}
442442
443pub fn flushModule(self: *MachO, comp: *Compilation) !void {443pub fn flushModule(self: *MachO, comp: *Compilation) !void {
444 _ = comp;
444 const tracy = trace(@src());445 const tracy = trace(@src());
445 defer tracy.end();446 defer tracy.end();
446447
...@@ -533,7 +534,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {...@@ -533,7 +534,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
533 .target = self.base.options.target,534 .target = self.base.options.target,
534 .output_mode = .Obj,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 const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename});538 const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename});
538 break :blk full_obj_path;539 break :blk full_obj_path;
539 }540 }
...@@ -1254,6 +1255,9 @@ fn freeTextBlock(self: *MachO, text_block: *TextBlock) void {...@@ -1254,6 +1255,9 @@ fn freeTextBlock(self: *MachO, text_block: *TextBlock) void {
1254}1255}
12551256
1256fn shrinkTextBlock(self: *MachO, text_block: *TextBlock, new_block_size: u64) void {1257fn shrinkTextBlock(self: *MachO, text_block: *TextBlock, new_block_size: u64) void {
1258 _ = self;
1259 _ = text_block;
1260 _ = new_block_size;
1257 // TODO check the new capacity, and if it crosses the size threshold into a big enough1261 // TODO check the new capacity, and if it crosses the size threshold into a big enough
1258 // capacity, insert a free list node for it.1262 // capacity, insert a free list node for it.
1259}1263}
src/link/MachO/DebugSymbols.zig+6
...@@ -899,6 +899,7 @@ fn writeStringTable(self: *DebugSymbols) !void {...@@ -899,6 +899,7 @@ fn writeStringTable(self: *DebugSymbols) !void {
899}899}
900900
901pub fn updateDeclLineNumber(self: *DebugSymbols, module: *Module, decl: *const Module.Decl) !void {901pub fn updateDeclLineNumber(self: *DebugSymbols, module: *Module, decl: *const Module.Decl) !void {
902 _ = module;
902 const tracy = trace(@src());903 const tracy = trace(@src());
903 defer tracy.end();904 defer tracy.end();
904905
...@@ -926,6 +927,8 @@ pub fn initDeclDebugBuffers(...@@ -926,6 +927,8 @@ pub fn initDeclDebugBuffers(
926 module: *Module,927 module: *Module,
927 decl: *Module.Decl,928 decl: *Module.Decl,
928) !DeclDebugBuffers {929) !DeclDebugBuffers {
930 _ = self;
931 _ = module;
929 const tracy = trace(@src());932 const tracy = trace(@src());
930 defer tracy.end();933 defer tracy.end();
931934
...@@ -1188,6 +1191,7 @@ fn addDbgInfoType(...@@ -1188,6 +1191,7 @@ fn addDbgInfoType(
1188 dbg_info_buffer: *std.ArrayList(u8),1191 dbg_info_buffer: *std.ArrayList(u8),
1189 target: std.Target,1192 target: std.Target,
1190) !void {1193) !void {
1194 _ = self;
1191 switch (ty.zigTypeTag()) {1195 switch (ty.zigTypeTag()) {
1192 .Void => unreachable,1196 .Void => unreachable,
1193 .NoReturn => unreachable,1197 .NoReturn => unreachable,
...@@ -1364,6 +1368,7 @@ fn getRelocDbgInfoSubprogramHighPC() u32 {...@@ -1364,6 +1368,7 @@ fn getRelocDbgInfoSubprogramHighPC() u32 {
1364}1368}
13651369
1366fn dbgLineNeededHeaderBytes(self: DebugSymbols, module: *Module) u32 {1370fn dbgLineNeededHeaderBytes(self: DebugSymbols, module: *Module) u32 {
1371 _ = self;
1367 const directory_entry_format_count = 1;1372 const directory_entry_format_count = 1;
1368 const file_name_entry_format_count = 1;1373 const file_name_entry_format_count = 1;
1369 const directory_count = 1;1374 const directory_count = 1;
...@@ -1378,6 +1383,7 @@ fn dbgLineNeededHeaderBytes(self: DebugSymbols, module: *Module) u32 {...@@ -1378,6 +1383,7 @@ fn dbgLineNeededHeaderBytes(self: DebugSymbols, module: *Module) u32 {
1378}1383}
13791384
1380fn dbgInfoNeededHeaderBytes(self: DebugSymbols) u32 {1385fn dbgInfoNeededHeaderBytes(self: DebugSymbols) u32 {
1386 _ = self;
1381 return 120;1387 return 120;
1382}1388}
13831389
src/link/MachO/Zld.zig+4-3
...@@ -108,6 +108,7 @@ const TlvOffset = struct {...@@ -108,6 +108,7 @@ const TlvOffset = struct {
108 offset: u64,108 offset: u64,
109109
110 fn cmp(context: void, a: TlvOffset, b: TlvOffset) bool {110 fn cmp(context: void, a: TlvOffset, b: TlvOffset) bool {
111 _ = context;
111 return a.source_addr < b.source_addr;112 return a.source_addr < b.source_addr;
112 }113 }
113};114};
...@@ -437,7 +438,7 @@ fn updateMetadata(self: *Zld) !void {...@@ -437,7 +438,7 @@ fn updateMetadata(self: *Zld) !void {
437 const data_seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;438 const data_seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
438439
439 // Create missing metadata440 // Create missing metadata
440 for (object.sections.items) |sect, sect_id| {441 for (object.sections.items) |sect| {
441 const segname = sect.segname();442 const segname = sect.segname();
442 const sectname = sect.sectname();443 const sectname = sect.sectname();
443444
...@@ -1373,7 +1374,7 @@ fn allocateTentativeSymbols(self: *Zld) !void {...@@ -1373,7 +1374,7 @@ fn allocateTentativeSymbols(self: *Zld) !void {
1373 }1374 }
13741375
1375 // Convert tentative definitions into regular symbols.1376 // Convert tentative definitions into regular symbols.
1376 for (self.tentatives.values()) |sym, i| {1377 for (self.tentatives.values()) |sym| {
1377 const tent = sym.cast(Symbol.Tentative) orelse unreachable;1378 const tent = sym.cast(Symbol.Tentative) orelse unreachable;
1378 const reg = try self.allocator.create(Symbol.Regular);1379 const reg = try self.allocator.create(Symbol.Regular);
1379 errdefer self.allocator.destroy(reg);1380 errdefer self.allocator.destroy(reg);
...@@ -1758,7 +1759,7 @@ fn resolveSymbolsInObject(self: *Zld, object: *Object) !void {...@@ -1758,7 +1759,7 @@ fn resolveSymbolsInObject(self: *Zld, object: *Object) !void {
17581759
1759 t_sym.alias = sym;1760 t_sym.alias = sym;
1760 sym_ptr.* = sym;1761 sym_ptr.* = sym;
1761 } else if (sym.cast(Symbol.Unresolved)) |und| {1762 } else if (sym.cast(Symbol.Unresolved)) |_| {
1762 if (self.globals.get(sym.name)) |g_sym| {1763 if (self.globals.get(sym.name)) |g_sym| {
1763 sym.alias = g_sym;1764 sym.alias = g_sym;
1764 continue;1765 continue;
src/link/MachO/bind.zig+1
...@@ -10,6 +10,7 @@ pub const Pointer = struct {...@@ -10,6 +10,7 @@ pub const Pointer = struct {
10};10};
1111
12pub fn pointerCmp(context: void, a: Pointer, b: Pointer) bool {12pub fn pointerCmp(context: void, a: Pointer, b: Pointer) bool {
13 _ = context;
13 if (a.segment_id < b.segment_id) return true;14 if (a.segment_id < b.segment_id) return true;
14 if (a.segment_id == b.segment_id) {15 if (a.segment_id == b.segment_id) {
15 return a.offset < b.offset;16 return a.offset < b.offset;
src/link/SpirV.zig+9-1
...@@ -102,6 +102,7 @@ pub fn deinit(self: *SpirV) void {...@@ -102,6 +102,7 @@ pub fn deinit(self: *SpirV) void {
102}102}
103103
104pub fn updateDecl(self: *SpirV, module: *Module, decl: *Module.Decl) !void {104pub fn updateDecl(self: *SpirV, module: *Module, decl: *Module.Decl) !void {
105 _ = module;
105 // Keep track of all decls so we can iterate over them on flush().106 // Keep track of all decls so we can iterate over them on flush().
106 _ = try self.decl_table.getOrPut(self.base.allocator, decl);107 _ = try self.decl_table.getOrPut(self.base.allocator, decl);
107}108}
...@@ -111,7 +112,14 @@ pub fn updateDeclExports(...@@ -111,7 +112,14 @@ pub fn updateDeclExports(
111 module: *Module,112 module: *Module,
112 decl: *const Module.Decl,113 decl: *const Module.Decl,
113 exports: []const *Module.Export,114 exports: []const *Module.Export,
114) !void {}115) !void {
116 if (false) {
117 self;
118 module;
119 decl;
120 exports;
121 }
122}
115123
116pub fn freeDecl(self: *SpirV, decl: *Module.Decl) void {124pub fn freeDecl(self: *SpirV, decl: *Module.Decl) void {
117 assert(self.decl_table.swapRemove(decl));125 assert(self.decl_table.swapRemove(decl));
src/link/Wasm.zig+11-3
...@@ -216,7 +216,7 @@ pub fn updateDecl(self: *Wasm, module: *Module, decl: *Module.Decl) !void {...@@ -216,7 +216,7 @@ pub fn updateDecl(self: *Wasm, module: *Module, decl: *Module.Decl) !void {
216 try module.failed_decls.put(module.gpa, decl, context.err_msg);216 try module.failed_decls.put(module.gpa, decl, context.err_msg);
217 return;217 return;
218 },218 },
219 else => |e| return err,219 else => |e| return e,
220 };220 };
221221
222 const code: []const u8 = switch (result) {222 const code: []const u8 = switch (result) {
...@@ -258,7 +258,14 @@ pub fn updateDeclExports(...@@ -258,7 +258,14 @@ pub fn updateDeclExports(
258 module: *Module,258 module: *Module,
259 decl: *const Module.Decl,259 decl: *const Module.Decl,
260 exports: []const *Module.Export,260 exports: []const *Module.Export,
261) !void {}261) !void {
262 if (false) {
263 self;
264 module;
265 decl;
266 exports;
267 }
268}
262269
263pub fn freeDecl(self: *Wasm, decl: *Module.Decl) void {270pub fn freeDecl(self: *Wasm, decl: *Module.Decl) void {
264 if (self.getFuncidx(decl)) |func_idx| {271 if (self.getFuncidx(decl)) |func_idx| {
...@@ -300,6 +307,7 @@ pub fn flush(self: *Wasm, comp: *Compilation) !void {...@@ -300,6 +307,7 @@ pub fn flush(self: *Wasm, comp: *Compilation) !void {
300}307}
301308
302pub fn flushModule(self: *Wasm, comp: *Compilation) !void {309pub fn flushModule(self: *Wasm, comp: *Compilation) !void {
310 _ = comp;
303 const tracy = trace(@src());311 const tracy = trace(@src());
304 defer tracy.end();312 defer tracy.end();
305313
...@@ -557,7 +565,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void {...@@ -557,7 +565,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void {
557 .target = self.base.options.target,565 .target = self.base.options.target,
558 .output_mode = .Obj,566 .output_mode = .Obj,
559 });567 });
560 const o_directory = self.base.options.module.?.zig_cache_artifact_directory;568 const o_directory = module.zig_cache_artifact_directory;
561 const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename});569 const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename});
562 break :blk full_obj_path;570 break :blk full_obj_path;
563 }571 }
src/main.zig+2-2
...@@ -500,7 +500,7 @@ const Emit = union(enum) {...@@ -500,7 +500,7 @@ const Emit = union(enum) {
500};500};
501501
502fn optionalBoolEnvVar(arena: *Allocator, name: []const u8) !bool {502fn optionalBoolEnvVar(arena: *Allocator, name: []const u8) !bool {
503 if (std.process.getEnvVarOwned(arena, name)) |value| {503 if (std.process.getEnvVarOwned(arena, name)) |_| {
504 return true;504 return true;
505 } else |err| switch (err) {505 } else |err| switch (err) {
506 error.EnvironmentVariableNotFound => return false,506 error.EnvironmentVariableNotFound => return false,
...@@ -2560,7 +2560,7 @@ pub const usage_init =...@@ -2560,7 +2560,7 @@ pub const usage_init =
2560;2560;
25612561
2562pub fn cmdInit(2562pub fn cmdInit(
2563 gpa: *Allocator,2563 _: *Allocator,
2564 arena: *Allocator,2564 arena: *Allocator,
2565 args: []const []const u8,2565 args: []const []const u8,
2566 output_mode: std.builtin.OutputMode,2566 output_mode: std.builtin.OutputMode,
src/print_env.zig+1
...@@ -5,6 +5,7 @@ const Allocator = std.mem.Allocator;...@@ -5,6 +5,7 @@ const Allocator = std.mem.Allocator;
5const fatal = @import("main.zig").fatal;5const fatal = @import("main.zig").fatal;
66
7pub fn cmdEnv(gpa: *Allocator, args: []const []const u8, stdout: std.fs.File.Writer) !void {7pub fn cmdEnv(gpa: *Allocator, args: []const []const u8, stdout: std.fs.File.Writer) !void {
8 _ = args;
8 const self_exe_path = try std.fs.selfExePathAlloc(gpa);9 const self_exe_path = try std.fs.selfExePathAlloc(gpa);
9 defer gpa.free(self_exe_path);10 defer gpa.free(self_exe_path);
1011
src/print_targets.zig+1
...@@ -17,6 +17,7 @@ pub fn cmdTargets(...@@ -17,6 +17,7 @@ pub fn cmdTargets(
17 stdout: anytype,17 stdout: anytype,
18 native_target: Target,18 native_target: Target,
19) !void {19) !void {
20 _ = args;
20 var zig_lib_directory = introspect.findZigLibDir(allocator) catch |err| {21 var zig_lib_directory = introspect.findZigLibDir(allocator) catch |err| {
21 fatal("unable to find zig installation directory: {s}\n", .{@errorName(err)});22 fatal("unable to find zig installation directory: {s}\n", .{@errorName(err)});
22 };23 };
src/register_manager.zig+2
...@@ -265,6 +265,8 @@ fn MockFunction(comptime Register: type) type {...@@ -265,6 +265,8 @@ fn MockFunction(comptime Register: type) type {
265 }265 }
266266
267 pub fn spillInstruction(self: *Self, src: LazySrcLoc, reg: Register, inst: *ir.Inst) !void {267 pub fn spillInstruction(self: *Self, src: LazySrcLoc, reg: Register, inst: *ir.Inst) !void {
268 _ = src;
269 _ = inst;
268 try self.spilled.append(self.allocator, reg);270 try self.spilled.append(self.allocator, reg);
269 }271 }
270 };272 };
src/stage1.zig+2
...@@ -407,6 +407,8 @@ export fn stage2_add_link_lib(...@@ -407,6 +407,8 @@ export fn stage2_add_link_lib(
407 symbol_name_ptr: [*c]const u8,407 symbol_name_ptr: [*c]const u8,
408 symbol_name_len: usize,408 symbol_name_len: usize,
409) ?[*:0]const u8 {409) ?[*:0]const u8 {
410 _ = symbol_name_len;
411 _ = symbol_name_ptr;
410 const comp = @intToPtr(*Compilation, stage1.userdata);412 const comp = @intToPtr(*Compilation, stage1.userdata);
411 const lib_name = std.ascii.allocLowerString(comp.gpa, lib_name_ptr[0..lib_name_len]) catch return "out of memory";413 const lib_name = std.ascii.allocLowerString(comp.gpa, lib_name_ptr[0..lib_name_len]) catch return "out of memory";
412 const target = comp.getTarget();414 const target = comp.getTarget();
src/test.zig+3
...@@ -70,6 +70,8 @@ const ErrorMsg = union(enum) {...@@ -70,6 +70,8 @@ const ErrorMsg = union(enum) {
70 options: std.fmt.FormatOptions,70 options: std.fmt.FormatOptions,
71 writer: anytype,71 writer: anytype,
72 ) !void {72 ) !void {
73 _ = fmt;
74 _ = options;
73 switch (self) {75 switch (self) {
74 .src => |src| {76 .src => |src| {
75 return writer.print("{s}:{d}:{d}: {s}: {s}", .{77 return writer.print("{s}:{d}:{d}: {s}: {s}", .{
...@@ -592,6 +594,7 @@ pub const TestContext = struct {...@@ -592,6 +594,7 @@ pub const TestContext = struct {
592 thread_pool: *ThreadPool,594 thread_pool: *ThreadPool,
593 global_cache_directory: Compilation.Directory,595 global_cache_directory: Compilation.Directory,
594 ) !void {596 ) !void {
597 _ = self;
595 const target_info = try std.zig.system.NativeTargetInfo.detect(allocator, case.target);598 const target_info = try std.zig.system.NativeTargetInfo.detect(allocator, case.target);
596 const target = target_info.target;599 const target = target_info.target;
597600
src/tracy.zig+3-1
...@@ -28,7 +28,9 @@ pub const ___tracy_c_zone_context = extern struct {...@@ -28,7 +28,9 @@ pub const ___tracy_c_zone_context = extern struct {
28};28};
2929
30pub const Ctx = if (enable) ___tracy_c_zone_context else struct {30pub 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};
3335
34pub inline fn trace(comptime src: std.builtin.SourceLocation) Ctx {36pub inline fn trace(comptime src: std.builtin.SourceLocation) Ctx {
src/translate_c.zig+15-5
...@@ -206,6 +206,7 @@ const Scope = struct {...@@ -206,6 +206,7 @@ const Scope = struct {
206 }206 }
207207
208 fn findBlockReturnType(inner: *Scope, c: *Context) clang.QualType {208 fn findBlockReturnType(inner: *Scope, c: *Context) clang.QualType {
209 _ = c;
209 var scope = inner;210 var scope = inner;
210 while (true) {211 while (true) {
211 switch (scope.id) {212 switch (scope.id) {
...@@ -601,7 +602,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const clang.FunctionDecl) Error!void {...@@ -601,7 +602,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const clang.FunctionDecl) Error!void {
601 var scope = &block_scope.base;602 var scope = &block_scope.base;
602603
603 var param_id: c_uint = 0;604 var param_id: c_uint = 0;
604 for (proto_node.data.params) |*param, i| {605 for (proto_node.data.params) |*param| {
605 const param_name = param.name orelse {606 const param_name = param.name orelse {
606 proto_node.data.is_extern = true;607 proto_node.data.is_extern = true;
607 proto_node.data.is_export = false;608 proto_node.data.is_export = false;
...@@ -785,7 +786,7 @@ const builtin_typedef_map = std.ComptimeStringMap([]const u8, .{...@@ -785,7 +786,7 @@ const builtin_typedef_map = std.ComptimeStringMap([]const u8, .{
785});786});
786787
787fn transTypeDef(c: *Context, scope: *Scope, typedef_decl: *const clang.TypedefNameDecl) Error!void {788fn 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 return; // Avoid processing this decl twice790 return; // Avoid processing this decl twice
790 const toplevel = scope.id == .root;791 const toplevel = scope.id == .root;
791 const bs: *Scope.Block = if (!toplevel) try scope.findBlockScope(c) else undefined;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,7 +936,7 @@ fn hasFlexibleArrayField(c: *Context, record_def: *const clang.RecordDecl) bool
935}936}
936937
937fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordDecl) Error!void {938fn 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 return; // Avoid processing this decl twice940 return; // Avoid processing this decl twice
940 const record_loc = record_decl.getLocation();941 const record_loc = record_decl.getLocation();
941 const toplevel = scope.id == .root;942 const toplevel = scope.id == .root;
...@@ -1080,7 +1081,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD...@@ -1080,7 +1081,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD
1080}1081}
10811082
1082fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const clang.EnumDecl) Error!void {1083fn 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 return; // Avoid processing this decl twice1085 return; // Avoid processing this decl twice
1085 const enum_loc = enum_decl.getLocation();1086 const enum_loc = enum_decl.getLocation();
1086 const toplevel = scope.id == .root;1087 const toplevel = scope.id == .root;
...@@ -1312,6 +1313,7 @@ fn transConvertVectorExpr(...@@ -1312,6 +1313,7 @@ fn transConvertVectorExpr(
1312 source_loc: clang.SourceLocation,1313 source_loc: clang.SourceLocation,
1313 expr: *const clang.ConvertVectorExpr,1314 expr: *const clang.ConvertVectorExpr,
1314) TransError!Node {1315) TransError!Node {
1316 _ = source_loc;
1315 const base_stmt = @ptrCast(*const clang.Stmt, expr);1317 const base_stmt = @ptrCast(*const clang.Stmt, expr);
13161318
1317 var block_scope = try Scope.Block.init(c, scope, true);1319 var block_scope = try Scope.Block.init(c, scope, true);
...@@ -1433,6 +1435,7 @@ fn transSimpleOffsetOfExpr(...@@ -1433,6 +1435,7 @@ fn transSimpleOffsetOfExpr(
1433 scope: *Scope,1435 scope: *Scope,
1434 expr: *const clang.OffsetOfExpr,1436 expr: *const clang.OffsetOfExpr,
1435) TransError!Node {1437) TransError!Node {
1438 _ = scope;
1436 assert(expr.getNumComponents() == 1);1439 assert(expr.getNumComponents() == 1);
1437 const component = expr.getComponent(0);1440 const component = expr.getComponent(0);
1438 if (component.getKind() == .Field) {1441 if (component.getKind() == .Field) {
...@@ -2269,6 +2272,7 @@ fn transStringLiteralInitializer(...@@ -2269,6 +2272,7 @@ fn transStringLiteralInitializer(
2269/// both operands resolve to addresses. The C standard requires that both operands2272/// both operands resolve to addresses. The C standard requires that both operands
2270/// point to elements of the same array object, but we do not verify that here.2273/// point to elements of the same array object, but we do not verify that here.
2271fn cIsPointerDiffExpr(c: *Context, stmt: *const clang.BinaryOperator) bool {2274fn cIsPointerDiffExpr(c: *Context, stmt: *const clang.BinaryOperator) bool {
2275 _ = c;
2272 const lhs = @ptrCast(*const clang.Stmt, stmt.getLHS());2276 const lhs = @ptrCast(*const clang.Stmt, stmt.getLHS());
2273 const rhs = @ptrCast(*const clang.Stmt, stmt.getRHS());2277 const rhs = @ptrCast(*const clang.Stmt, stmt.getRHS());
2274 return stmt.getOpcode() == .Sub and2278 return stmt.getOpcode() == .Sub and
...@@ -2572,6 +2576,7 @@ fn transInitListExprVector(...@@ -2572,6 +2576,7 @@ fn transInitListExprVector(
2572 expr: *const clang.InitListExpr,2576 expr: *const clang.InitListExpr,
2573 ty: *const clang.Type,2577 ty: *const clang.Type,
2574) TransError!Node {2578) TransError!Node {
2579 _ = ty;
2575 const qt = getExprQualType(c, @ptrCast(*const clang.Expr, expr));2580 const qt = getExprQualType(c, @ptrCast(*const clang.Expr, expr));
2576 const vector_type = try transQualType(c, scope, qt, loc);2581 const vector_type = try transQualType(c, scope, qt, loc);
2577 const init_count = expr.getNumInits();2582 const init_count = expr.getNumInits();
...@@ -2721,6 +2726,7 @@ fn transImplicitValueInitExpr(...@@ -2721,6 +2726,7 @@ fn transImplicitValueInitExpr(
2721 expr: *const clang.Expr,2726 expr: *const clang.Expr,
2722 used: ResultUsed,2727 used: ResultUsed,
2723) TransError!Node {2728) TransError!Node {
2729 _ = used;
2724 const source_loc = expr.getBeginLoc();2730 const source_loc = expr.getBeginLoc();
2725 const qt = getExprQualType(c, expr);2731 const qt = getExprQualType(c, expr);
2726 const ty = qt.getTypePtr();2732 const ty = qt.getTypePtr();
...@@ -3407,6 +3413,7 @@ fn transUnaryExprOrTypeTraitExpr(...@@ -3407,6 +3413,7 @@ fn transUnaryExprOrTypeTraitExpr(
3407 stmt: *const clang.UnaryExprOrTypeTraitExpr,3413 stmt: *const clang.UnaryExprOrTypeTraitExpr,
3408 result_used: ResultUsed,3414 result_used: ResultUsed,
3409) TransError!Node {3415) TransError!Node {
3416 _ = result_used;
3410 const loc = stmt.getBeginLoc();3417 const loc = stmt.getBeginLoc();
3411 const type_node = try transQualType(c, scope, stmt.getTypeOfArgument(), loc);3418 const type_node = try transQualType(c, scope, stmt.getTypeOfArgument(), loc);
34123419
...@@ -3893,6 +3900,7 @@ fn maybeSuppressResult(...@@ -3893,6 +3900,7 @@ fn maybeSuppressResult(
3893 used: ResultUsed,3900 used: ResultUsed,
3894 result: Node,3901 result: Node,
3895) TransError!Node {3902) TransError!Node {
3903 _ = scope;
3896 if (used == .used) return result;3904 if (used == .used) return result;
3897 return Tag.discard.create(c.arena, result);3905 return Tag.discard.create(c.arena, result);
3898}3906}
...@@ -4337,7 +4345,7 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: Node, proto_alias:...@@ -4337,7 +4345,7 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: Node, proto_alias:
4337 var fn_params = std.ArrayList(ast.Payload.Param).init(c.gpa);4345 var fn_params = std.ArrayList(ast.Payload.Param).init(c.gpa);
4338 defer fn_params.deinit();4346 defer fn_params.deinit();
43394347
4340 for (proto_alias.data.params) |param, i| {4348 for (proto_alias.data.params) |param| {
4341 const param_name = param.name orelse4349 const param_name = param.name orelse
4342 try std.fmt.allocPrint(c.arena, "arg_{d}", .{c.getMangle()});4350 try std.fmt.allocPrint(c.arena, "arg_{d}", .{c.getMangle()});
43434351
...@@ -5653,6 +5661,7 @@ fn parseCSpecifierQualifierList(c: *Context, m: *MacroCtx, scope: *Scope, allow_...@@ -5653,6 +5661,7 @@ fn parseCSpecifierQualifierList(c: *Context, m: *MacroCtx, scope: *Scope, allow_
5653}5661}
56545662
5655fn parseCNumericType(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node {5663fn parseCNumericType(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node {
5664 _ = scope;
5656 const KwCounter = struct {5665 const KwCounter = struct {
5657 double: u8 = 0,5666 double: u8 = 0,
5658 long: u8 = 0,5667 long: u8 = 0,
...@@ -5754,6 +5763,7 @@ fn parseCNumericType(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node {...@@ -5754,6 +5763,7 @@ fn parseCNumericType(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node {
5754}5763}
57555764
5756fn parseCAbstractDeclarator(c: *Context, m: *MacroCtx, scope: *Scope, node: Node) ParseError!Node {5765fn parseCAbstractDeclarator(c: *Context, m: *MacroCtx, scope: *Scope, node: Node) ParseError!Node {
5766 _ = scope;
5757 switch (m.next().?) {5767 switch (m.next().?) {
5758 .Asterisk => {5768 .Asterisk => {
5759 // last token of `node`5769 // last token of `node`
src/type.zig+3
...@@ -600,9 +600,11 @@ pub const Type = extern union {...@@ -600,9 +600,11 @@ pub const Type = extern union {
600600
601 pub const HashContext = struct {601 pub const HashContext = struct {
602 pub fn hash(self: @This(), t: Type) u64 {602 pub fn hash(self: @This(), t: Type) u64 {
603 _ = self;
603 return t.hash();604 return t.hash();
604 }605 }
605 pub fn eql(self: @This(), a: Type, b: Type) bool {606 pub fn eql(self: @This(), a: Type, b: Type) bool {
607 _ = self;
606 return a.eql(b);608 return a.eql(b);
607 }609 }
608 };610 };
...@@ -777,6 +779,7 @@ pub const Type = extern union {...@@ -777,6 +779,7 @@ pub const Type = extern union {
777 options: std.fmt.FormatOptions,779 options: std.fmt.FormatOptions,
778 writer: anytype,780 writer: anytype,
779 ) @TypeOf(writer).Error!void {781 ) @TypeOf(writer).Error!void {
782 _ = options;
780 comptime assert(fmt.len == 0);783 comptime assert(fmt.len == 0);
781 var ty = start_type;784 var ty = start_type;
782 while (true) {785 while (true) {
src/value.zig+8
...@@ -626,6 +626,7 @@ pub const Value = extern union {...@@ -626,6 +626,7 @@ pub const Value = extern union {
626 return std.mem.dupe(allocator, u8, payload.data);626 return std.mem.dupe(allocator, u8, payload.data);
627 }627 }
628 if (self.castTag(.repeated)) |payload| {628 if (self.castTag(.repeated)) |payload| {
629 _ = payload;
629 @panic("TODO implement toAllocatedBytes for this Value tag");630 @panic("TODO implement toAllocatedBytes for this Value tag");
630 }631 }
631 if (self.castTag(.decl_ref)) |payload| {632 if (self.castTag(.decl_ref)) |payload| {
...@@ -747,6 +748,7 @@ pub const Value = extern union {...@@ -747,6 +748,7 @@ pub const Value = extern union {
747748
748 /// Asserts the type is an enum type.749 /// Asserts the type is an enum type.
749 pub fn toEnum(val: Value, enum_ty: Type, comptime E: type) E {750 pub fn toEnum(val: Value, enum_ty: Type, comptime E: type) E {
751 _ = enum_ty;
750 // TODO this needs to resolve other kinds of Value tags rather than752 // TODO this needs to resolve other kinds of Value tags rather than
751 // assuming the tag will be .enum_field_index.753 // assuming the tag will be .enum_field_index.
752 const field_index = val.castTag(.enum_field_index).?.data;754 const field_index = val.castTag(.enum_field_index).?.data;
...@@ -935,6 +937,7 @@ pub const Value = extern union {...@@ -935,6 +937,7 @@ pub const Value = extern union {
935 /// Converts an integer or a float to a float.937 /// Converts an integer or a float to a float.
936 /// Returns `error.Overflow` if the value does not fit in the new type.938 /// Returns `error.Overflow` if the value does not fit in the new type.
937 pub fn floatCast(self: Value, allocator: *Allocator, ty: Type, target: Target) !Value {939 pub fn floatCast(self: Value, allocator: *Allocator, ty: Type, target: Target) !Value {
940 _ = target;
938 switch (ty.tag()) {941 switch (ty.tag()) {
939 .f16 => {942 .f16 => {
940 @panic("TODO add __trunctfhf2 to compiler-rt");943 @panic("TODO add __trunctfhf2 to compiler-rt");
...@@ -1292,17 +1295,21 @@ pub const Value = extern union {...@@ -1292,17 +1295,21 @@ pub const Value = extern union {
12921295
1293 pub const ArrayHashContext = struct {1296 pub const ArrayHashContext = struct {
1294 pub fn hash(self: @This(), v: Value) u32 {1297 pub fn hash(self: @This(), v: Value) u32 {
1298 _ = self;
1295 return v.hash_u32();1299 return v.hash_u32();
1296 }1300 }
1297 pub fn eql(self: @This(), a: Value, b: Value) bool {1301 pub fn eql(self: @This(), a: Value, b: Value) bool {
1302 _ = self;
1298 return a.eql(b);1303 return a.eql(b);
1299 }1304 }
1300 };1305 };
1301 pub const HashContext = struct {1306 pub const HashContext = struct {
1302 pub fn hash(self: @This(), v: Value) u64 {1307 pub fn hash(self: @This(), v: Value) u64 {
1308 _ = self;
1303 return v.hash();1309 return v.hash();
1304 }1310 }
1305 pub fn eql(self: @This(), a: Value, b: Value) bool {1311 pub fn eql(self: @This(), a: Value, b: Value) bool {
1312 _ = self;
1306 return a.eql(b);1313 return a.eql(b);
1307 }1314 }
1308 };1315 };
...@@ -1345,6 +1352,7 @@ pub const Value = extern union {...@@ -1345,6 +1352,7 @@ pub const Value = extern union {
1345 }1352 }
13461353
1347 pub fn fieldValue(val: Value, allocator: *Allocator, index: usize) error{OutOfMemory}!Value {1354 pub fn fieldValue(val: Value, allocator: *Allocator, index: usize) error{OutOfMemory}!Value {
1355 _ = allocator;
1348 switch (val.tag()) {1356 switch (val.tag()) {
1349 .@"struct" => {1357 .@"struct" => {
1350 const field_values = val.castTag(.@"struct").?.data;1358 const field_values = val.castTag(.@"struct").?.data;
test/behavior/align.zig+1
...@@ -167,6 +167,7 @@ test "generic function with align param" {...@@ -167,6 +167,7 @@ test "generic function with align param" {
167}167}
168168
169fn whyWouldYouEverDoThis(comptime align_bytes: u8) align(align_bytes) u8 {169fn whyWouldYouEverDoThis(comptime align_bytes: u8) align(align_bytes) u8 {
170 _ = align_bytes;
170 return 0x1;171 return 0x1;
171}172}
172173
test/behavior/async_fn.zig+10
...@@ -133,6 +133,7 @@ test "@frameSize" {...@@ -133,6 +133,7 @@ test "@frameSize" {
133 other(1);133 other(1);
134 }134 }
135 fn other(param: i32) void {135 fn other(param: i32) void {
136 _ = param;
136 var local: i32 = undefined;137 var local: i32 = undefined;
137 _ = local;138 _ = local;
138 suspend {}139 suspend {}
...@@ -635,6 +636,8 @@ test "returning a const error from async function" {...@@ -635,6 +636,8 @@ test "returning a const error from async function" {
635 }636 }
636637
637 fn fetchUrl(unused: i32, url: []const u8) ![]u8 {638 fn fetchUrl(unused: i32, url: []const u8) ![]u8 {
639 _ = unused;
640 _ = url;
638 frame = @frame();641 frame = @frame();
639 suspend {}642 suspend {}
640 ok = true;643 ok = true;
...@@ -711,6 +714,7 @@ fn testAsyncAwaitTypicalUsage(...@@ -711,6 +714,7 @@ fn testAsyncAwaitTypicalUsage(
711714
712 var global_download_frame: anyframe = undefined;715 var global_download_frame: anyframe = undefined;
713 fn fetchUrl(allocator: *std.mem.Allocator, url: []const u8) anyerror![]u8 {716 fn fetchUrl(allocator: *std.mem.Allocator, url: []const u8) anyerror![]u8 {
717 _ = url;
714 const result = try std.mem.dupe(allocator, u8, "expected download text");718 const result = try std.mem.dupe(allocator, u8, "expected download text");
715 errdefer allocator.free(result);719 errdefer allocator.free(result);
716 if (suspend_download) {720 if (suspend_download) {
...@@ -724,6 +728,7 @@ fn testAsyncAwaitTypicalUsage(...@@ -724,6 +728,7 @@ fn testAsyncAwaitTypicalUsage(
724728
725 var global_file_frame: anyframe = undefined;729 var global_file_frame: anyframe = undefined;
726 fn readFile(allocator: *std.mem.Allocator, filename: []const u8) anyerror![]u8 {730 fn readFile(allocator: *std.mem.Allocator, filename: []const u8) anyerror![]u8 {
731 _ = filename;
727 const result = try std.mem.dupe(allocator, u8, "expected file text");732 const result = try std.mem.dupe(allocator, u8, "expected file text");
728 errdefer allocator.free(result);733 errdefer allocator.free(result);
729 if (suspend_file) {734 if (suspend_file) {
...@@ -1226,6 +1231,7 @@ test "suspend in while loop" {...@@ -1226,6 +1231,7 @@ test "suspend in while loop" {
1226 suspend {}1231 suspend {}
1227 return val;1232 return val;
1228 } else |err| {1233 } else |err| {
1234 err catch {};
1229 return 0;1235 return 0;
1230 }1236 }
1231 }1237 }
...@@ -1355,6 +1361,7 @@ test "async function passed 0-bit arg after non-0-bit arg" {...@@ -1355,6 +1361,7 @@ test "async function passed 0-bit arg after non-0-bit arg" {
1355 }1361 }
13561362
1357 fn bar(x: i32, args: anytype) anyerror!void {1363 fn bar(x: i32, args: anytype) anyerror!void {
1364 _ = args;
1358 global_frame = @frame();1365 global_frame = @frame();
1359 suspend {}1366 suspend {}
1360 global_int = x;1367 global_int = x;
...@@ -1650,6 +1657,8 @@ test "@asyncCall with pass-by-value arguments" {...@@ -1650,6 +1657,8 @@ test "@asyncCall with pass-by-value arguments" {
1650 pub const AT = [5]u8;1657 pub const AT = [5]u8;
16511658
1652 pub fn f(_fill0: u64, s: ST, _fill1: u64, a: AT, _fill2: u64) callconv(.Async) void {1659 pub fn f(_fill0: u64, s: ST, _fill1: u64, a: AT, _fill2: u64) callconv(.Async) void {
1660 _ = s;
1661 _ = a;
1653 // Check that the array and struct arguments passed by value don't1662 // Check that the array and struct arguments passed by value don't
1654 // end up overflowing the adjacent fields in the frame structure.1663 // end up overflowing the adjacent fields in the frame structure.
1655 expectEqual(F0, _fill0) catch @panic("test failure");1664 expectEqual(F0, _fill0) catch @panic("test failure");
...@@ -1677,6 +1686,7 @@ test "@asyncCall with arguments having non-standard alignment" {...@@ -1677,6 +1686,7 @@ test "@asyncCall with arguments having non-standard alignment" {
16771686
1678 const S = struct {1687 const S = struct {
1679 pub fn f(_fill0: u32, s: struct { x: u64 align(16) }, _fill1: u64) callconv(.Async) void {1688 pub fn f(_fill0: u32, s: struct { x: u64 align(16) }, _fill1: u64) callconv(.Async) void {
1689 _ = s;
1680 // The compiler inserts extra alignment for s, check that the1690 // The compiler inserts extra alignment for s, check that the
1681 // generated code picks the right slot for fill1.1691 // generated code picks the right slot for fill1.
1682 expectEqual(F0, _fill0) catch @panic("test failure");1692 expectEqual(F0, _fill0) catch @panic("test failure");
test/behavior/bugs/1310.zig+2
...@@ -16,6 +16,8 @@ pub const InvocationTable_ = struct_InvocationTable_;...@@ -16,6 +16,8 @@ pub const InvocationTable_ = struct_InvocationTable_;
16pub const VM_ = struct_VM_;16pub const VM_ = struct_VM_;
1717
18fn agent_callback(_vm: [*]VM, options: [*]u8) callconv(.C) i32 {18fn agent_callback(_vm: [*]VM, options: [*]u8) callconv(.C) i32 {
19 _ = _vm;
20 _ = options;
19 return 11;21 return 11;
20}22}
2123
test/behavior/bugs/2578.zig+3-1
...@@ -5,7 +5,9 @@ const Foo = struct {...@@ -5,7 +5,9 @@ const Foo = struct {
5var foo: Foo = undefined;5var foo: Foo = undefined;
6const t = &foo;6const t = &foo;
77
8fn bar(pointer: ?*c_void) void {}8fn bar(pointer: ?*c_void) void {
9 _ = pointer;
10}
911
10test "fixed" {12test "fixed" {
11 bar(t);13 bar(t);
test/behavior/bugs/2692.zig+3-1
...@@ -1,4 +1,6 @@...@@ -1,4 +1,6 @@
1fn foo(a: []u8) void {}1fn foo(a: []u8) void {
2 _ = a;
3}
24
3test "address of 0 length array" {5test "address of 0 length array" {
4 var pt: [0]u8 = undefined;6 var pt: [0]u8 = undefined;
test/behavior/bugs/3367.zig+3-1
...@@ -3,7 +3,9 @@ const Foo = struct {...@@ -3,7 +3,9 @@ const Foo = struct {
3};3};
44
5const Mixin = struct {5const Mixin = struct {
6 pub fn two(self: Foo) void {}6 pub fn two(self: Foo) void {
7 _ = self;
8 }
7};9};
810
9test "container member access usingnamespace decls" {11test "container member access usingnamespace decls" {
test/behavior/bugs/4328.zig+2
...@@ -53,10 +53,12 @@ test "Peer resolution of extern function calls in @TypeOf" {...@@ -53,10 +53,12 @@ test "Peer resolution of extern function calls in @TypeOf" {
53test "Extern function calls, dereferences and field access in @TypeOf" {53test "Extern function calls, dereferences and field access in @TypeOf" {
54 const Test = struct {54 const Test = struct {
55 fn test_fn_1(a: c_long) @TypeOf(fopen("test", "r").*) {55 fn test_fn_1(a: c_long) @TypeOf(fopen("test", "r").*) {
56 _ = a;
56 return .{ .dummy_field = 0 };57 return .{ .dummy_field = 0 };
57 }58 }
5859
59 fn test_fn_2(a: anytype) @TypeOf(fopen("test", "r").*.dummy_field) {60 fn test_fn_2(a: anytype) @TypeOf(fopen("test", "r").*.dummy_field) {
61 _ = a;
60 return 255;62 return 255;
61 }63 }
6264
test/behavior/bugs/4560.zig+4
...@@ -25,6 +25,10 @@ pub fn StringHashMap(comptime V: type) type {...@@ -25,6 +25,10 @@ pub fn StringHashMap(comptime V: type) type {
25}25}
2626
27pub fn HashMap(comptime K: type, comptime V: type) type {27pub fn HashMap(comptime K: type, comptime V: type) type {
28 if (false) {
29 K;
30 V;
31 }
28 return struct {32 return struct {
29 size: usize,33 size: usize,
30 max_distance_from_start_index: usize,34 max_distance_from_start_index: usize,
test/behavior/bugs/529_other_file_2.zig+3-1
...@@ -1,4 +1,6 @@...@@ -1,4 +1,6 @@
1pub const A = extern struct {1pub const A = extern struct {
2 field: c_int,2 field: c_int,
3};3};
4export fn issue529(a: ?*A) void {}4export fn issue529(a: ?*A) void {
5 _ = a;
6}
test/behavior/bugs/5487.zig+1
...@@ -1,6 +1,7 @@...@@ -1,6 +1,7 @@
1const io = @import("std").io;1const io = @import("std").io;
22
3pub fn write(_: void, bytes: []const u8) !usize {3pub fn write(_: void, bytes: []const u8) !usize {
4 _ = bytes;
4 return 0;5 return 0;
5}6}
6pub fn writer() io.Writer(void, @typeInfo(@typeInfo(@TypeOf(write)).Fn.return_type.?).ErrorUnion.error_set, write) {7pub 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,6 +12,7 @@ const ListenerContext = struct {
12const ContextAllocator = MemoryPool(TestContext);12const ContextAllocator = MemoryPool(TestContext);
1313
14fn MemoryPool(comptime T: type) type {14fn MemoryPool(comptime T: type) type {
15 _ = T;
15 return struct {16 return struct {
16 n: usize,17 n: usize,
17 };18 };
test/behavior/bugs/679.zig+1
...@@ -2,6 +2,7 @@ const std = @import("std");...@@ -2,6 +2,7 @@ const std = @import("std");
2const expect = std.testing.expect;2const expect = std.testing.expect;
33
4pub fn List(comptime T: type) type {4pub fn List(comptime T: type) type {
5 _ = T;
5 return u32;6 return u32;
6}7}
78
test/behavior/bugs/7027.zig+3-1
...@@ -9,7 +9,9 @@ const Foobar = struct {...@@ -9,7 +9,9 @@ const Foobar = struct {
9 }9 }
10};10};
1111
12fn foo(arg: anytype) void {}12fn foo(arg: anytype) void {
13 _ = arg;
14}
1315
14test "" {16test "" {
15 comptime var foobar = Foobar.foo();17 comptime var foobar = Foobar.foo();
test/behavior/bugs/704.zig+3-1
...@@ -1,5 +1,7 @@...@@ -1,5 +1,7 @@
1const xxx = struct {1const xxx = struct {
2 pub fn bar(self: *xxx) void {}2 pub fn bar(self: *xxx) void {
3 _ = self;
4 }
3};5};
4test "bug 704" {6test "bug 704" {
5 var x: xxx = undefined;7 var x: xxx = undefined;
test/behavior/bugs/7250.zig+3-1
...@@ -3,7 +3,9 @@ const nrfx_uart_t = extern struct {...@@ -3,7 +3,9 @@ const nrfx_uart_t = extern struct {
3 drv_inst_idx: u8,3 drv_inst_idx: u8,
4};4};
55
6pub fn nrfx_uart_rx(p_instance: [*c]const nrfx_uart_t) void {}6pub fn nrfx_uart_rx(p_instance: [*c]const nrfx_uart_t) void {
7 _ = p_instance;
8}
79
8threadlocal var g_uart0 = nrfx_uart_t{10threadlocal var g_uart0 = nrfx_uart_t{
9 .p_reg = 0,11 .p_reg = 0,
test/behavior/bugs/828.zig+2
...@@ -4,6 +4,7 @@ const CountBy = struct {...@@ -4,6 +4,7 @@ const CountBy = struct {
4 const One = CountBy{ .a = 1 };4 const One = CountBy{ .a = 1 };
55
6 pub fn counter(self: *const CountBy) Counter {6 pub fn counter(self: *const CountBy) Counter {
7 _ = self;
7 return Counter{ .i = 0 };8 return Counter{ .i = 0 };
8 }9 }
9};10};
...@@ -18,6 +19,7 @@ const Counter = struct {...@@ -18,6 +19,7 @@ const Counter = struct {
18};19};
1920
20fn constCount(comptime cb: *const CountBy, comptime unused: u32) void {21fn constCount(comptime cb: *const CountBy, comptime unused: u32) void {
22 _ = unused;
21 comptime {23 comptime {
22 var cnt = cb.counter();24 var cnt = cb.counter();
23 if (cnt.i != 0) @compileError("Counter instance reused!");25 if (cnt.i != 0) @compileError("Counter instance reused!");
test/behavior/bugs/920.zig+2
...@@ -46,6 +46,8 @@ fn norm_f_inv(y: f64) f64 {...@@ -46,6 +46,8 @@ fn norm_f_inv(y: f64) f64 {
46 return math.sqrt(-2.0 * math.ln(y));46 return math.sqrt(-2.0 * math.ln(y));
47}47}
48fn norm_zero_case(random: *Random, u: f64) f64 {48fn norm_zero_case(random: *Random, u: f64) f64 {
49 _ = random;
50 _ = u;
49 return 0.0;51 return 0.0;
50}52}
5153
test/behavior/cast.zig+6-2
...@@ -824,9 +824,13 @@ test "variable initialization uses result locations properly with regards to the...@@ -824,9 +824,13 @@ test "variable initialization uses result locations properly with regards to the
824test "cast between [*c]T and ?[*:0]T on fn parameter" {824test "cast between [*c]T and ?[*:0]T on fn parameter" {
825 const S = struct {825 const S = struct {
826 const Handler = ?fn ([*c]const u8) callconv(.C) void;826 const Handler = ?fn ([*c]const u8) callconv(.C) void;
827 fn addCallback(handler: Handler) void {}827 fn addCallback(handler: Handler) void {
828 _ = handler;
829 }
828830
829 fn myCallback(cstr: ?[*:0]const u8) callconv(.C) void {}831 fn myCallback(cstr: ?[*:0]const u8) callconv(.C) void {
832 _ = cstr;
833 }
830834
831 fn doTheTest() void {835 fn doTheTest() void {
832 addCallback(myCallback);836 addCallback(myCallback);
test/behavior/error.zig+8-2
...@@ -139,7 +139,10 @@ test "comptime test error for empty error set" {...@@ -139,7 +139,10 @@ test "comptime test error for empty error set" {
139const EmptyErrorSet = error{};139const EmptyErrorSet = error{};
140140
141fn testComptimeTestErrorEmptySet(x: EmptyErrorSet!i32) !void {141fn testComptimeTestErrorEmptySet(x: EmptyErrorSet!i32) !void {
142 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 }
143}146}
144147
145test "syntax: optional operator in front of error union operator" {148test "syntax: optional operator in front of error union operator" {
...@@ -394,6 +397,7 @@ test "function pointer with return type that is error union with payload which i...@@ -394,6 +397,7 @@ test "function pointer with return type that is error union with payload which i
394 const Err = error{UnspecifiedErr};397 const Err = error{UnspecifiedErr};
395398
396 fn bar(a: i32) anyerror!*Foo {399 fn bar(a: i32) anyerror!*Foo {
400 _ = a;
397 return Err.UnspecifiedErr;401 return Err.UnspecifiedErr;
398 }402 }
399403
...@@ -448,7 +452,9 @@ test "error payload type is correctly resolved" {...@@ -448,7 +452,9 @@ test "error payload type is correctly resolved" {
448452
449test "error union comptime caching" {453test "error union comptime caching" {
450 const S = struct {454 const S = struct {
451 fn foo(comptime arg: anytype) void {}455 fn foo(comptime arg: anytype) void {
456 arg catch {};
457 }
452 };458 };
453459
454 S.foo(@as(anyerror!void, {}));460 S.foo(@as(anyerror!void, {}));
test/behavior/eval.zig+7-2
...@@ -422,6 +422,7 @@ test {...@@ -422,6 +422,7 @@ test {
422}422}
423423
424pub fn TypeWithCompTimeSlice(comptime field_name: []const u8) type {424pub fn TypeWithCompTimeSlice(comptime field_name: []const u8) type {
425 _ = field_name;
425 return struct {426 return struct {
426 pub const Node = struct {};427 pub const Node = struct {};
427 };428 };
...@@ -698,7 +699,9 @@ test "refer to the type of a generic function" {...@@ -698,7 +699,9 @@ test "refer to the type of a generic function" {
698 f(i32);699 f(i32);
699}700}
700701
701fn doNothingWithType(comptime T: type) void {}702fn doNothingWithType(comptime T: type) void {
703 _ = T;
704}
702705
703test "zero extend from u0 to u1" {706test "zero extend from u0 to u1" {
704 var zero_u0: u0 = 0;707 var zero_u0: u0 = 0;
...@@ -819,7 +822,9 @@ test "two comptime calls with array default initialized to undefined" {...@@ -819,7 +822,9 @@ test "two comptime calls with array default initialized to undefined" {
819 result.getCpuArch();822 result.getCpuArch();
820 }823 }
821824
822 pub fn getCpuArch(self: CrossTarget) void {}825 pub fn getCpuArch(self: CrossTarget) void {
826 _ = self;
827 }
823 };828 };
824829
825 const DynamicLinker = struct {830 const DynamicLinker = struct {
test/behavior/fn.zig+8-2
...@@ -23,6 +23,7 @@ test "void parameters" {...@@ -23,6 +23,7 @@ test "void parameters" {
23 try voidFun(1, void{}, 2, {});23 try voidFun(1, void{}, 2, {});
24}24}
25fn voidFun(a: i32, b: void, c: i32, d: void) !void {25fn voidFun(a: i32, b: void, c: i32, d: void) !void {
26 _ = d;
26 const v = b;27 const v = b;
27 const vv: void = if (a == 1) v else {};28 const vv: void = if (a == 1) v else {};
28 try expect(a + c == 3);29 try expect(a + c == 3);
...@@ -57,7 +58,9 @@ test "call function with empty string" {...@@ -57,7 +58,9 @@ test "call function with empty string" {
57 acceptsString("");58 acceptsString("");
58}59}
5960
60fn acceptsString(foo: []u8) void {}61fn acceptsString(foo: []u8) void {
62 _ = foo;
63}
6164
62fn @"weird function name"() i32 {65fn @"weird function name"() i32 {
63 return 1234;66 return 1234;
...@@ -70,7 +73,9 @@ test "implicit cast function unreachable return" {...@@ -70,7 +73,9 @@ test "implicit cast function unreachable return" {
70 wantsFnWithVoid(fnWithUnreachable);73 wantsFnWithVoid(fnWithUnreachable);
71}74}
7275
73fn wantsFnWithVoid(f: fn () void) void {}76fn wantsFnWithVoid(f: fn () void) void {
77 _ = f;
78}
7479
75fn fnWithUnreachable() noreturn {80fn fnWithUnreachable() noreturn {
76 unreachable;81 unreachable;
...@@ -162,6 +167,7 @@ const Point3 = struct {...@@ -162,6 +167,7 @@ const Point3 = struct {
162 y: i32,167 y: i32,
163168
164 fn addPointCoords(self: Point3, comptime T: type) i32 {169 fn addPointCoords(self: Point3, comptime T: type) i32 {
170 _ = T;
165 return self.x + self.y;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,10 +29,14 @@ test "for loop with pointer elem var" {
29 mangleString(target[0..]);29 mangleString(target[0..]);
30 try expect(mem.eql(u8, &target, "bcdefgh"));30 try expect(mem.eql(u8, &target, "bcdefgh"));
3131
32 for (source) |*c, i|32 for (source) |*c, i| {
33 _ = i;
33 try expect(@TypeOf(c) == *const u8);34 try expect(@TypeOf(c) == *const u8);
34 for (target) |*c, i|35 }
36 for (target) |*c, i| {
37 _ = i;
35 try expect(@TypeOf(c) == *u8);38 try expect(@TypeOf(c) == *u8);
39 }
36}40}
3741
38fn mangleString(s: []u8) void {42fn mangleString(s: []u8) void {
...@@ -53,6 +57,7 @@ test "basic for loop" {...@@ -53,6 +57,7 @@ test "basic for loop" {
53 buf_index += 1;57 buf_index += 1;
54 }58 }
55 for (array) |item, index| {59 for (array) |item, index| {
60 _ = item;
56 buffer[buf_index] = @intCast(u8, index);61 buffer[buf_index] = @intCast(u8, index);
57 buf_index += 1;62 buf_index += 1;
58 }63 }
...@@ -62,6 +67,7 @@ test "basic for loop" {...@@ -62,6 +67,7 @@ test "basic for loop" {
62 buf_index += 1;67 buf_index += 1;
63 }68 }
64 for (array_ptr) |item, index| {69 for (array_ptr) |item, index| {
70 _ = item;
65 buffer[buf_index] = @intCast(u8, index);71 buffer[buf_index] = @intCast(u8, index);
66 buf_index += 1;72 buf_index += 1;
67 }73 }
...@@ -70,7 +76,7 @@ test "basic for loop" {...@@ -70,7 +76,7 @@ test "basic for loop" {
70 buffer[buf_index] = item;76 buffer[buf_index] = item;
71 buf_index += 1;77 buf_index += 1;
72 }78 }
73 for (unknown_size) |item, index| {79 for (unknown_size) |_, index| {
74 buffer[buf_index] = @intCast(u8, index);80 buffer[buf_index] = @intCast(u8, index);
75 buf_index += 1;81 buf_index += 1;
76 }82 }
...@@ -118,6 +124,7 @@ test "2 break statements and an else" {...@@ -118,6 +124,7 @@ test "2 break statements and an else" {
118 var buf: [10]u8 = undefined;124 var buf: [10]u8 = undefined;
119 var ok = false;125 var ok = false;
120 ok = for (buf) |item| {126 ok = for (buf) |item| {
127 _ = item;
121 if (f) break false;128 if (f) break false;
122 if (t) break true;129 if (t) break true;
123 } else false;130 } else false;
...@@ -136,6 +143,7 @@ test "for with null and T peer types and inferred result location type" {...@@ -136,6 +143,7 @@ test "for with null and T peer types and inferred result location type" {
136 break item;143 break item;
137 }144 }
138 } else null) |v| {145 } else null) |v| {
146 _ = v;
139 @panic("fail");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,7 +45,7 @@ var global_with_err: anyerror!u32 = error.SomeError;
45test "unwrap mutable global var" {45test "unwrap mutable global var" {
46 if (global_with_val) |v| {46 if (global_with_val) |v| {
47 try expect(v == 0);47 try expect(v == 0);
48 } else |e| {48 } else |_| {
49 unreachable;49 unreachable;
50 }50 }
51 if (global_with_err) |_| {51 if (global_with_err) |_| {
test/behavior/misc.zig+17-4
...@@ -245,14 +245,18 @@ var some_mem: [100]u8 = undefined;...@@ -245,14 +245,18 @@ var some_mem: [100]u8 = undefined;
245fn memAlloc(comptime T: type, n: usize) anyerror![]T {245fn memAlloc(comptime T: type, n: usize) anyerror![]T {
246 return @ptrCast([*]T, &some_mem[0])[0..n];246 return @ptrCast([*]T, &some_mem[0])[0..n];
247}247}
248fn memFree(comptime T: type, memory: []T) void {}248fn memFree(comptime T: type, memory: []T) void {
249 _ = memory;
250}
249251
250test "cast undefined" {252test "cast undefined" {
251 const array: [100]u8 = undefined;253 const array: [100]u8 = undefined;
252 const slice = @as([]const u8, &array);254 const slice = @as([]const u8, &array);
253 testCastUndefined(slice);255 testCastUndefined(slice);
254}256}
255fn testCastUndefined(x: []const u8) void {}257fn testCastUndefined(x: []const u8) void {
258 _ = x;
259}
256260
257test "cast small unsigned to larger signed" {261test "cast small unsigned to larger signed" {
258 try expect(castSmallUnsignedToLargerSigned1(200) == @as(i16, 200));262 try expect(castSmallUnsignedToLargerSigned1(200) == @as(i16, 200));
...@@ -452,6 +456,7 @@ test "@typeName" {...@@ -452,6 +456,7 @@ test "@typeName" {
452}456}
453457
454fn TypeFromFn(comptime T: type) type {458fn TypeFromFn(comptime T: type) type {
459 _ = T;
455 return struct {};460 return struct {};
456}461}
457462
...@@ -555,7 +560,12 @@ test "packed struct, enum, union parameters in extern function" {...@@ -555,7 +560,12 @@ test "packed struct, enum, union parameters in extern function" {
555 }), &(PackedUnion{ .a = 1 }));560 }), &(PackedUnion{ .a = 1 }));
556}561}
557562
558export fn testPackedStuff(a: *const PackedStruct, b: *const PackedUnion) void {}563export fn testPackedStuff(a: *const PackedStruct, b: *const PackedUnion) void {
564 if (false) {
565 a;
566 b;
567 }
568}
559569
560test "slicing zero length array" {570test "slicing zero length array" {
561 const s1 = ""[0..];571 const s1 = ""[0..];
...@@ -584,6 +594,7 @@ test "self reference through fn ptr field" {...@@ -584,6 +594,7 @@ test "self reference through fn ptr field" {
584 };594 };
585595
586 fn foo(a: A) u8 {596 fn foo(a: A) u8 {
597 _ = a;
587 return 12;598 return 12;
588 }599 }
589 };600 };
...@@ -753,7 +764,9 @@ test "extern variable with non-pointer opaque type" {...@@ -753,7 +764,9 @@ test "extern variable with non-pointer opaque type" {
753764
754test "lazy typeInfo value as generic parameter" {765test "lazy typeInfo value as generic parameter" {
755 const S = struct {766 const S = struct {
756 fn foo(args: anytype) void {}767 fn foo(args: anytype) void {
768 _ = args;
769 }
757 };770 };
758 S.foo(@typeInfo(@TypeOf(.{})));771 S.foo(@typeInfo(@TypeOf(.{})));
759}772}
test/behavior/null.zig+1
...@@ -130,6 +130,7 @@ var struct_with_optional: StructWithOptional = undefined;...@@ -130,6 +130,7 @@ var struct_with_optional: StructWithOptional = undefined;
130test "unwrap optional which is field of global var" {130test "unwrap optional which is field of global var" {
131 struct_with_optional.field = null;131 struct_with_optional.field = null;
132 if (struct_with_optional.field) |payload| {132 if (struct_with_optional.field) |payload| {
133 _ = payload;
133 unreachable;134 unreachable;
134 }135 }
135 struct_with_optional.field = 1234;136 struct_with_optional.field = 1234;
test/behavior/optional.zig+1
...@@ -161,6 +161,7 @@ test "self-referential struct through a slice of optional" {...@@ -161,6 +161,7 @@ test "self-referential struct through a slice of optional" {
161test "assigning to an unwrapped optional field in an inline loop" {161test "assigning to an unwrapped optional field in an inline loop" {
162 comptime var maybe_pos_arg: ?comptime_int = null;162 comptime var maybe_pos_arg: ?comptime_int = null;
163 inline for ("ab") |x| {163 inline for ("ab") |x| {
164 _ = x;
164 maybe_pos_arg = 0;165 maybe_pos_arg = 0;
165 if (maybe_pos_arg.? != 0) {166 if (maybe_pos_arg.? != 0) {
166 @compileError("bad");167 @compileError("bad");
test/behavior/pointers.zig+5-1
...@@ -179,6 +179,7 @@ test "assign null directly to C pointer and test null equality" {...@@ -179,6 +179,7 @@ test "assign null directly to C pointer and test null equality" {
179 try expect(!(x != null));179 try expect(!(x != null));
180 try expect(!(null != x));180 try expect(!(null != x));
181 if (x) |same_x| {181 if (x) |same_x| {
182 _ = same_x;
182 @panic("fail");183 @panic("fail");
183 }184 }
184 var otherx: i32 = undefined;185 var otherx: i32 = undefined;
...@@ -189,7 +190,10 @@ test "assign null directly to C pointer and test null equality" {...@@ -189,7 +190,10 @@ test "assign null directly to C pointer and test null equality" {
189 comptime try expect(null == y);190 comptime try expect(null == y);
190 comptime try expect(!(y != null));191 comptime try expect(!(y != null));
191 comptime try expect(!(null != y));192 comptime try expect(!(null != y));
192 if (y) |same_y| @panic("fail");193 if (y) |same_y| {
194 _ = same_y;
195 @panic("fail");
196 }
193 const othery: i32 = undefined;197 const othery: i32 = undefined;
194 comptime try expect((y orelse &othery) == &othery);198 comptime try expect((y orelse &othery) == &othery);
195199
test/behavior/reflection.zig+5
...@@ -15,6 +15,11 @@ test "reflection: function return type, var args, and param types" {...@@ -15,6 +15,11 @@ test "reflection: function return type, var args, and param types" {
15}15}
1616
17fn dummy(a: bool, b: i32, c: f32) i32 {17fn dummy(a: bool, b: i32, c: f32) i32 {
18 if (false) {
19 a;
20 b;
21 c;
22 }
18 return 1234;23 return 1234;
19}24}
2025
test/behavior/struct.zig+5
...@@ -182,6 +182,7 @@ test "empty struct method call" {...@@ -182,6 +182,7 @@ test "empty struct method call" {
182}182}
183const EmptyStruct = struct {183const EmptyStruct = struct {
184 fn method(es: *const EmptyStruct) i32 {184 fn method(es: *const EmptyStruct) i32 {
185 _ = es;
185 return 1234;186 return 1234;
186 }187 }
187};188};
...@@ -452,9 +453,11 @@ fn alloc(comptime T: type) []T {...@@ -452,9 +453,11 @@ fn alloc(comptime T: type) []T {
452test "call method with mutable reference to struct with no fields" {453test "call method with mutable reference to struct with no fields" {
453 const S = struct {454 const S = struct {
454 fn doC(s: *const @This()) bool {455 fn doC(s: *const @This()) bool {
456 _ = s;
455 return true;457 return true;
456 }458 }
457 fn do(s: *@This()) bool {459 fn do(s: *@This()) bool {
460 _ = s;
458 return true;461 return true;
459 }462 }
460 };463 };
...@@ -625,11 +628,13 @@ test "for loop over pointers to struct, getting field from struct pointer" {...@@ -625,11 +628,13 @@ test "for loop over pointers to struct, getting field from struct pointer" {
625 var ok = true;628 var ok = true;
626629
627 fn eql(a: []const u8) bool {630 fn eql(a: []const u8) bool {
631 _ = a;
628 return true;632 return true;
629 }633 }
630634
631 const ArrayList = struct {635 const ArrayList = struct {
632 fn toSlice(self: *ArrayList) []*Foo {636 fn toSlice(self: *ArrayList) []*Foo {
637 _ = self;
633 return @as([*]*Foo, undefined)[0..0];638 return @as([*]*Foo, undefined)[0..0];
634 }639 }
635 };640 };
test/behavior/switch.zig+13-3
...@@ -386,6 +386,7 @@ test "switch with null and T peer types and inferred result location type" {...@@ -386,6 +386,7 @@ test "switch with null and T peer types and inferred result location type" {
386 0 => true,386 0 => true,
387 else => null,387 else => null,
388 }) |v| {388 }) |v| {
389 _ = v;
389 @panic("fail");390 @panic("fail");
390 }391 }
391 }392 }
...@@ -411,12 +412,18 @@ test "switch prongs with cases with identical payload types" {...@@ -411,12 +412,18 @@ test "switch prongs with cases with identical payload types" {
411 try expect(@TypeOf(e) == usize);412 try expect(@TypeOf(e) == usize);
412 try expect(e == 8);413 try expect(e == 8);
413 },414 },
414 .B => |e| @panic("fail"),415 .B => |e| {
416 _ = e;
417 @panic("fail");
418 },
415 }419 }
416 }420 }
417 fn doTheSwitch2(u: Union) !void {421 fn doTheSwitch2(u: Union) !void {
418 switch (u) {422 switch (u) {
419 .A, .C => |e| @panic("fail"),423 .A, .C => |e| {
424 _ = e;
425 @panic("fail");
426 },
420 .B => |e| {427 .B => |e| {
421 try expect(@TypeOf(e) == isize);428 try expect(@TypeOf(e) == isize);
422 try expect(e == -8);429 try expect(e == -8);
...@@ -508,7 +515,10 @@ test "switch on error set with single else" {...@@ -508,7 +515,10 @@ test "switch on error set with single else" {
508 fn doTheTest() !void {515 fn doTheTest() !void {
509 var some: error{Foo} = error.Foo;516 var some: error{Foo} = error.Foo;
510 try expect(switch (some) {517 try expect(switch (some) {
511 else => |a| true,518 else => |a| blk: {
519 a catch {};
520 break :blk true;
521 },
512 });522 });
513 }523 }
514 };524 };
test/behavior/type.zig+7-1
...@@ -431,6 +431,10 @@ test "Type.Fn" {...@@ -431,6 +431,10 @@ test "Type.Fn" {
431431
432 const foo = struct {432 const foo = struct {
433 fn func(a: usize, b: bool) align(4) callconv(.C) usize {433 fn func(a: usize, b: bool) align(4) callconv(.C) usize {
434 if (false) {
435 a;
436 b;
437 }
434 return 0;438 return 0;
435 }439 }
436 }.func;440 }.func;
...@@ -444,7 +448,9 @@ test "Type.BoundFn" {...@@ -444,7 +448,9 @@ test "Type.BoundFn" {
444 if (builtin.target.cpu.arch == .wasm32 or builtin.target.cpu.arch == .wasm64) return error.SkipZigTest;448 if (builtin.target.cpu.arch == .wasm32 or builtin.target.cpu.arch == .wasm64) return error.SkipZigTest;
445449
446 const TestStruct = packed struct {450 const TestStruct = packed struct {
447 pub fn foo(self: *const @This()) align(4) callconv(.Unspecified) void {}451 pub fn foo(self: *const @This()) align(4) callconv(.Unspecified) void {
452 _ = self;
453 }
448 };454 };
449 const test_instance: TestStruct = undefined;455 const test_instance: TestStruct = undefined;
450 try testing.expect(std.meta.eql(456 try testing.expect(std.meta.eql(
test/behavior/type_info.zig+7-2
...@@ -277,7 +277,9 @@ const TestStruct = packed struct {...@@ -277,7 +277,9 @@ const TestStruct = packed struct {
277 fieldC: *Self,277 fieldC: *Self,
278 fieldD: u32 = 4,278 fieldD: u32 = 4,
279279
280 pub fn foo(self: *const Self) void {}280 pub fn foo(self: *const Self) void {
281 _ = self;
282 }
281 const Self = @This();283 const Self = @This();
282};284};
283285
...@@ -326,7 +328,9 @@ extern fn fooAligned(a: usize, b: bool, ...) align(4) callconv(.C) usize;...@@ -326,7 +328,9 @@ extern fn fooAligned(a: usize, b: bool, ...) align(4) callconv(.C) usize;
326328
327test "typeInfo with comptime parameter in struct fn def" {329test "typeInfo with comptime parameter in struct fn def" {
328 const S = struct {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 comptime var info = @typeInfo(S);335 comptime var info = @typeInfo(S);
332 _ = info;336 _ = info;
...@@ -369,6 +373,7 @@ test "type info: pass to function" {...@@ -369,6 +373,7 @@ test "type info: pass to function" {
369}373}
370374
371fn passTypeInfo(comptime info: TypeInfo) type {375fn passTypeInfo(comptime info: TypeInfo) type {
376 _ = info;
372 return void;377 return void;
373}378}
374379
test/behavior/underscore.zig+2
...@@ -7,7 +7,9 @@ test "ignore lval with underscore" {...@@ -7,7 +7,9 @@ test "ignore lval with underscore" {
77
8test "ignore lval with underscore (for loop)" {8test "ignore lval with underscore (for loop)" {
9 for ([_]void{}) |_, i| {9 for ([_]void{}) |_, i| {
10 _ = i;
10 for ([_]void{}) |_, j| {11 for ([_]void{}) |_, j| {
12 _ = j;
11 break;13 break;
12 }14 }
13 break;15 break;
test/behavior/union.zig+8-2
...@@ -374,7 +374,9 @@ const Attribute = union(enum) {...@@ -374,7 +374,9 @@ const Attribute = union(enum) {
374 B: u8,374 B: u8,
375};375};
376376
377fn setAttribute(attr: Attribute) void {}377fn setAttribute(attr: Attribute) void {
378 _ = attr;
379}
378380
379fn Setter(attr: Attribute) type {381fn Setter(attr: Attribute) type {
380 return struct {382 return struct {
...@@ -465,7 +467,9 @@ test "union no tag with struct member" {...@@ -465,7 +467,9 @@ test "union no tag with struct member" {
465 const Struct = struct {};467 const Struct = struct {};
466 const Union = union {468 const Union = union {
467 s: Struct,469 s: Struct,
468 pub fn foo(self: *@This()) void {}470 pub fn foo(self: *@This()) void {
471 _ = self;
472 }
469 };473 };
470 var u = Union{ .s = Struct{} };474 var u = Union{ .s = Struct{} };
471 u.foo();475 u.foo();
...@@ -703,6 +707,7 @@ test "method call on an empty union" {...@@ -703,6 +707,7 @@ test "method call on an empty union" {
703 X2: [0]u8,707 X2: [0]u8,
704708
705 pub fn useIt(self: *@This()) bool {709 pub fn useIt(self: *@This()) bool {
710 _ = self;
706 return true;711 return true;
707 }712 }
708 };713 };
...@@ -771,6 +776,7 @@ test "@unionInit on union w/ tag but no fields" {...@@ -771,6 +776,7 @@ test "@unionInit on union w/ tag but no fields" {
771 no_op: void,776 no_op: void,
772777
773 pub fn decode(buf: []const u8) Data {778 pub fn decode(buf: []const u8) Data {
779 _ = buf;
774 return @unionInit(Data, "no_op", {});780 return @unionInit(Data, "no_op", {});
775 }781 }
776 };782 };
test/behavior/var_args.zig+3
...@@ -48,6 +48,7 @@ test "runtime parameter before var args" {...@@ -48,6 +48,7 @@ test "runtime parameter before var args" {
48}48}
4949
50fn extraFn(extra: u32, args: anytype) !usize {50fn extraFn(extra: u32, args: anytype) !usize {
51 _ = extra;
51 if (args.len >= 1) {52 if (args.len >= 1) {
52 try expect(args[0] == false);53 try expect(args[0] == false);
53 }54 }
...@@ -63,9 +64,11 @@ const foos = [_]fn (anytype) bool{...@@ -63,9 +64,11 @@ const foos = [_]fn (anytype) bool{
63};64};
6465
65fn foo1(args: anytype) bool {66fn foo1(args: anytype) bool {
67 _ = args;
66 return true;68 return true;
67}69}
68fn foo2(args: anytype) bool {70fn foo2(args: anytype) bool {
71 _ = args;
69 return false;72 return false;
70}73}
7174
test/behavior/while.zig+2-2
...@@ -151,14 +151,14 @@ test "while on optional with else result follow break prong" {...@@ -151,14 +151,14 @@ test "while on optional with else result follow break prong" {
151test "while on error union with else result follow else prong" {151test "while on error union with else result follow else prong" {
152 const result = while (returnError()) |value| {152 const result = while (returnError()) |value| {
153 break value;153 break value;
154 } else |err| @as(i32, 2);154 } else |_| @as(i32, 2);
155 try expect(result == 2);155 try expect(result == 2);
156}156}
157157
158test "while on error union with else result follow break prong" {158test "while on error union with else result follow break prong" {
159 const result = while (returnSuccess(10)) |value| {159 const result = while (returnSuccess(10)) |value| {
160 break value;160 break value;
161 } else |err| @as(i32, 2);161 } else |_| @as(i32, 2);
162 try expect(result == 10);162 try expect(result == 10);
163}163}
164164
test/stage2/cbe.zig+10-6
...@@ -823,31 +823,35 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -823,31 +823,35 @@ pub fn addCases(ctx: *TestContext) !void {
823 \\823 \\
824 );824 );
825 ctx.h("header with single param function", linux_x64,825 ctx.h("header with single param function", linux_x64,
826 \\export fn start(a: u8) void{}826 \\export fn start(a: u8) void{
827 \\ _ = a;
828 \\}
827 ,829 ,
828 \\ZIG_EXTERN_C void start(uint8_t a0);830 \\ZIG_EXTERN_C void start(uint8_t a0);
829 \\831 \\
830 );832 );
831 ctx.h("header with multiple param function", linux_x64,833 ctx.h("header with multiple param function", linux_x64,
832 \\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 \\}
833 ,837 ,
834 \\ZIG_EXTERN_C void start(uint8_t a0, uint8_t a1, uint8_t a2);838 \\ZIG_EXTERN_C void start(uint8_t a0, uint8_t a1, uint8_t a2);
835 \\839 \\
836 );840 );
837 ctx.h("header with u32 param function", linux_x64,841 ctx.h("header with u32 param function", linux_x64,
838 \\export fn start(a: u32) void{}842 \\export fn start(a: u32) void{ _ = a; }
839 ,843 ,
840 \\ZIG_EXTERN_C void start(uint32_t a0);844 \\ZIG_EXTERN_C void start(uint32_t a0);
841 \\845 \\
842 );846 );
843 ctx.h("header with usize param function", linux_x64,847 ctx.h("header with usize param function", linux_x64,
844 \\export fn start(a: usize) void{}848 \\export fn start(a: usize) void{ _ = a; }
845 ,849 ,
846 \\ZIG_EXTERN_C void start(uintptr_t a0);850 \\ZIG_EXTERN_C void start(uintptr_t a0);
847 \\851 \\
848 );852 );
849 ctx.h("header with bool param function", linux_x64,853 ctx.h("header with bool param function", linux_x64,
850 \\export fn start(a: bool) void{}854 \\export fn start(a: bool) void{_ = a;}
851 ,855 ,
852 \\ZIG_EXTERN_C void start(bool a0);856 \\ZIG_EXTERN_C void start(bool a0);
853 \\857 \\
...@@ -871,7 +875,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -871,7 +875,7 @@ pub fn addCases(ctx: *TestContext) !void {
871 \\875 \\
872 );876 );
873 ctx.h("header with multiple includes", linux_x64,877 ctx.h("header with multiple includes", linux_x64,
874 \\export fn start(a: u32, b: usize) void{}878 \\export fn start(a: u32, b: usize) void{ _ = a; _ = b; }
875 ,879 ,
876 \\ZIG_EXTERN_C void start(uint32_t a0, uintptr_t a1);880 \\ZIG_EXTERN_C void start(uint32_t a0, uintptr_t a1);
877 \\881 \\
test/stage2/test.zig+3-1
...@@ -1392,7 +1392,9 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1392,7 +1392,9 @@ pub fn addCases(ctx: *TestContext) !void {
1392 \\pub fn main() void {1392 \\pub fn main() void {
1393 \\ doNothing(0);1393 \\ doNothing(0);
1394 \\}1394 \\}
1395 \\fn doNothing(arg: u0) void {}1395 \\fn doNothing(arg: u0) void {
1396 \\ _ = arg;
1397 \\}
1396 ,1398 ,
1397 "",1399 "",
1398 );1400 );
test/stage2/wasm.zig+2-1
...@@ -64,7 +64,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -64,7 +64,7 @@ pub fn addCases(ctx: *TestContext) !void {
64 \\ foo(10, 20);64 \\ foo(10, 20);
65 \\ return 5;65 \\ return 5;
66 \\}66 \\}
67 \\fn foo(x: u32, y: u32) void {}67 \\fn foo(x: u32, y: u32) void { _ = x; _ = y; }
68 , "5\n");68 , "5\n");
69 }69 }
7070
...@@ -95,6 +95,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -95,6 +95,7 @@ pub fn addCases(ctx: *TestContext) !void {
95 \\ return i;95 \\ return i;
96 \\}96 \\}
97 \\fn foo(x: u32, y: u32) void {97 \\fn foo(x: u32, y: u32) void {
98 \\ _ = y;
98 \\ var i: u32 = 10;99 \\ var i: u32 = 10;
99 \\ i = x;100 \\ i = x;
100 \\}101 \\}
test/standalone/hello_world/hello_libc.zig+2
...@@ -8,6 +8,8 @@ const c = @cImport({...@@ -8,6 +8,8 @@ const c = @cImport({
8const msg = "Hello, world!\n";8const msg = "Hello, world!\n";
99
10pub export fn main(argc: c_int, argv: **u8) c_int {10pub export fn main(argc: c_int, argv: **u8) c_int {
11 _ = argv;
12 _ = argc;
11 if (c.printf(msg) != @intCast(c_int, c.strlen(msg))) return -1;13 if (c.printf(msg) != @intCast(c_int, c.strlen(msg))) return -1;
12 return 0;14 return 0;
13}15}
test/standalone/issue_339/test.zig+2
...@@ -1,5 +1,7 @@...@@ -1,5 +1,7 @@
1const StackTrace = @import("std").builtin.StackTrace;1const StackTrace = @import("std").builtin.StackTrace;
2pub fn panic(msg: []const u8, stack_trace: ?*StackTrace) noreturn {2pub fn panic(msg: []const u8, stack_trace: ?*StackTrace) noreturn {
3 _ = msg;
4 _ = stack_trace;
3 @breakpoint();5 @breakpoint();
4 while (true) {}6 while (true) {}
5}7}
test/standalone/issue_8550/main.zig+3-1
...@@ -1,6 +1,8 @@...@@ -1,6 +1,8 @@
1export fn main(r0: u32, r1: u32, atags: u32) callconv(.C) noreturn {1export fn main() callconv(.C) noreturn {
2 unreachable; // never gets run so it doesn't matter2 unreachable; // never gets run so it doesn't matter
3}3}
4pub fn panic(msg: []const u8, error_return_trace: ?*@import("std").builtin.StackTrace) noreturn {4pub fn panic(msg: []const u8, error_return_trace: ?*@import("std").builtin.StackTrace) noreturn {
5 _ = msg;
6 _ = error_return_trace;
5 while (true) {}7 while (true) {}
6}8}
test/tests.zig+2
...@@ -417,6 +417,8 @@ pub fn addStandaloneTests(b: *build.Builder, test_filter: ?[]const u8, modes: []...@@ -417,6 +417,8 @@ pub fn addStandaloneTests(b: *build.Builder, test_filter: ?[]const u8, modes: []
417}417}
418418
419pub fn addCliTests(b: *build.Builder, test_filter: ?[]const u8, modes: []const Mode) *build.Step {419pub fn addCliTests(b: *build.Builder, test_filter: ?[]const u8, modes: []const Mode) *build.Step {
420 _ = test_filter;
421 _ = modes;
420 const step = b.step("test-cli", "Test the command line interface");422 const step = b.step("test-cli", "Test the command line interface");
421423
422 const exe = b.addExecutable("test-cli", "test/cli.zig");424 const exe = b.addExecutable("test-cli", "test/cli.zig");
tools/process_headers.zig+3
...@@ -236,12 +236,14 @@ const DestTarget = struct {...@@ -236,12 +236,14 @@ const DestTarget = struct {
236236
237 const HashContext = struct {237 const HashContext = struct {
238 pub fn hash(self: @This(), a: DestTarget) u32 {238 pub fn hash(self: @This(), a: DestTarget) u32 {
239 _ = self;
239 return @enumToInt(a.arch) +%240 return @enumToInt(a.arch) +%
240 (@enumToInt(a.os) *% @as(u32, 4202347608)) +%241 (@enumToInt(a.os) *% @as(u32, 4202347608)) +%
241 (@enumToInt(a.abi) *% @as(u32, 4082223418));242 (@enumToInt(a.abi) *% @as(u32, 4082223418));
242 }243 }
243244
244 pub fn eql(self: @This(), a: DestTarget, b: DestTarget) bool {245 pub fn eql(self: @This(), a: DestTarget, b: DestTarget) bool {
246 _ = self;
245 return a.arch.eql(b.arch) and247 return a.arch.eql(b.arch) and
246 a.os == b.os and248 a.os == b.os and
247 a.abi == b.abi;249 a.abi == b.abi;
...@@ -256,6 +258,7 @@ const Contents = struct {...@@ -256,6 +258,7 @@ const Contents = struct {
256 is_generic: bool,258 is_generic: bool,
257259
258 fn hitCountLessThan(context: void, lhs: *const Contents, rhs: *const Contents) bool {260 fn hitCountLessThan(context: void, lhs: *const Contents, rhs: *const Contents) bool {
261 _ = context;
259 return lhs.hit_count < rhs.hit_count;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,6 +585,8 @@ const Syntax = union(enum) {
585 options: std.fmt.FormatOptions,585 options: std.fmt.FormatOptions,
586 out_stream: anytype,586 out_stream: anytype,
587 ) !void {587 ) !void {
588 _ = fmt;
589 _ = options;
588 switch (self) {590 switch (self) {
589 .multi_arg => |n| return out_stream.print(".{{.{s}={}}}", .{ @tagName(self), n }),591 .multi_arg => |n| return out_stream.print(".{{.{s}={}}}", .{ @tagName(self), n }),
590 else => return out_stream.print(".{s}", .{@tagName(self)}),592 else => return out_stream.print(".{s}", .{@tagName(self)}),
...@@ -663,6 +665,7 @@ fn syntaxMatchesWithEql(syntax: Syntax) bool {...@@ -663,6 +665,7 @@ fn syntaxMatchesWithEql(syntax: Syntax) bool {
663}665}
664666
665fn objectLessThan(context: void, a: *json.ObjectMap, b: *json.ObjectMap) bool {667fn objectLessThan(context: void, a: *json.ObjectMap, b: *json.ObjectMap) bool {
668 _ = context;
666 // Priority is determined by exact matches first, followed by prefix matches in descending669 // Priority is determined by exact matches first, followed by prefix matches in descending
667 // length, with key as a final tiebreaker.670 // length, with key as a final tiebreaker.
668 const a_syntax = objSyntax(a);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,14 +1227,17 @@ fn usageAndExit(file: fs.File, arg0: []const u8, code: u8) noreturn {
1227}1227}
12281228
1229fn featureLessThan(context: void, a: Feature, b: Feature) bool {1229fn featureLessThan(context: void, a: Feature, b: Feature) bool {
1230 _ = context;
1230 return std.ascii.lessThanIgnoreCase(a.zig_name, b.zig_name);1231 return std.ascii.lessThanIgnoreCase(a.zig_name, b.zig_name);
1231}1232}
12321233
1233fn cpuLessThan(context: void, a: Cpu, b: Cpu) bool {1234fn cpuLessThan(context: void, a: Cpu, b: Cpu) bool {
1235 _ = context;
1234 return std.ascii.lessThanIgnoreCase(a.zig_name, b.zig_name);1236 return std.ascii.lessThanIgnoreCase(a.zig_name, b.zig_name);
1235}1237}
12361238
1237fn asciiLessThan(context: void, a: []const u8, b: []const u8) bool {1239fn asciiLessThan(context: void, a: []const u8, b: []const u8) bool {
1240 _ = context;
1238 return std.ascii.lessThanIgnoreCase(a, b);1241 return std.ascii.lessThanIgnoreCase(a, b);
1239}1242}
12401243
tools/update_glibc.zig+5-3
...@@ -155,7 +155,7 @@ pub fn main() !void {...@@ -155,7 +155,7 @@ pub fn main() !void {
155 }155 }
156 const fn_set = &target_funcs_gop.value_ptr.list;156 const fn_set = &target_funcs_gop.value_ptr.list;
157157
158 for (lib_names) |lib_name, lib_name_index| {158 for (lib_names) |lib_name| {
159 const lib_prefix = if (std.mem.eql(u8, lib_name, "ld")) "" else "lib";159 const lib_prefix = if (std.mem.eql(u8, lib_name, "ld")) "" else "lib";
160 const basename = try fmt.allocPrint(allocator, "{s}{s}.abilist", .{ lib_prefix, lib_name });160 const basename = try fmt.allocPrint(allocator, "{s}{s}.abilist", .{ lib_prefix, lib_name });
161 const abi_list_filename = blk: {161 const abi_list_filename = blk: {
...@@ -263,7 +263,7 @@ pub fn main() !void {...@@ -263,7 +263,7 @@ pub fn main() !void {
263263
264 // Now the mapping of version and function to integer index is complete.264 // Now the mapping of version and function to integer index is complete.
265 // Here we create a mapping of function name to list of versions.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 const value = target_functions.getPtr(@ptrToInt(abi_list)).?;267 const value = target_functions.getPtr(@ptrToInt(abi_list)).?;
268 const fn_vers_list = &value.fn_vers_list;268 const fn_vers_list = &value.fn_vers_list;
269 for (value.list.items) |*ver_fn| {269 for (value.list.items) |*ver_fn| {
...@@ -286,7 +286,7 @@ pub fn main() !void {...@@ -286,7 +286,7 @@ pub fn main() !void {
286 const abilist_txt = buffered.writer();286 const abilist_txt = buffered.writer();
287287
288 // first iterate over the abi lists288 // first iterate over the abi lists
289 for (abi_lists) |*abi_list, abi_index| {289 for (abi_lists) |*abi_list| {
290 const fn_vers_list = &target_functions.getPtr(@ptrToInt(abi_list)).?.fn_vers_list;290 const fn_vers_list = &target_functions.getPtr(@ptrToInt(abi_list)).?.fn_vers_list;
291 for (abi_list.targets) |target, it_i| {291 for (abi_list.targets) |target, it_i| {
292 if (it_i != 0) try abilist_txt.writeByte(' ');292 if (it_i != 0) try abilist_txt.writeByte(' ');
...@@ -312,10 +312,12 @@ pub fn main() !void {...@@ -312,10 +312,12 @@ pub fn main() !void {
312}312}
313313
314pub fn strCmpLessThan(context: void, a: []const u8, b: []const u8) bool {314pub fn strCmpLessThan(context: void, a: []const u8, b: []const u8) bool {
315 _ = context;
315 return std.mem.order(u8, a, b) == .lt;316 return std.mem.order(u8, a, b) == .lt;
316}317}
317318
318pub fn versionLessThan(context: void, a: []const u8, b: []const u8) bool {319pub fn versionLessThan(context: void, a: []const u8, b: []const u8) bool {
320 _ = context;
319 const sep_chars = "GLIBC_.";321 const sep_chars = "GLIBC_.";
320 var a_tokens = std.mem.tokenize(a, sep_chars);322 var a_tokens = std.mem.tokenize(a, sep_chars);
321 var b_tokens = std.mem.tokenize(b, sep_chars);323 var b_tokens = std.mem.tokenize(b, sep_chars);
tools/update_spirv_features.zig+1
...@@ -37,6 +37,7 @@ const Version = struct {...@@ -37,6 +37,7 @@ const Version = struct {
37 }37 }
3838
39 fn lessThan(ctx: void, a: Version, b: Version) bool {39 fn lessThan(ctx: void, a: Version, b: Version) bool {
40 _ = ctx;
40 return if (a.major == b.major)41 return if (a.major == b.major)
41 a.minor < b.minor42 a.minor < b.minor
42 else43 else