authorgravatar for gbell12907@gmail.comCMDRZero <gbell12907@gmail.com> 2025-09-17 19:49:34-07:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-22 12:21:43+02:00
log64e4f9db8fa6fc47b0a2ef3143edacf472fb8c48
tree7566214af13ad8d95ade48e53c4013acfbe23f7c
parent16894c484c316c110a843ee15514790cc589dbfa

Implement partially ordered operator precedence


108 files changed, 727 insertions(+), 411 deletions(-)

lib/c/math.zig+2-2
......@@ -355,7 +355,7 @@ fn pow10f(x: f32) callconv(.c) f32 {
355355fn rint(x: f64) callconv(.c) f64 {
356356 const toint: f64 = 1.0 / math.floatEps(f64);
357357 const a: u64 = @bitCast(x);
358 const e = a >> 52 & 0x7ff;
358 const e = (a >> 52) & 0x7ff;
359359 const s = a >> 63;
360360 var y: f64 = undefined;
361361
......@@ -376,7 +376,7 @@ fn rint(x: f64) callconv(.c) f64 {
376376fn rintf(x: f32) callconv(.c) f32 {
377377 const toint: f32 = 1.0 / math.floatEps(f32);
378378 const a: u32 = @bitCast(x);
379 const e = a >> 23 & 0xff;
379 const e = (a >> 23) & 0xff;
380380 const s = a >> 31;
381381 var y: f32 = undefined;
382382
lib/c/stdlib/drand48.zig+6-6
......@@ -30,7 +30,7 @@ var lcg: Lcg = .init(0, default_multiplier, default_addend);
3030var seed48_xi: [3]c_ushort = undefined;
3131
3232fn erand48(xsubi: *[3]c_ushort) callconv(.c) f64 {
33 const xi = @as(u48, @as(u16, @truncate(xsubi[0])) | (@as(u48, @as(u16, @truncate(xsubi[1])))) << 16) | (@as(u48, @as(u16, @truncate(xsubi[2]))) << 32);
33 const xi = @as(u48, @as(u16, @truncate(xsubi[0])) | ((@as(u48, @as(u16, @truncate(xsubi[1])))) << 16)) | (@as(u48, @as(u16, @truncate(xsubi[2]))) << 32);
3434
3535 var separate_lcg: Lcg = .init(xi, lcg.a, lcg.c);
3636 const next_xi = separate_lcg.next();
......@@ -40,7 +40,7 @@ fn erand48(xsubi: *[3]c_ushort) callconv(.c) f64 {
4040}
4141
4242fn jrand48(xsubi: *[3]c_ushort) callconv(.c) c_long {
43 const xi = @as(u48, @as(u16, @truncate(xsubi[0])) | (@as(u48, @as(u16, @truncate(xsubi[1])))) << 16) | (@as(u48, @as(u16, @truncate(xsubi[2]))) << 32);
43 const xi = @as(u48, @as(u16, @truncate(xsubi[0])) | ((@as(u48, @as(u16, @truncate(xsubi[1])))) << 16)) | (@as(u48, @as(u16, @truncate(xsubi[2]))) << 32);
4444
4545 var separate_lcg: Lcg = .init(xi, lcg.a, lcg.c);
4646 const next_xi = separate_lcg.next();
......@@ -50,7 +50,7 @@ fn jrand48(xsubi: *[3]c_ushort) callconv(.c) c_long {
5050}
5151
5252fn nrand48(xsubi: *[3]c_ushort) callconv(.c) c_long {
53 const xi = @as(u48, @as(u16, @truncate(xsubi[0])) | (@as(u48, @as(u16, @truncate(xsubi[1])))) << 16) | (@as(u48, @as(u16, @truncate(xsubi[2]))) << 32);
53 const xi = @as(u48, @as(u16, @truncate(xsubi[0])) | ((@as(u48, @as(u16, @truncate(xsubi[1])))) << 16)) | (@as(u48, @as(u16, @truncate(xsubi[2]))) << 32);
5454
5555 var separate_lcg: Lcg = .init(xi, lcg.a, lcg.c);
5656 const next_xi = separate_lcg.next();
......@@ -74,14 +74,14 @@ fn mrand48() callconv(.c) c_long {
7474// 0..3 is `Xi`, 3..6 is `a`, 6 is `c`
7575// first low 16-bits, then mid, then high.
7676fn lcong48(param: *[7]c_ushort) callconv(.c) void {
77 lcg.xi = (@as(u48, @as(u16, @truncate(param[0]))) | (@as(u48, @as(u16, @truncate(param[1])))) << 16) | (@as(u48, @as(u16, @truncate(param[2]))) << 32);
78 lcg.a = (@as(u48, @as(u16, @truncate(param[3]))) | (@as(u48, @as(u16, @truncate(param[4])))) << 16) | (@as(u48, @as(u16, @truncate(param[5]))) << 32);
77 lcg.xi = (@as(u48, @as(u16, @truncate(param[0]))) | ((@as(u48, @as(u16, @truncate(param[1])))) << 16)) | (@as(u48, @as(u16, @truncate(param[2]))) << 32);
78 lcg.a = (@as(u48, @as(u16, @truncate(param[3]))) | ((@as(u48, @as(u16, @truncate(param[4])))) << 16)) | (@as(u48, @as(u16, @truncate(param[5]))) << 32);
7979 lcg.c = @as(u16, @truncate(param[6]));
8080}
8181
8282fn seed48(seed16v: *[3]c_ushort) callconv(.c) *[3]c_ushort {
8383 seed48_xi = .{ @truncate(lcg.xi & 0xFFFF), @truncate((lcg.xi >> 16) & 0xFFFF), @truncate((lcg.xi >> 32) & 0xFFFF) };
84 const xi = (@as(u48, @as(u16, @truncate(seed16v[0]))) | (@as(u48, @as(u16, @truncate(seed16v[1])))) << 16) | (@as(u48, @as(u16, @truncate(seed16v[2]))) << 32);
84 const xi = (@as(u48, @as(u16, @truncate(seed16v[0]))) | ((@as(u48, @as(u16, @truncate(seed16v[1])))) << 16)) | (@as(u48, @as(u16, @truncate(seed16v[2]))) << 32);
8585 lcg = .init(xi, default_multiplier, default_addend);
8686 return &seed48_xi;
8787}
lib/compiler/Maker/Step/Compile.zig+1-1
......@@ -45,7 +45,7 @@ pub fn make(
4545
4646 try lowerZigArgs(arena, compile_index, maker, progress_node, &argv, false);
4747
48 const incremental = conf_comp.flags4.incremental.toBool() orelse graph.incremental == true;
48 const incremental = conf_comp.flags4.incremental.toBool() orelse graph.incremental orelse false;
4949
5050 const opt_cache_digest = Step.evalZigProcess(
5151 compile_index,
lib/compiler/aro/aro/Compilation.zig+3-3
......@@ -287,7 +287,7 @@ fn generateSystemDefines(comp: *Compilation, w: *Io.Writer) !void {
287287 const gnuc_version = comp.langopts.gnuc_version orelse comp.langopts.emulate.defaultGccVersion();
288288 if (gnuc_version > 0) {
289289 try w.print("#define __GNUC__ {d}\n", .{gnuc_version / 10_000});
290 try w.print("#define __GNUC_MINOR__ {d}\n", .{gnuc_version / 100 % 100});
290 try w.print("#define __GNUC_MINOR__ {d}\n", .{(gnuc_version / 100) % 100});
291291 try w.print("#define __GNUC_PATCHLEVEL__ {d}\n", .{gnuc_version % 100});
292292 }
293293
......@@ -962,7 +962,7 @@ fn generateSystemDefines(comp: *Compilation, w: *Io.Writer) !void {
962962 try define(w, "__ARM_ARCH_EXT_IDIV__");
963963 }
964964 var sat = false;
965 if (arm_version == 6 and !target.cpu.has(.arm, .mclass) or arm_version > 6) {
965 if ((arm_version == 6 and !target.cpu.has(.arm, .mclass)) or arm_version > 6) {
966966 try define(w, "__ARM_FEATURE_SAT");
967967 sat = true;
968968 }
......@@ -2856,7 +2856,7 @@ test "addSourceFromBuffer - exhaustive check for carriage return elimination" {
28562856 if (buf[j] == alphabet[0]) buf[j - 1] = alphabet[(idx + 1) % alen] else break;
28572857 }
28582858 }
2859 try std.testing.expect(source_count == std.math.powi(usize, alen, alen) catch unreachable);
2859 try std.testing.expect(source_count == (std.math.powi(usize, alen, alen) catch unreachable));
28602860}
28612861
28622862test "ignore BOM at beginning of file" {
lib/compiler/aro/aro/Driver.zig+1-1
......@@ -1373,7 +1373,7 @@ fn getOutFileName(d: *Driver, source: Source, buf: *[std.fs.max_name_bytes]u8) !
13731373 if (d.only_preprocess_and_compile) ".s" else d.comp.target.ofmt.fileExt(d.comp.target.cpu.arch),
13741374 };
13751375 return d.output_name orelse
1376 mem.print(buf, fmt_template, fmt_args) catch return d.fatal("Filename too long for filesystem: " ++ fmt_template, fmt_args);
1376 (mem.print(buf, fmt_template, fmt_args) catch return d.fatal("Filename too long for filesystem: " ++ fmt_template, fmt_args));
13771377 }
13781378
13791379 return d.getRandomFilename(buf, d.comp.target.ofmt.fileExt(d.comp.target.cpu.arch));
lib/compiler/aro/aro/Parser.zig+1-1
......@@ -7084,7 +7084,7 @@ pub const Result = struct {
70847084 const b_child_qt = b.qt.get(p.comp, .pointer).?.child;
70857085
70867086 if (!a_child_qt.eql(b_child_qt, p.comp)) try p.err(tok, .incompatible_pointers, .{ a.qt, b.qt });
7087 if (a.qt.childType(p.comp).sizeofOrNull(p.comp) orelse 1 == 0) try p.err(tok, .subtract_pointers_zero_elem_size, .{a.qt.childType(p.comp)});
7087 if ((a.qt.childType(p.comp).sizeofOrNull(p.comp) orelse 1) == 0) try p.err(tok, .subtract_pointers_zero_elem_size, .{a.qt.childType(p.comp)});
70887088 a.qt = p.comp.type_store.ptrdiff;
70897089 }
70907090
lib/compiler/aro/aro/Preprocessor.zig+3-3
......@@ -310,13 +310,13 @@ pub const InitOptions = struct {
310310};
311311
312312pub fn init(comp: *Compilation, options: InitOptions) !Preprocessor {
313 const source_epoch: SourceEpoch = options.source_epoch orelse comp.environment.sourceEpoch(comp.io) catch |er| switch (er) {
313 const source_epoch: SourceEpoch = options.source_epoch orelse (comp.environment.sourceEpoch(comp.io) catch |er| switch (er) {
314314 error.InvalidEpoch => blk: {
315315 const diagnostic: Diagnostic = .invalid_source_epoch;
316316 try comp.diagnostics.add(.{ .text = diagnostic.fmt, .kind = diagnostic.kind, .opt = diagnostic.opt, .location = null });
317317 break :blk .default;
318318 },
319 };
319 });
320320
321321 var pp: Preprocessor = .{
322322 .comp = comp,
......@@ -3882,7 +3882,7 @@ pub fn prettyPrintTokens(pp: *Preprocessor, w: *std.Io.Writer, macro_dump_mode:
38823882 },
38833883 .keyword_pragma => {
38843884 const pragma_name = pp.expandedSlice(pp.tokens.get(i + 1));
3885 const end_idx = mem.findScalarPos(Token.Id, tok_ids, i, .nl) orelse i + 1;
3885 const end_idx = mem.findScalarPos(Token.Id, tok_ids, i, .nl) orelse (i + 1);
38863886 const pragma_len = @as(u32, @intCast(end_idx)) - i;
38873887
38883888 if (pp.comp.getPragma(pragma_name)) |prag| {
lib/compiler/aro/aro/Preprocessor/Parser.zig+1-1
......@@ -323,7 +323,7 @@ fn binaryExpr(p: *Parser, min_prec: Token.Precedence, eval: bool) Error!?Value {
323323 const else_res = try p.binaryExpr(op_prec, eval_else) orelse return null;
324324
325325 lhs = if (lhs.toBool()) rhs else else_res;
326 if (eval and rhs == .unsigned or else_res == .unsigned) {
326 if ((eval and rhs == .unsigned) or else_res == .unsigned) {
327327 try lhs.toUnsigned(p, operator, "right");
328328 }
329329 },
lib/compiler/aro/aro/char_info.zig+2-2
......@@ -492,7 +492,7 @@ pub fn isXidStart(c: u21) bool {
492492 assert(c > 0x7F);
493493 const idx = c / 8 / tables.chunk;
494494 const chunk: usize = if (idx < tables.trie_start.len) tables.trie_start[idx] else 0;
495 const offset = chunk * tables.chunk / 2 + c / 8 % tables.chunk;
495 const offset = chunk * tables.chunk / 2 + (c / 8) % tables.chunk;
496496 return (tables.leaf[offset] >> (@as(u3, @intCast(c % 8)))) & 1 != 0;
497497}
498498
......@@ -500,7 +500,7 @@ pub fn isXidContinue(c: u21) bool {
500500 assert(c > 0x7F);
501501 const idx = c / 8 / tables.chunk;
502502 const chunk: usize = if (idx < tables.trie_continue.len) tables.trie_continue[idx] else 0;
503 const offset = chunk * tables.chunk / 2 + c / 8 % tables.chunk;
503 const offset = chunk * tables.chunk / 2 + (c / 8) % tables.chunk;
504504 return (tables.leaf[offset] >> (@as(u3, @intCast(c % 8)))) & 1 != 0;
505505}
506506
lib/compiler/aro/aro/record_layout.zig+1-1
......@@ -324,7 +324,7 @@ const SysVContext = struct {
324324
325325 // On Clang, the alignment requested by annotations is not respected if it is
326326 // larger than the value of #pragma pack. See test case 0083.
327 if (annotation_alignment <= self.max_field_align_bits orelse std.math.maxInt(u29)) {
327 if (annotation_alignment <= (self.max_field_align_bits orelse std.math.maxInt(u29))) {
328328 field_align_bits = @max(field_align_bits, annotation_alignment);
329329 }
330330 // On Clang, if there are no packing annotations and the field would cross a
lib/compiler_rt/absv.zig+1-1
......@@ -11,7 +11,7 @@ pub inline fn absv(comptime ST: type, a: ST) ST {
1111 // compute the integer absolute value (abs) without branching
1212 var x: ST = a;
1313 const N: UT = @bitSizeOf(ST);
14 const sign: ST = a >> N - 1;
14 const sign: ST = a >> (N - 1);
1515 x +%= sign;
1616 x ^= sign;
1717 if (x < 0) @panic("integer overflow");
lib/compiler_rt/addf3.zig+1-1
......@@ -259,7 +259,7 @@ inline fn addf3(comptime T: type, a: T, b: T) T {
259259 // adjust the exponent:
260260 if (aSignificand & (integerBit << 4) != 0) {
261261 const sticky = aSignificand & 1;
262 aSignificand = aSignificand >> 1 | sticky;
262 aSignificand = (aSignificand >> 1) | sticky;
263263 aExponent += 1;
264264 }
265265 }
lib/compiler_rt/atomics.zig+1-1
......@@ -241,7 +241,7 @@ fn wideUpdate(comptime T: type, ptr: *T, val: T, update: anytype) T {
241241 while (true) {
242242 const old = @as(T, @truncate((wide_old & mask) >> inner_shift));
243243 const new = update(val, old);
244 const wide_new = wide_old & ~mask | (@as(WideAtomic, new) << inner_shift);
244 const wide_new = (wide_old & ~mask) | (@as(WideAtomic, new) << inner_shift);
245245 if (@cmpxchgWeak(WideAtomic, wide_ptr, wide_old, wide_new, .seq_cst, .seq_cst)) |new_wide_old| {
246246 wide_old = new_wide_old;
247247 } else {
lib/compiler_rt/comparef.zig+4-4
......@@ -130,13 +130,13 @@ fn __aeabi_fcmplt(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 {
130130 return @intFromBool(cmp_f32(a, b) == .lt);
131131}
132132fn __aeabi_fcmple(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 {
133 return @intFromBool(cmp_f32(a, b) orelse .gt != .gt);
133 return @intFromBool((cmp_f32(a, b) orelse .gt) != .gt);
134134}
135135fn __gesf2(a: compiler_rt.f32.Abi, b: compiler_rt.f32.Abi) callconv(.c) Order {
136136 return cmp_f32(compiler_rt.f32.fromAbi(a), compiler_rt.f32.fromAbi(b)) orelse .lt;
137137}
138138fn __aeabi_fcmpge(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 {
139 return @intFromBool(cmp_f32(a, b) orelse .lt != .lt);
139 return @intFromBool((cmp_f32(a, b) orelse .lt) != .lt);
140140}
141141fn __aeabi_fcmpgt(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 {
142142 return @intFromBool(cmp_f32(a, b) == .gt);
......@@ -164,13 +164,13 @@ fn __aeabi_dcmplt(a: f64, b: f64) callconv(.{ .arm_aapcs = .{} }) i32 {
164164 return @intFromBool(cmp_f64(a, b) == .lt);
165165}
166166fn __aeabi_dcmple(a: f64, b: f64) callconv(.{ .arm_aapcs = .{} }) i32 {
167 return @intFromBool(cmp_f64(a, b) orelse .gt != .gt);
167 return @intFromBool((cmp_f64(a, b) orelse .gt) != .gt);
168168}
169169fn __gedf2(a: compiler_rt.f64.Abi, b: compiler_rt.f64.Abi) callconv(.c) Order {
170170 return cmp_f64(compiler_rt.f64.fromAbi(a), compiler_rt.f64.fromAbi(b)) orelse .lt;
171171}
172172fn __aeabi_dcmpge(a: f64, b: f64) callconv(.{ .arm_aapcs = .{} }) i32 {
173 return @intFromBool(cmp_f64(a, b) orelse .lt != .lt);
173 return @intFromBool((cmp_f64(a, b) orelse .lt) != .lt);
174174}
175175fn __aeabi_dcmpgt(a: f64, b: f64) callconv(.{ .arm_aapcs = .{} }) i32 {
176176 return @intFromBool(cmp_f64(a, b) == .gt);
lib/compiler_rt/divdf3.zig+8-8
......@@ -119,12 +119,12 @@ pub fn div_f64(a: f64, b: f64) f64 {
119119 // with each iteration, so after three iterations, we have about 28 binary
120120 // digits of accuracy.
121121 var correction32: u32 = undefined;
122 correction32 = @truncate(~(@as(u64, recip32) *% q31b >> 32) +% 1);
123 recip32 = @truncate(@as(u64, recip32) *% correction32 >> 31);
124 correction32 = @truncate(~(@as(u64, recip32) *% q31b >> 32) +% 1);
125 recip32 = @truncate(@as(u64, recip32) *% correction32 >> 31);
126 correction32 = @truncate(~(@as(u64, recip32) *% q31b >> 32) +% 1);
127 recip32 = @truncate(@as(u64, recip32) *% correction32 >> 31);
122 correction32 = @truncate(~((@as(u64, recip32) *% q31b) >> 32) +% 1);
123 recip32 = @truncate((@as(u64, recip32) *% correction32) >> 31);
124 correction32 = @truncate(~((@as(u64, recip32) *% q31b) >> 32) +% 1);
125 recip32 = @truncate((@as(u64, recip32) *% correction32) >> 31);
126 correction32 = @truncate(~((@as(u64, recip32) *% q31b) >> 32) +% 1);
127 recip32 = @truncate((@as(u64, recip32) *% correction32) >> 31);
128128
129129 // recip32 might have overflowed to exactly zero in the preceding
130130 // computation if the high word of b is exactly 1.0. This would sabotage
......@@ -137,10 +137,10 @@ pub fn div_f64(a: f64, b: f64) f64 {
137137 const q63blo: u32 = @truncate(bSignificand << 11);
138138 var correction: u64 = undefined;
139139 var reciprocal: u64 = undefined;
140 correction = ~(@as(u64, recip32) *% q31b +% (@as(u64, recip32) *% q63blo >> 32)) +% 1;
140 correction = ~(@as(u64, recip32) *% q31b +% ((@as(u64, recip32) *% q63blo) >> 32)) +% 1;
141141 const cHi: u32 = @truncate(correction >> 32);
142142 const cLo: u32 = @truncate(correction);
143 reciprocal = @as(u64, recip32) *% cHi +% (@as(u64, recip32) *% cLo >> 32);
143 reciprocal = @as(u64, recip32) *% cHi +% ((@as(u64, recip32) *% cLo) >> 32);
144144
145145 // We already adjusted the 32-bit estimate, now we need to adjust the final
146146 // 64-bit reciprocal estimate downward to ensure that it is strictly smaller
lib/compiler_rt/divsf3.zig+7-7
......@@ -126,12 +126,12 @@ pub fn div_f32(a: f32, b: f32) f32 {
126126 // with each iteration, so after three iterations, we have about 28 binary
127127 // digits of accuracy.
128128 var correction: u32 = undefined;
129 correction = @truncate(~(@as(u64, reciprocal) *% q31b >> 32) +% 1);
130 reciprocal = @truncate(@as(u64, reciprocal) *% correction >> 31);
131 correction = @truncate(~(@as(u64, reciprocal) *% q31b >> 32) +% 1);
132 reciprocal = @truncate(@as(u64, reciprocal) *% correction >> 31);
133 correction = @truncate(~(@as(u64, reciprocal) *% q31b >> 32) +% 1);
134 reciprocal = @truncate(@as(u64, reciprocal) *% correction >> 31);
129 correction = @truncate(~((@as(u64, reciprocal) *% q31b) >> 32) +% 1);
130 reciprocal = @truncate((@as(u64, reciprocal) *% correction) >> 31);
131 correction = @truncate(~((@as(u64, reciprocal) *% q31b) >> 32) +% 1);
132 reciprocal = @truncate((@as(u64, reciprocal) *% correction) >> 31);
133 correction = @truncate(~((@as(u64, reciprocal) *% q31b) >> 32) +% 1);
134 reciprocal = @truncate((@as(u64, reciprocal) *% correction) >> 31);
135135
136136 // Exhaustive testing shows that the error in reciprocal after three steps
137137 // is in the interval [-0x1.f58108p-31, 0x1.d0e48cp-29], in line with our
......@@ -153,7 +153,7 @@ pub fn div_f32(a: f32, b: f32) f32 {
153153 // is the error in the reciprocal of b scaled by the maximum
154154 // possible value of a. As a consequence of this error bound,
155155 // either q or nextafter(q) is the correctly rounded
156 var quotient: Z = @truncate(@as(u64, reciprocal) *% (aSignificand << 1) >> 32);
156 var quotient: Z = @truncate((@as(u64, reciprocal) *% (aSignificand << 1)) >> 32);
157157
158158 // Two cases: quotient is in [0.5, 1.0) or quotient is in [1.0, 2.0).
159159 // In either case, we are going to compute a residual of the form
lib/compiler_rt/divtf3.zig+10-10
......@@ -119,16 +119,16 @@ pub fn div_f128(a: f128, b: f128) f128 {
119119 // This doubles the number of correct binary digits in the approximation
120120 // with each iteration.
121121 var correction64: u64 = undefined;
122 correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1);
123 recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63);
124 correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1);
125 recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63);
126 correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1);
127 recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63);
128 correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1);
129 recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63);
130 correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1);
131 recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63);
122 correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1);
123 recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63);
124 correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1);
125 recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63);
126 correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1);
127 recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63);
128 correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1);
129 recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63);
130 correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1);
131 recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63);
132132
133133 // The reciprocal may have overflowed to zero if the upper half of b is
134134 // exactly 1.0. This would sabatoge the full-width final stage of the
lib/compiler_rt/divxf3.zig+10-10
......@@ -102,16 +102,16 @@ pub fn div_f80(a: f80, b: f80) f80 {
102102 // This doubles the number of correct binary digits in the approximation
103103 // with each iteration.
104104 var correction64: u64 = undefined;
105 correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1);
106 recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63);
107 correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1);
108 recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63);
109 correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1);
110 recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63);
111 correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1);
112 recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63);
113 correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1);
114 recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63);
105 correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1);
106 recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63);
107 correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1);
108 recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63);
109 correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1);
110 recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63);
111 correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1);
112 recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63);
113 correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1);
114 recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63);
115115
116116 // The reciprocal may have overflowed to zero if the upper half of b is
117117 // exactly 1.0. This would sabatoge the full-width final stage of the
lib/compiler_rt/elf/tls.zig+1-1
......@@ -251,7 +251,7 @@ fn setThreadPointer(addr: usize) void {
251251 // Update the %gs selector
252252 asm volatile ("movl %[gs_val], %%gs"
253253 :
254 : [gs_val] "r" (gdt_entry_number << 3 | 3),
254 : [gs_val] "r" ((gdt_entry_number << 3) | 3),
255255 );
256256 },
257257 .x86_64 => {
lib/compiler_rt/extendf.zig+2-2
......@@ -165,7 +165,7 @@ pub fn f128_floatCast_f80(a: f80) f128 {
165165 }
166166
167167 // Apply the signbit to (dst_t)abs(a).
168 const result: u128 = abs_result | @as(u128, sign) << (dst_bits - 16);
168 const result: u128 = abs_result | (@as(u128, sign) << (dst_bits - 16));
169169 return @bitCast(result);
170170}
171171
......@@ -232,7 +232,7 @@ inline fn extendf(comptime dst_t: type, comptime src_t: type, f: src_t) dst_t {
232232 }
233233
234234 // Apply the signbit to (dst_t)abs(a).
235 const result: dst_rep_t = absResult | @as(dst_rep_t, sign) << (dstBits - srcBits);
235 const result: dst_rep_t = absResult | (@as(dst_rep_t, sign) << (dstBits - srcBits));
236236 return @bitCast(result);
237237}
238238
lib/compiler_rt/floor_ceil.zig+4-4
......@@ -141,13 +141,13 @@ inline fn impl(comptime T: type, comptime op: enum { floor, ceil }, x: T) T {
141141 const m = (@as(U, 1) << @intCast(mantissa - e)) - 1;
142142 if (u & m == 0) return x;
143143 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1.0p120);
144 if (u >> bits - 1 == @intFromBool(op == .floor)) u += m;
144 if (u >> (bits - 1) == @intFromBool(op == .floor)) u += m;
145145 return @bitCast(u & ~m);
146146 } else {
147147 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1.0p120);
148148 return switch (op) {
149 .floor => if (u >> bits - 1 == 0) 0.0 else if (u << 1 != 0) -1.0 else x,
150 .ceil => if (u >> bits - 1 != 0) -0.0 else if (u << 1 != 0) 1.0 else x,
149 .floor => if (u >> (bits - 1) == 0) 0.0 else if (u << 1 != 0) -1.0 else x,
150 .ceil => if (u >> (bits - 1) != 0) -0.0 else if (u << 1 != 0) 1.0 else x,
151151 };
152152 }
153153 },
......@@ -155,7 +155,7 @@ inline fn impl(comptime T: type, comptime op: enum { floor, ceil }, x: T) T {
155155 const e = (u >> mantissa) & mask;
156156 if (e >= bias + math.floatFractionalBits(T) or x == 0) return x;
157157
158 const positive = u >> @bitSizeOf(T) - 1 == 0;
158 const positive = u >> (@bitSizeOf(T) - 1) == 0;
159159 const y: T = if (positive)
160160 x + C - C - x
161161 else
lib/compiler_rt/fmod.zig+2-2
......@@ -204,8 +204,8 @@ pub fn fmod_f128(a: f128, b: f128) f128 {
204204 }
205205
206206 // OR in extra non-stored mantissa digit
207 var highA: u64 = (aPtr_u64[high_index] & (std.math.maxInt(u64) >> 16)) | 1 << 48;
208 const highB: u64 = (bPtr_u64[high_index] & (std.math.maxInt(u64) >> 16)) | 1 << 48;
207 var highA: u64 = (aPtr_u64[high_index] & (std.math.maxInt(u64) >> 16)) | (1 << 48);
208 const highB: u64 = (bPtr_u64[high_index] & (std.math.maxInt(u64) >> 16)) | (1 << 48);
209209 var lowA: u64 = aPtr_u64[low_index];
210210 const lowB: u64 = bPtr_u64[low_index];
211211
lib/compiler_rt/mulf3.zig+1-1
......@@ -237,7 +237,7 @@ fn wideShrWithTruncation(comptime Z: type, hi: *Z, lo: *Z, count: u32) bool {
237237 lo.* = (hi.* << @intCast(typeWidth -% count)) | (lo.* >> @intCast(count));
238238 hi.* = hi.* >> @intCast(count);
239239 } else if (count < 2 * typeWidth) {
240 inexact = (hi.* << @intCast(2 * typeWidth -% count) | lo.*) != 0;
240 inexact = ((hi.* << @intCast(2 * typeWidth -% count)) | lo.*) != 0;
241241 lo.* = hi.* >> @intCast(count -% typeWidth);
242242 hi.* = 0;
243243 } else {
lib/compiler_rt/rem_pio2l.zig+1-1
......@@ -37,7 +37,7 @@ pub fn rem_pio2l(comptime T: type, x: T, y: *[2]T) i32 {
3737 const se = ld.signExponent(x_val);
3838 const top = ld.mantissaTop(x_val);
3939 const lhs = (@as(u32, se & 0x7fff) << 16) | top;
40 const rhs: u32 = ((0x3fff + 25) << 16) | 0x921f >> 1 | 0x8000;
40 const rhs: u32 = ((0x3fff + 25) << 16) | (0x921f >> 1) | 0x8000;
4141 return lhs < rhs;
4242 }
4343
lib/compiler_rt/sqrt.zig+5-5
......@@ -523,15 +523,15 @@ const rsqrt_tab: [128]u16 = .{
523523};
524524
525525inline fn mul16(a: u16, b: u16) u16 {
526 return @intCast(@as(u32, a) * b >> 16);
526 return @intCast((@as(u32, a) * b) >> 16);
527527}
528528
529529inline fn mul32(a: u32, b: u32) u32 {
530 return @intCast(@as(u64, a) * b >> 32);
530 return @intCast((@as(u64, a) * b) >> 32);
531531}
532532
533533inline fn mul64(a: u64, b: u64) u64 {
534 return @intCast(@as(u128, a) * b >> 64);
534 return @intCast((@as(u128, a) * b) >> 64);
535535}
536536
537537inline fn mul80(a: u80, b: u80) u80 {
......@@ -539,7 +539,7 @@ inline fn mul80(a: u80, b: u80) u80 {
539539 const alo = a & 0xFF_FFFF_FFFF;
540540 const bhi = b >> 40;
541541 const blo = b & 0xFF_FFFF_FFFF;
542 return ahi * bhi + (ahi * blo >> 40) + (alo * bhi >> 40);
542 return ahi * bhi + ((ahi * blo) >> 40) + ((alo * bhi) >> 40);
543543}
544544
545545inline fn mul128(a: u128, b: u128) u128 {
......@@ -547,7 +547,7 @@ inline fn mul128(a: u128, b: u128) u128 {
547547 const alo = a & 0xFFFF_FFFF_FFFF_FFFF;
548548 const bhi = b >> 64;
549549 const blo = b & 0xFFFF_FFFF_FFFF_FFFF;
550 return ahi * bhi + (ahi * blo >> 64) + (alo * bhi >> 64);
550 return ahi * bhi + ((ahi * blo) >> 64) + ((alo * bhi) >> 64);
551551}
552552
553553inline fn mul80_tail(a: u80, b: u80) u80 {
lib/compiler_rt/truncf.zig+3-3
......@@ -279,7 +279,7 @@ inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t {
279279 absResult = 0;
280280 } else {
281281 const sticky: src_rep_t = @intFromBool(significand << @intCast(srcBits - shift) != 0);
282 const denormalizedSignificand: src_rep_t = significand >> @intCast(shift) | sticky;
282 const denormalizedSignificand: src_rep_t = (significand >> @intCast(shift)) | sticky;
283283 absResult = @intCast(denormalizedSignificand >> (srcSigBits - dstSigBits));
284284 const roundBits: src_rep_t = denormalizedSignificand & roundMask;
285285 if (roundBits > halfway) {
......@@ -362,7 +362,7 @@ inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t {
362362 abs_result = 0;
363363 } else {
364364 const sticky = @intFromBool(a_rep.fraction << @intCast(shift) != 0);
365 const denormalized_significand = a_rep.fraction >> @intCast(shift) | sticky;
365 const denormalized_significand = (a_rep.fraction >> @intCast(shift)) | sticky;
366366 abs_result = @intCast(denormalized_significand >> (src_sig_bits - dst_sig_bits));
367367 const round_bits = denormalized_significand & round_mask;
368368 if (round_bits > halfway) {
......@@ -375,7 +375,7 @@ inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t {
375375 }
376376 }
377377
378 const result align(@alignOf(dst_t)) = abs_result | @as(dst_rep_t, sign) << dst_bits - 16;
378 const result align(@alignOf(dst_t)) = abs_result | (@as(dst_rep_t, sign) << (dst_bits - 16));
379379 return @bitCast(result);
380380}
381381
lib/std/Io/Dispatch.zig+2-2
......@@ -1931,10 +1931,10 @@ const BatchWaiter = struct {
19311931
19321932fn batchAwaitAsync(userdata: ?*anyopaque, batch: *Io.Batch) Io.Cancelable!void {
19331933 const ev: *Evented = @ptrCast(@alignCast(userdata));
1934 const queue = ev.batchDrainSubmitted(batch, false) catch |err| switch (err) {
1934 const queue = (ev.batchDrainSubmitted(batch, false) catch |err| switch (err) {
19351935 error.ConcurrencyUnavailable => unreachable, // passed concurrency=false
19361936 error.Canceled => |e| return e,
1937 } orelse return;
1937 }) orelse return;
19381938 if (batch.pending.head == .none) return;
19391939 var waiter: BatchWaiter = .{
19401940 .sleeper = .init(ev.queue, Thread.current().currentFiber()),
lib/std/Io/Kqueue.zig+1-1
......@@ -164,7 +164,7 @@ pub const InitError = Allocator.Error || CreateFileDescriptorError;
164164pub fn init(k: *Kqueue, gpa: Allocator, options: InitOptions) !void {
165165 assert(options.n_threads != 0);
166166
167 const n_threads = @max(1, options.n_threads orelse std.Thread.getCpuCount() catch 1);
167 const n_threads = @max(1, options.n_threads orelse (std.Thread.getCpuCount() catch 1));
168168 const threads_size = n_threads * @sizeOf(Thread);
169169 const idle_stack_end_offset = std.mem.alignForward(usize, threads_size + idle_stack_size, std.heap.page_size_max);
170170 const allocated_slice = try gpa.alignedAlloc(u8, .of(Thread), idle_stack_end_offset);
lib/std/Io/Threaded/test.zig+1-1
......@@ -36,7 +36,7 @@ fn put(io: Io, queue: *Io.Queue(u8)) void {
3636}
3737
3838fn get(io: Io, queue: *Io.Queue(u8)) void {
39 assert(queue.getOneUncancelable(io) catch unreachable == 42);
39 assert((queue.getOneUncancelable(io) catch unreachable) == 42);
4040}
4141
4242test "concurrent vs concurrent prevents deadlock via oversubscription" {
lib/std/Io/Writer.zig+1-1
......@@ -1827,7 +1827,7 @@ pub fn printFloatHex(w: *Writer, value: anytype, case: std.fmt.Case, opt_precisi
18271827 // Restore the alignment.
18281828 mantissa <<= @as(std.math.Log2Int(TU), @intCast((mantissa_digits - precision) * 4));
18291829
1830 const overflow = mantissa & (1 << 1 + mantissa_digits * 4) != 0;
1830 const overflow = mantissa & (1 << (1 + mantissa_digits * 4)) != 0;
18311831 // Prefer a normalized result in case of overflow.
18321832 if (overflow) {
18331833 mantissa >>= 1;
lib/std/Io/net/HostName.zig+1-1
......@@ -230,7 +230,7 @@ pub fn expand(noalias packet: []const u8, start_i: usize, noalias dest_buffer: [
230230 i += 1 + label_len;
231231 } else {
232232 return .{
233 len orelse i - start_i + 1,
233 len orelse (i - start_i + 1),
234234 try .init(dest[0..dest_i]),
235235 };
236236 }
lib/std/base64.zig+3-3
......@@ -148,7 +148,7 @@ pub const Base64Encoder = struct {
148148 if (idx + 2 < source.len) {
149149 dest[out_idx] = encoder.alphabet_chars[source[idx] >> 2];
150150 dest[out_idx + 1] = encoder.alphabet_chars[((source[idx] & 0x3) << 4) | (source[idx + 1] >> 4)];
151 dest[out_idx + 2] = encoder.alphabet_chars[(source[idx + 1] & 0xf) << 2 | (source[idx + 2] >> 6)];
151 dest[out_idx + 2] = encoder.alphabet_chars[((source[idx + 1] & 0xf) << 2) | (source[idx + 2] >> 6)];
152152 dest[out_idx + 3] = encoder.alphabet_chars[source[idx + 2] & 0x3f];
153153 out_idx += 4;
154154 } else if (idx + 1 < source.len) {
......@@ -282,7 +282,7 @@ pub const Base64Decoder = struct {
282282 dest_idx += 1;
283283 }
284284 }
285 if (acc_len > 4 or (acc & (@as(u12, 1) << acc_len) - 1) != 0) {
285 if (acc_len > 4 or (acc & ((@as(u12, 1) << acc_len) - 1)) != 0) {
286286 return error.InvalidPadding;
287287 }
288288 if (leftover_idx == null) return;
......@@ -357,7 +357,7 @@ pub const Base64DecoderWithIgnore = struct {
357357 dest_idx += 1;
358358 }
359359 }
360 if (acc_len > 4 or (acc & (@as(u12, 1) << acc_len) - 1) != 0) {
360 if (acc_len > 4 or (acc & ((@as(u12, 1) << acc_len) - 1)) != 0) {
361361 return error.InvalidPadding;
362362 }
363363 const padding_len = acc_len / 2;
lib/std/bit_set.zig+4-4
......@@ -468,11 +468,11 @@ pub fn Array(comptime MaskIntType: type, comptime size: usize) type {
468468
469469 if (start_mask_index == end_mask_index) {
470470 var mask1 = std.math.boolMask(MaskInt, true) << start_bit;
471 var mask2 = std.math.boolMask(MaskInt, true) >> (mask_len - 1) - (end_bit - 1);
471 var mask2 = std.math.boolMask(MaskInt, true) >> ((mask_len - 1) - (end_bit - 1));
472472 self.masks[start_mask_index] &= ~(mask1 & mask2);
473473
474474 mask1 = std.math.boolMask(MaskInt, value) << start_bit;
475 mask2 = std.math.boolMask(MaskInt, value) >> (mask_len - 1) - (end_bit - 1);
475 mask2 = std.math.boolMask(MaskInt, value) >> ((mask_len - 1) - (end_bit - 1));
476476 self.masks[start_mask_index] |= mask1 & mask2;
477477 } else {
478478 var bulk_mask_index: usize = undefined;
......@@ -875,11 +875,11 @@ pub const Dynamic = struct {
875875
876876 if (start_mask_index == end_mask_index) {
877877 var mask1 = std.math.boolMask(MaskInt, true) << start_bit;
878 var mask2 = std.math.boolMask(MaskInt, true) >> (@bitSizeOf(MaskInt) - 1) - (end_bit - 1);
878 var mask2 = std.math.boolMask(MaskInt, true) >> ((@bitSizeOf(MaskInt) - 1) - (end_bit - 1));
879879 self.masks[start_mask_index] &= ~(mask1 & mask2);
880880
881881 mask1 = std.math.boolMask(MaskInt, value) << start_bit;
882 mask2 = std.math.boolMask(MaskInt, value) >> (@bitSizeOf(MaskInt) - 1) - (end_bit - 1);
882 mask2 = std.math.boolMask(MaskInt, value) >> ((@bitSizeOf(MaskInt) - 1) - (end_bit - 1));
883883 self.masks[start_mask_index] |= mask1 & mask2;
884884 } else {
885885 var bulk_mask_index: usize = undefined;
lib/std/coff.zig+1-1
......@@ -2035,7 +2035,7 @@ pub const ArchiveMemberHeader = extern struct {
20352035 if (trim.len == 0) return error.BadName;
20362036 return if (trim[0] == '/') name: {
20372037 if (trim.len == 1 or
2038 trim.len == 2 and trim[1] == '/')
2038 (trim.len == 2 and trim[1] == '/'))
20392039 break :name trim;
20402040
20412041 const offset = std.fmt.parseUnsigned(u50, trim[1..], 10) catch
lib/std/compress/flate/Compress.zig+2-2
......@@ -1333,8 +1333,8 @@ const huffman = struct {
13331333
13341334 const incomplete_allowed = smith.value(bool);
13351335 while (nfreqs < @as(u8, @intFromBool(!incomplete_allowed)) + 1 or
1336 nfreqs != freqs_buf.len and freqs_limit != 0 and
1337 smith.eosWeightedSimple(15, 1))
1336 (nfreqs != freqs_buf.len and freqs_limit != 0 and
1337 smith.eosWeightedSimple(15, 1)))
13381338 {
13391339 const f = smith.valueWeighted(u16, &.{
13401340 .rangeAtMost(u16, 0, @min(31, freqs_limit), @max(freqs_limit, 1)),
lib/std/crypto/aes/soft.zig+1-1
......@@ -728,7 +728,7 @@ pub const Aes256 = struct {
728728// constants
729729
730730// Rijndael's irreducible polynomial.
731const poly: u9 = 1 << 8 | 1 << 4 | 1 << 3 | 1 << 1 | 1 << 0; // x⁸ + x⁴ + x³ + x + 1
731const poly: u9 = (1 << 8) | (1 << 4) | (1 << 3) | (1 << 1) | (1 << 0); // x⁸ + x⁴ + x³ + x + 1
732732
733733// Powers of x mod poly in GF(2).
734734const powx = init: {
lib/std/crypto/codecs/base64_hex_ct.zig+1-1
......@@ -29,7 +29,7 @@ pub const hex = struct {
2929 const c: u16 = v & 0xf;
3030 const off = if (case == .upper) 32 else 0;
3131 const x =
32 ((87 - off + c + (((c -% 10) >> 8) & ~@as(u16, 38 - off))) & 0xff) << 8 |
32 (((87 - off + c + (((c -% 10) >> 8) & ~@as(u16, 38 - off))) & 0xff) << 8) |
3333 ((87 - off + b + (((b -% 10) >> 8) & ~@as(u16, 38 - off))) & 0xff);
3434 encoded[i * 2] = @truncate(x);
3535 encoded[i * 2 + 1] = @truncate(x >> 8);
lib/std/crypto/ml_kem.zig+1-1
......@@ -1264,7 +1264,7 @@ const Poly = struct {
12641264 const b1 = @as(i16, buf[3 * i + 1]);
12651265 const b2 = @as(i16, buf[3 * i + 2]);
12661266 ret.cs[2 * i] = b0 | ((b1 & 0xf) << 8);
1267 ret.cs[2 * i + 1] = (b1 >> 4) | b2 << 4;
1267 ret.cs[2 * i + 1] = (b1 >> 4) | (b2 << 4);
12681268 }
12691269 return ret;
12701270 }
lib/std/crypto/scrypt.zig+1-1
......@@ -82,7 +82,7 @@ fn blockMix(tmp: *align(16) [16]u32, in: []align(16) const u32, out: []align(16)
8282
8383fn integerify(b: []align(16) const u32, r: u30) u64 {
8484 const j = (2 * r - 1) * 16;
85 return @as(u64, b[j]) | @as(u64, b[j + 1]) << 32;
85 return @as(u64, b[j]) | (@as(u64, b[j + 1]) << 32);
8686}
8787
8888fn smix(b: []align(16) u8, r: u30, n: usize, v: []align(16) u32, xy: []align(16) u32) void {
lib/std/crypto/sha2.zig+1-1
......@@ -557,7 +557,7 @@ fn Sha2x64(comptime iv: Iv64, digest_bits: comptime_int) type {
557557 }
558558
559559 if (digest_bits % 8 != 0) @compileError("impl doesn't support non-byte digest_len");
560 const bytes_left = digest_bits / 8 % 8;
560 const bytes_left = (digest_bits / 8) % 8;
561561 if (bytes_left > 0) {
562562 const rest = d.s[(digest_bits / 64)];
563563 var buf: [8]u8 = undefined;
lib/std/debug.zig+1-1
......@@ -1306,7 +1306,7 @@ fn printLineInfo(
13061306 try writer.print("0x{x} in {s} ({s})", .{
13071307 address,
13081308 symbol.name orelse "???",
1309 symbol.compile_unit_name orelse debug_info.getModuleName(io, address) catch "???",
1309 symbol.compile_unit_name orelse (debug_info.getModuleName(io, address) catch "???"),
13101310 });
13111311 t.setColor(.reset) catch {};
13121312 try writer.writeAll("\n");
lib/std/debug/SelfInfo/Elf.zig+4-4
......@@ -16,11 +16,11 @@ pub fn deinit(si: *SelfInfo, io: Io) void {
1616 const gpa = std.debug.getDebugInfoAllocator();
1717 for (si.modules.items) |*mod| {
1818 unwind: {
19 const u = &(mod.unwind orelse break :unwind catch break :unwind);
19 const u = &((mod.unwind orelse break :unwind) catch break :unwind);
2020 for (u.buf[0..u.len]) |*unwind| unwind.deinit(gpa);
2121 }
2222 loaded: {
23 const l = &(mod.loaded_elf orelse break :loaded catch break :loaded);
23 const l = &((mod.loaded_elf orelse break :loaded) catch break :loaded);
2424 l.file.deinit(gpa);
2525 }
2626 }
......@@ -431,11 +431,11 @@ fn findModule(si: *SelfInfo, gpa: Allocator, io: Io, address: usize, lock: enum
431431 }
432432 for (si.modules.items) |*mod| {
433433 unwind: {
434 const u = &(mod.unwind orelse break :unwind catch break :unwind);
434 const u = &((mod.unwind orelse break :unwind) catch break :unwind);
435435 for (u.buf[0..u.len]) |*unwind| unwind.deinit(gpa);
436436 }
437437 loaded: {
438 const l = &(mod.loaded_elf orelse break :loaded catch break :loaded);
438 const l = &((mod.loaded_elf orelse break :loaded) catch break :loaded);
439439 l.file.deinit(gpa);
440440 }
441441 }
lib/std/debug/SelfInfo/MachO.zig+2-2
......@@ -11,11 +11,11 @@ pub fn deinit(si: *SelfInfo, io: Io) void {
1111 const gpa = std.debug.getDebugInfoAllocator();
1212 for (si.modules.keys()) |*module| {
1313 unwind: {
14 const u = &(module.unwind orelse break :unwind catch break :unwind);
14 const u = &((module.unwind orelse break :unwind) catch break :unwind);
1515 if (u.dwarf) |*dwarf| dwarf.deinit(gpa);
1616 }
1717 file: {
18 const f = &(module.file orelse break :file catch break :file);
18 const f = &((module.file orelse break :file) catch break :file);
1919 f.deinit(gpa);
2020 }
2121 }
lib/std/debug/SelfInfo/Windows.zig+4-4
......@@ -280,7 +280,7 @@ const Module = struct {
280280 // we have no information to add to the address
281281 break :pdb;
282282 };
283 const module = pdb.getModule(mod_index) catch |err| switch (err) {
283 const module = (pdb.getModule(mod_index) catch |err| switch (err) {
284284 error.InvalidDebugInfo,
285285 error.MissingDebugInfo,
286286 error.OutOfMemory,
......@@ -289,7 +289,7 @@ const Module = struct {
289289 error.ReadFailed,
290290 error.EndOfStream,
291291 => return error.InvalidDebugInfo,
292 } orelse {
292 }) orelse {
293293 return error.InvalidDebugInfo; // bad module index
294294 };
295295
......@@ -539,9 +539,9 @@ const Module = struct {
539539 }
540540
541541 var opt_pdb: ?Pdb = pdb: {
542 const path = coff_obj.getPdbPath() catch {
542 const path = (coff_obj.getPdbPath() catch {
543543 return error.InvalidDebugInfo;
544 } orelse {
544 }) orelse {
545545 break :pdb null;
546546 };
547547 const pdb_file_open_result = if (fs.path.isAbsolute(path)) res: {
lib/std/dynamic_library.zig+7-7
......@@ -13,7 +13,7 @@ const posix = std.posix;
1313/// Platform-specific functionality is available through the `inner` field.
1414pub const DynLib = struct {
1515 const InnerType = switch (native_os) {
16 .linux => if (!builtin.link_libc or builtin.abi == .musl and builtin.link_mode == .static)
16 .linux => if (!builtin.link_libc or (builtin.abi == .musl and builtin.link_mode == .static))
1717 ElfDynLib
1818 else
1919 DlDynLib,
......@@ -434,15 +434,15 @@ pub const ElfDynLib = struct {
434434 pub fn lookupAddress(self: *const ElfDynLib, vername: []const u8, name: []const u8) ?usize {
435435 const maybe_versym = if (self.verdef == null) null else self.versym;
436436
437 const OK_TYPES = (1 << elf.STT_NOTYPE | 1 << elf.STT_OBJECT | 1 << elf.STT_FUNC | 1 << elf.STT_COMMON);
438 const OK_BINDS = (1 << elf.STB_GLOBAL | 1 << elf.STB_WEAK | 1 << elf.STB_GNU_UNIQUE);
437 const OK_TYPES = (1 << elf.STT_NOTYPE) | (1 << elf.STT_OBJECT) | (1 << elf.STT_FUNC) | (1 << elf.STT_COMMON);
438 const OK_BINDS = (1 << elf.STB_GLOBAL) | (1 << elf.STB_WEAK) | (1 << elf.STB_GNU_UNIQUE);
439439
440440 switch (self.hash_table) {
441441 .dt_hash => |hashtab| {
442442 var i: usize = 0;
443443 while (i < hashtab[1]) : (i += 1) {
444 if (0 == (@as(u32, 1) << @as(u5, @intCast(self.syms[i].st_info & 0xf)) & OK_TYPES)) continue;
445 if (0 == (@as(u32, 1) << @as(u5, @intCast(self.syms[i].st_info >> 4)) & OK_BINDS)) continue;
444 if (0 == (@as(u32, 1) << @as(u5, @intCast(self.syms[i].st_info & 0xf))) & OK_TYPES) continue;
445 if (0 == (@as(u32, 1) << @as(u5, @intCast(self.syms[i].st_info >> 4))) & OK_BINDS) continue;
446446 if (0 == self.syms[i].st_shndx) continue;
447447 if (!mem.eql(u8, name, mem.sliceTo(self.strings + self.syms[i].st_name, 0))) continue;
448448 if (maybe_versym) |versym| {
......@@ -494,8 +494,8 @@ pub const ElfDynLib = struct {
494494 const symbol_index = current_index + gnu_hash_header.symoffset;
495495 const symbol = self.syms[symbol_index];
496496
497 if (0 == (@as(u32, 1) << @as(u5, @intCast(symbol.st_info & 0xf)) & OK_TYPES)) continue;
498 if (0 == (@as(u32, 1) << @as(u5, @intCast(symbol.st_info >> 4)) & OK_BINDS)) continue;
497 if (0 == (@as(u32, 1) << @as(u5, @intCast(symbol.st_info & 0xf))) & OK_TYPES) continue;
498 if (0 == (@as(u32, 1) << @as(u5, @intCast(symbol.st_info >> 4))) & OK_BINDS) continue;
499499 if (0 == symbol.st_shndx) continue;
500500
501501 const symbol_name = mem.sliceTo(self.strings + symbol.st_name, 0);
lib/std/fmt/parse_float/common.zig+1-1
......@@ -82,7 +82,7 @@ pub fn isDigit(c: u8, comptime base: u8) bool {
8282 return if (base == 10)
8383 '0' <= c and c <= '9'
8484 else
85 '0' <= c and c <= '9' or 'a' <= c and c <= 'f' or 'A' <= c and c <= 'F';
85 ('0' <= c and c <= '9') or ('a' <= c and c <= 'f') or ('A' <= c and c <= 'F');
8686}
8787
8888/// Returns the underlying storage type used for the mantissa of floating-point type.
lib/std/hash/cityhash.zig+1-1
......@@ -222,7 +222,7 @@ pub const CityHash64 = struct {
222222 const c: u8 = str[str.len - 1];
223223 const y: u32 = @as(u32, @intCast(a)) +% (@as(u32, @intCast(b)) << 8);
224224 const z: u32 = @as(u32, @truncate(str.len)) +% (@as(u32, @intCast(c)) << 2);
225 return shiftmix(@as(u64, @intCast(y)) *% k2 ^ @as(u64, @intCast(z)) *% k0) *% k2;
225 return shiftmix((@as(u64, @intCast(y)) *% k2) ^ (@as(u64, @intCast(z)) *% k0)) *% k2;
226226 }
227227 return k2;
228228 }
lib/std/hash/xxhash.zig+1-1
......@@ -398,7 +398,7 @@ pub const XxHash32 = struct {
398398 }
399399
400400 fn avalanche(value: u32) u32 {
401 var acc = value ^ value >> 15;
401 var acc = value ^ (value >> 15);
402402 acc *%= prime_2;
403403 acc ^= acc >> 13;
404404 acc *%= prime_3;
lib/std/hash_map.zig+1-1
......@@ -2019,7 +2019,7 @@ test "getOrPutAdapted" {
20192019 const AdaptedContext = struct {
20202020 fn eql(self: @This(), adapted_key: []const u8, test_key: u64) bool {
20212021 _ = self;
2022 return std.fmt.parseInt(u64, adapted_key, 10) catch unreachable == test_key;
2022 return (std.fmt.parseInt(u64, adapted_key, 10) catch unreachable) == test_key;
20232023 }
20242024 fn hash(self: @This(), adapted_key: []const u8) u64 {
20252025 _ = self;
lib/std/heap/SafeAllocator.zig+1-1
......@@ -211,7 +211,7 @@ const Bucket = struct {
211211
212212 fn of(s: *SafeAllocator, ptr: [*]u8) *Bucket {
213213 const size_log2 = s.bucket_size_log2;
214 return @ptrFromInt(@intFromPtr(ptr) >> @intCast(size_log2) << @intCast(size_log2));
214 return @ptrFromInt((@intFromPtr(ptr) >> @intCast(size_log2)) << @intCast(size_log2));
215215 }
216216
217217 fn fillAt(s: *SafeAllocator, ptr: [*]const u8) u32 {
lib/std/math.zig+14-14
......@@ -710,7 +710,7 @@ pub fn rotr(comptime T: type, x: T, r: anytype) T {
710710
711711 if (comptime isPowerOfTwo(@typeInfo(T).int.bits)) {
712712 const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).int.bits));
713 return x >> ar | x << (1 +% ~ar);
713 return (x >> ar) | (x << (1 +% ~ar));
714714 } else {
715715 const ar = @mod(r, @typeInfo(T).int.bits);
716716 return shr(T, x, ar) | shl(T, x, @typeInfo(T).int.bits - ar);
......@@ -753,7 +753,7 @@ pub fn rotl(comptime T: type, x: T, r: anytype) T {
753753
754754 if (comptime isPowerOfTwo(@typeInfo(T).int.bits)) {
755755 const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).int.bits));
756 return x << ar | x >> 1 +% ~ar;
756 return (x << ar) | (x >> (1 +% ~ar));
757757 } else {
758758 const ar = @mod(r, @typeInfo(T).int.bits);
759759 return shl(T, x, ar) | shr(T, x, @typeInfo(T).int.bits - ar);
......@@ -1542,21 +1542,21 @@ pub const Order = enum {
15421542 const neg: i32 = -1;
15431543 const zero: i32 = 0;
15441544 const pos: i32 = 1;
1545 try testing.expect(order(zero, neg).differ() orelse
1546 order(pos, zero) == .gt);
1547 try testing.expect(order(zero, zero).differ() orelse
1548 order(zero, zero) == .eq);
1549 try testing.expect(order(pos, pos).differ() orelse
1550 order(neg, zero) == .lt);
1551 try testing.expect(order(zero, zero).differ() orelse
1545 try testing.expect((order(zero, neg).differ() orelse
1546 order(pos, zero)) == .gt);
1547 try testing.expect((order(zero, zero).differ() orelse
1548 order(zero, zero)) == .eq);
1549 try testing.expect((order(pos, pos).differ() orelse
1550 order(neg, zero)) == .lt);
1551 try testing.expect((order(zero, zero).differ() orelse
15521552 order(pos, neg).differ() orelse
1553 order(neg, zero) == .gt);
1554 try testing.expect(order(pos, pos).differ() orelse
1553 order(neg, zero)) == .gt);
1554 try testing.expect((order(pos, pos).differ() orelse
15551555 order(pos, pos).differ() orelse
1556 order(neg, neg) == .eq);
1557 try testing.expect(order(zero, pos).differ() orelse
1556 order(neg, neg)) == .eq);
1557 try testing.expect((order(zero, pos).differ() orelse
15581558 order(neg, pos).differ() orelse
1559 order(pos, neg) == .lt);
1559 order(pos, neg)) == .lt);
15601560 }
15611561
15621562 pub fn compare(self: Order, op: CompareOperator) bool {
lib/std/math/acos.zig+1-1
......@@ -176,7 +176,7 @@ fn acosBinary64(x: f64) f64 {
176176 // |x| >= 1 or nan
177177 if (ix >= 0x3ff0_0000) {
178178 const lx: u32 = @truncate(@as(u64, @bitCast(x)));
179 if ((ix - 0x3ff0_0000 | lx) == 0) {
179 if (((ix - 0x3ff0_0000) | lx) == 0) {
180180 if (hx >> 31 != 0) {
181181 return 2.0 * pio2_hi + 0x1.0p-120;
182182 }
lib/std/math/asin.zig+1-1
......@@ -156,7 +156,7 @@ fn asinBinary64(x: f64) f64 {
156156 if (ix >= 0x3ff0_0000) {
157157 const lx: u32 = @truncate(@as(u64, @bitCast(x)));
158158 // asin(1) = +-pi/2 with inexact
159 if ((ix - 0x3ff0_0000 | lx) == 0) {
159 if (((ix - 0x3ff0_0000) | lx) == 0) {
160160 return x * pio2_hi + 0x1.0p-120;
161161 }
162162 return 0.0 / (x - x);
lib/std/math/big/int.zig+3-3
......@@ -2401,7 +2401,7 @@ pub const Const = struct {
24012401 const shift: usize = @intCast(exponent - @bitSizeOf(Repr.Normalized.Fraction));
24022402 mantissa.shiftRight(normalized_abs, shift);
24032403 const final_limb_index = (shift - 1) / limb_bits;
2404 const round_bits = normalized_abs.limbs[final_limb_index] << @truncate(-%shift) |
2404 const round_bits = (normalized_abs.limbs[final_limb_index] << @truncate(-%shift)) |
24052405 @intFromBool(!std.mem.allEqual(Limb, normalized_abs.limbs[0..final_limb_index], 0));
24062406 if (round_bits == 0) break :exactness .exact;
24072407 round: switch (round) {
......@@ -4902,10 +4902,10 @@ test "format" {
49024902 try a.set(20000000000000000000); // > maxInt(u64)
49034903 try testFormat(a, "20000000000000000000");
49044904
4905 try a.set(1 << 64 * @sizeOf(usize) * 8);
4905 try a.set(1 << (64 * @sizeOf(usize) * 8));
49064906 try testFormat(a, "(BigInt)");
49074907
4908 try a.set(-(1 << 64 * @sizeOf(usize) * 8));
4908 try a.set(-(1 << (64 * @sizeOf(usize) * 8)));
49094909 try testFormat(a, "(BigInt)");
49104910}
49114911
lib/std/math/big/int_test.zig+16-16
......@@ -2489,14 +2489,14 @@ test "truncate to minimum signed integer" {
24892489 .len = undefined,
24902490 .positive = undefined,
24912491 };
2492 res.truncate(.{ .positive = true, .limbs = &.{1 << @bitSizeOf(Limb) - 1} }, .signed, @bitSizeOf(Limb));
2493 try testing.expect(res.toConst().orderAgainstScalar(-1 << @bitSizeOf(Limb) - 1).compare(.eq));
2494 res.truncate(.{ .positive = false, .limbs = &.{1 << @bitSizeOf(Limb) - 1} }, .signed, @bitSizeOf(Limb));
2495 try testing.expect(res.toConst().orderAgainstScalar(-1 << @bitSizeOf(Limb) - 1).compare(.eq));
2496 res.truncate(.{ .positive = true, .limbs = &.{1 << @bitSizeOf(Limb) - 1} }, .unsigned, @bitSizeOf(Limb));
2497 try testing.expect(res.toConst().orderAgainstScalar(1 << @bitSizeOf(Limb) - 1).compare(.eq));
2498 res.truncate(.{ .positive = false, .limbs = &.{1 << @bitSizeOf(Limb) - 1} }, .unsigned, @bitSizeOf(Limb));
2499 try testing.expect(res.toConst().orderAgainstScalar(1 << @bitSizeOf(Limb) - 1).compare(.eq));
2492 res.truncate(.{ .positive = true, .limbs = &.{1 << (@bitSizeOf(Limb) - 1)} }, .signed, @bitSizeOf(Limb));
2493 try testing.expect(res.toConst().orderAgainstScalar(-1 << (@bitSizeOf(Limb) - 1)).compare(.eq));
2494 res.truncate(.{ .positive = false, .limbs = &.{1 << (@bitSizeOf(Limb) - 1)} }, .signed, @bitSizeOf(Limb));
2495 try testing.expect(res.toConst().orderAgainstScalar(-1 << (@bitSizeOf(Limb) - 1)).compare(.eq));
2496 res.truncate(.{ .positive = true, .limbs = &.{1 << (@bitSizeOf(Limb) - 1)} }, .unsigned, @bitSizeOf(Limb));
2497 try testing.expect(res.toConst().orderAgainstScalar(1 << (@bitSizeOf(Limb) - 1)).compare(.eq));
2498 res.truncate(.{ .positive = false, .limbs = &.{1 << (@bitSizeOf(Limb) - 1)} }, .unsigned, @bitSizeOf(Limb));
2499 try testing.expect(res.toConst().orderAgainstScalar(1 << (@bitSizeOf(Limb) - 1)).compare(.eq));
25002500}
25012501
25022502test "saturate single signed positive" {
......@@ -3880,7 +3880,7 @@ test "clz" {
38803880 try testing.expectEqual(0, neg_limb_max_squared_plus_one.clz(@bitSizeOf(Limb) * 2 + 1));
38813881
38823882 const neg_limb_msb_squared: std.math.big.int.Const = .{
3883 .limbs = &.{ 0, 1 << @bitSizeOf(Limb) - 2 },
3883 .limbs = &.{ 0, 1 << (@bitSizeOf(Limb) - 2) },
38843884 .positive = false,
38853885 };
38863886 try testing.expectEqual(0, neg_limb_msb_squared.clz(@bitSizeOf(Limb) * 2));
......@@ -3896,7 +3896,7 @@ test "clz" {
38963896 try testing.expectEqual(0, neg_limb_max.clz(@bitSizeOf(Limb) * 2 + 1));
38973897
38983898 const neg_limb_msb: std.math.big.int.Const = .{
3899 .limbs = &.{1 << @bitSizeOf(Limb) - 1},
3899 .limbs = &.{1 << (@bitSizeOf(Limb) - 1)},
39003900 .positive = false,
39013901 };
39023902 try testing.expectEqual(0, neg_limb_msb.clz(@bitSizeOf(Limb)));
......@@ -3936,7 +3936,7 @@ test "clz" {
39363936 try testing.expectEqual(@bitSizeOf(Limb) * 2, one.clz(@bitSizeOf(Limb) * 2 + 1));
39373937
39383938 const limb_msb: std.math.big.int.Const = .{
3939 .limbs = &.{1 << @bitSizeOf(Limb) - 1},
3939 .limbs = &.{1 << (@bitSizeOf(Limb) - 1)},
39403940 .positive = true,
39413941 };
39423942 try testing.expectEqual(0, limb_msb.clz(@bitSizeOf(Limb)));
......@@ -3956,7 +3956,7 @@ test "clz" {
39563956 try testing.expectEqual(@bitSizeOf(Limb) + 1, limb_max.clz(@bitSizeOf(Limb) * 2 + 1));
39573957
39583958 const limb_msb_squared: std.math.big.int.Const = .{
3959 .limbs = &.{ 0, 1 << @bitSizeOf(Limb) - 2 },
3959 .limbs = &.{ 0, 1 << (@bitSizeOf(Limb) - 2) },
39603960 .positive = true,
39613961 };
39623962 try testing.expectEqual(0, limb_msb_squared.clz(@bitSizeOf(Limb) * 2 - 1));
......@@ -3992,7 +3992,7 @@ test "ctz" {
39923992 try testing.expectEqual(@bitSizeOf(Limb) + 1, neg_limb_max_squared_plus_one.ctz(@bitSizeOf(Limb) * 2 + 1));
39933993
39943994 const neg_limb_msb_squared: std.math.big.int.Const = .{
3995 .limbs = &.{ 0, 1 << @bitSizeOf(Limb) - 2 },
3995 .limbs = &.{ 0, 1 << (@bitSizeOf(Limb) - 2) },
39963996 .positive = false,
39973997 };
39983998 try testing.expectEqual(@bitSizeOf(Limb) * 2 - 2, neg_limb_msb_squared.ctz(@bitSizeOf(Limb) * 2));
......@@ -4008,7 +4008,7 @@ test "ctz" {
40084008 try testing.expectEqual(0, neg_limb_max.ctz(@bitSizeOf(Limb) * 2 + 1));
40094009
40104010 const neg_limb_msb: std.math.big.int.Const = .{
4011 .limbs = &.{1 << @bitSizeOf(Limb) - 1},
4011 .limbs = &.{1 << (@bitSizeOf(Limb) - 1)},
40124012 .positive = false,
40134013 };
40144014 try testing.expectEqual(@bitSizeOf(Limb) - 1, neg_limb_msb.ctz(@bitSizeOf(Limb)));
......@@ -4048,7 +4048,7 @@ test "ctz" {
40484048 try testing.expectEqual(0, one.ctz(@bitSizeOf(Limb) * 2 + 1));
40494049
40504050 const limb_msb: std.math.big.int.Const = .{
4051 .limbs = &.{1 << @bitSizeOf(Limb) - 1},
4051 .limbs = &.{1 << (@bitSizeOf(Limb) - 1)},
40524052 .positive = true,
40534053 };
40544054 try testing.expectEqual(@bitSizeOf(Limb) - 1, limb_msb.ctz(@bitSizeOf(Limb)));
......@@ -4068,7 +4068,7 @@ test "ctz" {
40684068 try testing.expectEqual(0, limb_max.ctz(@bitSizeOf(Limb) * 2 + 1));
40694069
40704070 const limb_msb_squared: std.math.big.int.Const = .{
4071 .limbs = &.{ 0, 1 << @bitSizeOf(Limb) - 2 },
4071 .limbs = &.{ 0, 1 << (@bitSizeOf(Limb) - 2) },
40724072 .positive = true,
40734073 };
40744074 try testing.expectEqual(@bitSizeOf(Limb) * 2 - 2, limb_msb_squared.ctz(@bitSizeOf(Limb) * 2 - 1));
lib/std/math/float.zig+2-2
......@@ -281,7 +281,7 @@ pub inline fn nan(comptime Type: type) Type {
281281 return reconstructFloat(
282282 RuntimeType,
283283 floatExponentMax(RuntimeType) + 1,
284 mantissaOne(RuntimeType) | 1 << (floatFractionalBits(RuntimeType) - 1),
284 mantissaOne(RuntimeType) | (1 << (floatFractionalBits(RuntimeType) - 1)),
285285 );
286286}
287287
......@@ -297,7 +297,7 @@ pub inline fn snan(comptime Type: type) Type {
297297 return reconstructFloat(
298298 RuntimeType,
299299 floatExponentMax(RuntimeType) + 1,
300 mantissaOne(RuntimeType) | 1 << (floatFractionalBits(RuntimeType) - 2),
300 mantissaOne(RuntimeType) | (1 << (floatFractionalBits(RuntimeType) - 2)),
301301 );
302302}
303303
lib/std/mem.zig+1-1
......@@ -4354,7 +4354,7 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize {
43544354 @compileError("expected many item pointer, got " ++ @typeName(T));
43554355
43564356 // Do nothing if the pointer is already well-aligned.
4357 if (align_to <= info.pointer.attrs.@"align" orelse @alignOf(info.pointer.child))
4357 if (align_to <= (info.pointer.attrs.@"align" orelse @alignOf(info.pointer.child)))
43584358 return 0;
43594359
43604360 // Calculate the aligned base address with an eye out for overflow.
lib/std/os/linux/vdso.zig+4-4
......@@ -62,13 +62,13 @@ pub fn lookup(vername: []const u8, name: []const u8) usize {
6262 const hashtab = maybe_hashtab orelse return 0;
6363 if (maybe_verdef == null) maybe_versym = null;
6464
65 const OK_TYPES = (1 << elf.STT_NOTYPE | 1 << elf.STT_OBJECT | 1 << elf.STT_FUNC | 1 << elf.STT_COMMON);
66 const OK_BINDS = (1 << elf.STB_GLOBAL | 1 << elf.STB_WEAK | 1 << elf.STB_GNU_UNIQUE);
65 const OK_TYPES = (1 << elf.STT_NOTYPE) | (1 << elf.STT_OBJECT) | (1 << elf.STT_FUNC) | (1 << elf.STT_COMMON);
66 const OK_BINDS = (1 << elf.STB_GLOBAL) | (1 << elf.STB_WEAK) | (1 << elf.STB_GNU_UNIQUE);
6767
6868 var i: usize = 0;
6969 while (i < hashtab[1]) : (i += 1) {
70 if (0 == (@as(u32, 1) << @as(u5, @intCast(syms[i].st_info & 0xf)) & OK_TYPES)) continue;
71 if (0 == (@as(u32, 1) << @as(u5, @intCast(syms[i].st_info >> 4)) & OK_BINDS)) continue;
70 if (0 == (@as(u32, 1) << @as(u5, @intCast(syms[i].st_info & 0xf))) & OK_TYPES) continue;
71 if (0 == (@as(u32, 1) << @as(u5, @intCast(syms[i].st_info >> 4))) & OK_BINDS) continue;
7272 if (0 == syms[i].st_shndx) continue;
7373 const sym_name = @as([*:0]u8, @ptrCast(strings + syms[i].st_name));
7474 if (!mem.eql(u8, name, mem.sliceTo(sym_name, 0))) continue;
lib/std/os/uefi/status.zig+1-1
......@@ -1,6 +1,6 @@
11const testing = @import("std").testing;
22
3const high_bit = 1 << @typeInfo(usize).int.bits - 1;
3const high_bit = 1 << (@typeInfo(usize).int.bits - 1);
44
55pub const Status = enum(usize) {
66 /// The operation completed successfully.
lib/std/unicode.zig+1-1
......@@ -485,7 +485,7 @@ pub fn utf16DecodeSurrogatePair(surrogate_pair: []const u16) !u21 {
485485 const high_half: u21 = surrogate_pair[0];
486486 const low_half = surrogate_pair[1];
487487 if (!utf16IsLowSurrogate(low_half)) return error.ExpectedSecondSurrogateHalf;
488 return 0x10000 + ((high_half & 0x03ff) << 10) | (low_half & 0x03ff);
488 return (0x10000 + ((high_half & 0x03ff) << 10)) | (low_half & 0x03ff);
489489}
490490
491491pub const Utf16LeIterator = struct {
lib/std/zig/Ast.zig+32
......@@ -555,6 +555,33 @@ pub fn renderError(tree: Ast, parse_error: Error, w: *Writer) Writer.Error!void
555555 .var_const_decl => {
556556 return w.writeAll("use 'var' or 'const' to declare variable");
557557 },
558 .ambiguous_operator_precedence => {
559 return w.print("ambiguous operator precedence with operators … {s} … {s} …; use parentheses to disambiguate", .{
560 tree.tokenTag(parse_error.token - @as(u32, @intCast(parse_error.extra.offset))).lexeme().?,
561 tree.tokenTag(parse_error.token).lexeme().?,
562 });
563 },
564 .previous_ambiguous_operator => {
565 return w.writeAll("previous ambiguous operator here");
566 },
567 .illegal_chained_operators => {
568 return w.print("repetition of non-chainable operators … {s} … {s} …; use parentheses to disambiguate", .{
569 tree.tokenTag(parse_error.token - @as(u32, @intCast(parse_error.extra.offset))).lexeme().?,
570 tree.tokenTag(parse_error.token).lexeme().?,
571 });
572 },
573 .hint_operator_precedence_left => {
574 return w.print("did you mean `(… {s} …) {s} …` ?", .{
575 tree.tokenTag(parse_error.token - @as(u32, @intCast(parse_error.extra.offset))).lexeme().?,
576 tree.tokenTag(parse_error.token).lexeme().?,
577 });
578 },
579 .hint_operator_precedence_right => {
580 return w.print("did you mean `… {s} (… {s} …)` ?", .{
581 tree.tokenTag(parse_error.token - @as(u32, @intCast(parse_error.extra.offset))).lexeme().?,
582 tree.tokenTag(parse_error.token).lexeme().?,
583 });
584 },
558585
559586 .invalid_byte => {
560587 const tok_slice = tree.source[tree.tokens.items(.start)[parse_error.token]..];
......@@ -2893,6 +2920,11 @@ pub const Error = struct {
28932920 expected_var_const,
28942921 wrong_equal_var_decl,
28952922 var_const_decl,
2923 ambiguous_operator_precedence,
2924 previous_ambiguous_operator,
2925 hint_operator_precedence_left,
2926 hint_operator_precedence_right,
2927 illegal_chained_operators,
28962928
28972929 zig_style_container,
28982930 previous_field,
lib/std/zig/Ast/Render.zig+3-3
......@@ -1483,9 +1483,9 @@ fn renderThenElse(
14831483 last_else_token = error_token + 1; // |
14841484 }
14851485
1486 const indent_else_expr = indent_then_expr and
1486 const indent_else_expr = (indent_then_expr and
14871487 !nodeIsBlock(tree.nodeTag(else_expr)) and
1488 !nodeIsIfForWhileSwitch(tree.nodeTag(else_expr)) or
1488 !nodeIsIfForWhileSwitch(tree.nodeTag(else_expr))) or
14891489 tree.tokenTag(tree.firstToken(else_expr)) ==
14901490 .multiline_string_literal_line;
14911491 if (indent_else_expr) {
......@@ -3195,7 +3195,7 @@ fn renderComments(r: *Render, start: usize, end: usize) Error!bool {
31953195 }
31963196 }
31973197
3198 index = 1 + (newline orelse end - 1);
3198 index = 1 + (newline orelse (end - 1));
31993199
32003200 const comment_content = mem.trimStart(u8, trimmed_comment["//".len..], &std.ascii.whitespace);
32013201 if (ais.disabled_offset != null and mem.eql(u8, comment_content, "zig fmt: on")) {
lib/std/zig/Parse.zig+301-54
......@@ -1512,7 +1512,7 @@ fn expectAssignExpr(p: *Parse) !Node.Index {
15121512}
15131513
15141514fn parseExpr(p: *Parse) Error!?Node.Index {
1515 return p.parseExprPrecedence(0);
1515 return p.parseExprPrecedence(.start, p.tok_i);
15161516}
15171517
15181518fn expectExpr(p: *Parse) Error!Node.Index {
......@@ -1524,67 +1524,317 @@ const Assoc = enum {
15241524 none,
15251525};
15261526
1527const PrecClass = struct {
1528 group: Group,
1529 assoc: Assoc = Assoc.left,
1530
1531 const Group = enum {
1532 const num_distinct = std.meta.fieldNames(Group).len;
1533
1534 arithmetic_product_chainable,
1535 arithmetic_mod_nonchainable,
1536 arithmetic_sum,
1537
1538 bitwise_shift,
1539 bitwise_and,
1540 bitwise_xor,
1541 bitwise_or,
1542
1543 comparison,
1544
1545 bool_and,
1546 bool_or,
1547
1548 recovery_orelse,
1549 recovery_catch,
1550
1551 root,
1552
1553 /// For this to work correctly we require that all subgroups are strictly adjacent
1554 /// Major groups are defined by the first text before an underscore
1555 const Major: type = b: {
1556 var major_names: []const []const u8 = &.{};
1557 for (std.meta.fieldNames(Group)) |fieldname| {
1558 var major_name: []const u8 = fieldname[0..];
1559 for (fieldname, 0..) |c, i| {
1560 if (c == '_') {
1561 major_name = fieldname[0..i];
1562 break;
1563 }
1564 }
1565 if (major_names.len == 0 or !std.mem.eql(u8, major_name, major_names[major_names.len - 1])) {
1566 major_names = major_names ++ &[1][]const u8{major_name};
1567 }
1568 }
1569
1570 const IntType = std.math.IntFittingRange(0, major_names.len - 1);
1571 var values: [major_names.len]IntType = undefined;
1572 for (0..major_names.len) |i| values[i] = i;
1573
1574 break :b @Enum(
1575 IntType,
1576 .exhaustive,
1577 major_names,
1578 &values,
1579 );
1580 };
1581 };
1582
1583 pub const start: PrecClass = .{ .group = .root };
1584
1585 pub const Rel = enum(i2) {
1586 lt = -1,
1587 eq = 0,
1588 gt = 1,
1589
1590 fn inverted(self: Rel) Rel {
1591 return @enumFromInt(-@intFromEnum(self));
1592 }
1593 };
1594
1595 const PrecedenceArray = [Group.num_distinct][Group.num_distinct]?Rel;
1596
1597 fn setMajorRelation(prec_array: *PrecedenceArray, major_a: Group.Major, rel: Rel, major_b: Group.Major) void {
1598 for (std.meta.fieldNames(Group), 0..) |fieldname_i, i| {
1599 if (!std.mem.startsWith(u8, fieldname_i, @tagName(major_a))) continue;
1600
1601 for (std.meta.fieldNames(Group), 0..) |fieldname_j, j| {
1602 if (!std.mem.startsWith(u8, fieldname_j, @tagName(major_b))) continue;
1603
1604 prec_array.*[i][j] = rel;
1605 }
1606 }
1607 }
1608
1609 fn setMinorRelation(prec_array: *PrecedenceArray, minor_a: Group, rel: Rel, minor_b: Group) void {
1610 prec_array.*[@intFromEnum(minor_a)][@intFromEnum(minor_b)] = rel;
1611 }
1612
1613 /// Arithmetic_* > Comparison
1614 /// Bitwise_* > Comparison
1615 /// Comparison > Bool_* > Root
1616 /// Recovery > Root
1617 ///
1618 /// *_Product > *_Sum
1619 ///
1620 /// order[y][x] --> y cmp x
1621 const precedence_ordering = b: {
1622 @setEvalBranchQuota(20_000);
1623 const major_greater_than_relations = [_][2]Group.Major{
1624 // zig fmt: off
1625 .{ .arithmetic, .comparison },
1626 .{ .bitwise, .comparison },
1627 .{ .comparison, .bool },
1628 .{ .bool, .root },
1629 .{ .recovery, .root },
1630 // zig fmt: on
1631 };
1632
1633 var order: PrecedenceArray = @splat(@splat(null));
1634
1635 for (major_greater_than_relations) |relation| {
1636 setMajorRelation(&order, relation[0], .gt, relation[1]);
1637 }
1638
1639 setMinorRelation(&order, .arithmetic_mod_nonchainable, .gt, .arithmetic_sum);
1640 setMinorRelation(&order, .arithmetic_product_chainable, .gt, .arithmetic_sum);
1641
1642 computeTransativeOrdering(&order);
1643 break :b order;
1644 };
1645
1646 /// Uses the table from Zig-0.16.0
1647 /// * / % *% *| ||
1648 /// + - ++ +% -% +| -|
1649 /// << >> <<|
1650 /// & ^ | orelse catch
1651 /// == != < > <= >=
1652 /// and
1653 /// or
1654 const v16_precedence_ordering = b: {
1655 @setEvalBranchQuota(20_000);
1656
1657 var order: PrecedenceArray = @splat(@splat(null));
1658
1659 setMinorRelation(&order, .arithmetic_product_chainable, .eq, .arithmetic_mod_nonchainable);
1660 setMinorRelation(&order, .arithmetic_mod_nonchainable, .gt, .arithmetic_sum);
1661 setMinorRelation(&order, .arithmetic_product_chainable, .gt, .arithmetic_sum);
1662
1663 setMinorRelation(&order, .arithmetic_sum, .gt, .bitwise_shift);
1664
1665 // Here since the transative ordering computer cant leverage equals to derive a = b < c --> a < c, we have to manually list these
1666 setMinorRelation(&order, .bitwise_shift, .gt, .bitwise_and);
1667 setMinorRelation(&order, .bitwise_shift, .gt, .bitwise_xor);
1668 setMinorRelation(&order, .bitwise_shift, .gt, .bitwise_or);
1669 setMinorRelation(&order, .bitwise_shift, .gt, .recovery_catch);
1670 setMinorRelation(&order, .bitwise_shift, .gt, .recovery_orelse);
1671
1672 setMinorRelation(&order, .bitwise_and, .eq, .bitwise_xor);
1673 setMinorRelation(&order, .bitwise_xor, .eq, .bitwise_or);
1674 setMinorRelation(&order, .bitwise_or, .eq, .recovery_catch);
1675 setMinorRelation(&order, .recovery_catch, .eq, .recovery_orelse);
1676 setMinorRelation(&order, .recovery_orelse, .eq, .bitwise_and);
1677
1678 setMinorRelation(&order, .bitwise_and, .gt, .comparison);
1679 setMinorRelation(&order, .bitwise_xor, .gt, .comparison);
1680 setMinorRelation(&order, .bitwise_or, .gt, .comparison);
1681 setMinorRelation(&order, .recovery_catch, .gt, .comparison);
1682 setMinorRelation(&order, .recovery_orelse, .gt, .comparison);
1683
1684 setMinorRelation(&order, .comparison, .gt, .bool_and);
1685
1686 setMinorRelation(&order, .bool_and, .gt, .bool_or);
1687
1688 setMinorRelation(&order, .bool_or, .gt, .root);
1689
1690 computeTransativeOrdering(&order);
1691 for (order) |row| {
1692 for (row) |item| {
1693 if (item == null) @compileError("Null entry in old precedence ordering which had none.");
1694 }
1695 }
1696 break :b order;
1697 };
1698
1699 pub fn cmp(lhs: PrecClass, rhs: PrecClass) ?Rel {
1700 return PrecClass.precedence_ordering[@intFromEnum(lhs.group)][@intFromEnum(rhs.group)];
1701 }
1702
1703 pub fn v16_cmp(lhs: PrecClass, rhs: PrecClass) Rel {
1704 return PrecClass.v16_precedence_ordering[@intFromEnum(lhs.group)][@intFromEnum(rhs.group)].?;
1705 }
1706
1707 fn computeTransativeOrdering(order: *PrecedenceArray) void {
1708 for (0..Group.num_distinct) |i| for (0..Group.num_distinct) |j| for (0..Group.num_distinct) |k| {
1709 if (order[i][k] == order[k][j] and order[i][k] != null) order[i][j] = order[i][k];
1710 };
1711 for (0..Group.num_distinct) |i| for (0..Group.num_distinct) |j| {
1712 if (i == j) order[i][j] = .eq;
1713 if (order[i][j] == null and order[j][i] != null) order[i][j] = order[j][i].?.inverted();
1714 };
1715 }
1716};
1717
15271718const OperInfo = struct {
1528 prec: i8,
1719 prec: PrecClass,
15291720 tag: Node.Tag,
1530 assoc: Assoc = Assoc.left,
15311721};
15321722
1533// A table of binary operator information. Higher precedence numbers are
1534// stickier. All operators at the same precedence level should have the same
1535// associativity.
1536const operTable = std.enums.directEnumArrayDefault(Token.Tag, OperInfo, .{ .prec = -1, .tag = Node.Tag.root }, 0, .{
1537 .keyword_or = .{ .prec = 10, .tag = .bool_or },
1538
1539 .keyword_and = .{ .prec = 20, .tag = .bool_and },
1540
1541 .equal_equal = .{ .prec = 30, .tag = .equal_equal, .assoc = Assoc.none },
1542 .bang_equal = .{ .prec = 30, .tag = .bang_equal, .assoc = Assoc.none },
1543 .angle_bracket_left = .{ .prec = 30, .tag = .less_than, .assoc = Assoc.none },
1544 .angle_bracket_right = .{ .prec = 30, .tag = .greater_than, .assoc = Assoc.none },
1545 .angle_bracket_left_equal = .{ .prec = 30, .tag = .less_or_equal, .assoc = Assoc.none },
1546 .angle_bracket_right_equal = .{ .prec = 30, .tag = .greater_or_equal, .assoc = Assoc.none },
1547
1548 .ampersand = .{ .prec = 40, .tag = .bit_and },
1549 .caret = .{ .prec = 40, .tag = .bit_xor },
1550 .pipe = .{ .prec = 40, .tag = .bit_or },
1551 .keyword_orelse = .{ .prec = 40, .tag = .@"orelse" },
1552 .keyword_catch = .{ .prec = 40, .tag = .@"catch" },
1553
1554 .angle_bracket_angle_bracket_left = .{ .prec = 50, .tag = .shl },
1555 .angle_bracket_angle_bracket_left_pipe = .{ .prec = 50, .tag = .shl_sat },
1556 .angle_bracket_angle_bracket_right = .{ .prec = 50, .tag = .shr },
1557
1558 .plus = .{ .prec = 60, .tag = .add },
1559 .minus = .{ .prec = 60, .tag = .sub },
1560 .plus_plus = .{ .prec = 60, .tag = .array_cat },
1561 .plus_percent = .{ .prec = 60, .tag = .add_wrap },
1562 .minus_percent = .{ .prec = 60, .tag = .sub_wrap },
1563 .plus_pipe = .{ .prec = 60, .tag = .add_sat },
1564 .minus_pipe = .{ .prec = 60, .tag = .sub_sat },
1565
1566 .pipe_pipe = .{ .prec = 70, .tag = .merge_error_sets },
1567 .asterisk = .{ .prec = 70, .tag = .mul },
1568 .slash = .{ .prec = 70, .tag = .div },
1569 .percent = .{ .prec = 70, .tag = .mod },
1570 .asterisk_percent = .{ .prec = 70, .tag = .mul_wrap },
1571 .asterisk_pipe = .{ .prec = 70, .tag = .mul_sat },
1723const operTable = std.enums.directEnumArrayDefault(Token.Tag, OperInfo, .{ .prec = .start, .tag = Node.Tag.root }, 0, .{
1724 // zig fmt: off
1725 .keyword_or = .{ .prec = .{ .group = .bool_or }, .tag = .bool_or },
1726
1727 .keyword_and = .{ .prec = .{ .group = .bool_and }, .tag = .bool_and },
1728
1729 .equal_equal = .{ .prec = .{ .group = .comparison, .assoc = Assoc.none }, .tag = .equal_equal },
1730 .bang_equal = .{ .prec = .{ .group = .comparison, .assoc = Assoc.none }, .tag = .bang_equal },
1731 .angle_bracket_left = .{ .prec = .{ .group = .comparison, .assoc = Assoc.none }, .tag = .less_than },
1732 .angle_bracket_right = .{ .prec = .{ .group = .comparison, .assoc = Assoc.none }, .tag = .greater_than },
1733 .angle_bracket_left_equal = .{ .prec = .{ .group = .comparison, .assoc = Assoc.none }, .tag = .less_or_equal },
1734 .angle_bracket_right_equal = .{ .prec = .{ .group = .comparison, .assoc = Assoc.none }, .tag = .greater_or_equal },
1735
1736 .ampersand = .{ .prec = .{ .group = .bitwise_and }, .tag = .bit_and },
1737 .caret = .{ .prec = .{ .group = .bitwise_xor }, .tag = .bit_xor },
1738 .pipe = .{ .prec = .{ .group = .bitwise_or }, .tag = .bit_or },
1739
1740 .keyword_orelse = .{ .prec = .{ .group = .recovery_orelse }, .tag = .@"orelse" },
1741 .keyword_catch = .{ .prec = .{ .group = .recovery_catch }, .tag = .@"catch" },
1742
1743 .angle_bracket_angle_bracket_left = .{ .prec = .{ .group = .bitwise_shift, .assoc = Assoc.none }, .tag = .shl },
1744 .angle_bracket_angle_bracket_left_pipe = .{ .prec = .{ .group = .bitwise_shift, .assoc = Assoc.none }, .tag = .shl_sat },
1745 .angle_bracket_angle_bracket_right = .{ .prec = .{ .group = .bitwise_shift, .assoc = Assoc.none }, .tag = .shr },
1746
1747 .plus = .{ .prec = .{ .group = .arithmetic_sum }, .tag = .add },
1748 .minus = .{ .prec = .{ .group = .arithmetic_sum }, .tag = .sub },
1749 .plus_plus = .{ .prec = .{ .group = .arithmetic_sum }, .tag = .array_cat },
1750 .plus_percent = .{ .prec = .{ .group = .arithmetic_sum }, .tag = .add_wrap },
1751 .minus_percent = .{ .prec = .{ .group = .arithmetic_sum }, .tag = .sub_wrap },
1752 .plus_pipe = .{ .prec = .{ .group = .arithmetic_sum }, .tag = .add_sat },
1753 .minus_pipe = .{ .prec = .{ .group = .arithmetic_sum }, .tag = .sub_sat },
1754
1755 .pipe_pipe = .{ .prec = .{ .group = .arithmetic_product_chainable }, .tag = .merge_error_sets },
1756 .asterisk = .{ .prec = .{ .group = .arithmetic_product_chainable }, .tag = .mul },
1757 .slash = .{ .prec = .{ .group = .arithmetic_product_chainable }, .tag = .div },
1758 .asterisk_percent = .{ .prec = .{ .group = .arithmetic_product_chainable }, .tag = .mul_wrap },
1759 .asterisk_pipe = .{ .prec = .{ .group = .arithmetic_product_chainable }, .tag = .mul_sat },
1760
1761 .percent = .{ .prec = .{ .group = .arithmetic_mod_nonchainable, .assoc = Assoc.none }, .tag = .mod },
1762 // zig fmt: on
15721763});
15731764
1574fn parseExprPrecedence(p: *Parse, min_prec: i32) Error!?Node.Index {
1575 assert(min_prec >= 0);
1765fn parseExprPrecedence(p: *Parse, min_exc_prec: PrecClass, prev_token_const: u32) Error!?Node.Index {
15761766 var node = try p.parsePrefixExpr() orelse return null;
15771767
1578 var banned_prec: i8 = -1;
1768 var prev_operator_token = prev_token_const;
15791769
15801770 while (true) {
15811771 const tok_tag = p.tokenTag(p.tok_i);
1582 const info = operTable[@as(usize, @intCast(@backingInt(tok_tag)))];
1583 if (info.prec < min_prec) {
1772 const info = operTable[@intFromEnum(tok_tag)];
1773
1774 const rel = info.prec.cmp(min_exc_prec) orelse b: {
1775 const prev_op_tok_tag = p.tokenTag(prev_operator_token);
1776 const prev_op_info = operTable[@intFromEnum(prev_op_tok_tag)];
1777 const v16_rel = prev_op_info.prec.v16_cmp(info.prec);
1778 try p.warnMsg(.{
1779 .tag = .ambiguous_operator_precedence,
1780 .is_note = false,
1781 .token = p.tok_i,
1782 .extra = .{ .offset = p.tok_i - prev_operator_token },
1783 });
1784 try p.warnMsg(.{
1785 .tag = .previous_ambiguous_operator,
1786 .is_note = true,
1787 .token = prev_operator_token,
1788 });
1789 if (v16_rel == .gt or v16_rel == .eq) {
1790 try p.warnMsg(.{
1791 .tag = .hint_operator_precedence_left,
1792 .is_note = true,
1793 .token = p.tok_i,
1794 .extra = .{ .offset = p.tok_i - prev_operator_token },
1795 });
1796 } else {
1797 try p.warnMsg(.{
1798 .tag = .hint_operator_precedence_right,
1799 .is_note = true,
1800 .token = p.tok_i,
1801 .extra = .{ .offset = p.tok_i - prev_operator_token },
1802 });
1803 }
1804 break :b .gt;
1805 };
1806
1807 if (rel == .lt) {
15841808 break;
15851809 }
1586 if (info.prec == banned_prec) {
1587 return p.fail(.chained_comparison_operators);
1810
1811 if (min_exc_prec.group == info.prec.group and min_exc_prec.assoc == .none and info.prec.assoc == .none) {
1812 //Special cased check to maintain the old more helpful error for chained comparisons.
1813 if (info.prec.group == .comparison) {
1814 try p.warn(.chained_comparison_operators);
1815 } else {
1816 try p.warnMsg(.{
1817 .tag = .illegal_chained_operators,
1818 .is_note = false,
1819 .token = p.tok_i,
1820 .extra = .{ .offset = p.tok_i - prev_operator_token },
1821 });
1822 try p.warnMsg(.{
1823 .tag = .previous_ambiguous_operator,
1824 .is_note = true,
1825 .token = prev_operator_token,
1826 });
1827 try p.warnMsg(.{
1828 .tag = .hint_operator_precedence_left,
1829 .is_note = true,
1830 .token = p.tok_i,
1831 .extra = .{ .offset = p.tok_i - prev_operator_token },
1832 });
1833 }
1834 }
1835
1836 if (rel == .eq) {
1837 break;
15881838 }
15891839
15901840 const oper_token = p.nextToken();
......@@ -1614,7 +1864,8 @@ fn parseExprPrecedence(p: *Parse, min_prec: i32) Error!?Node.Index {
16141864 }
16151865 }
16161866
1617 const rhs = try p.parseExprPrecedence(info.prec + 1) orelse {
1867 prev_operator_token = oper_token;
1868 const rhs = try p.parseExprPrecedence(info.prec, prev_operator_token) orelse {
16181869 try p.warn(.expected_expr);
16191870 return node;
16201871 };
......@@ -1624,10 +1875,6 @@ fn parseExprPrecedence(p: *Parse, min_prec: i32) Error!?Node.Index {
16241875 .main_token = oper_token,
16251876 .data = .{ .node_and_node = .{ node, rhs } },
16261877 });
1627
1628 if (info.assoc == Assoc.none) {
1629 banned_prec = info.prec;
1630 }
16311878 }
16321879
16331880 return node;
lib/std/zig/TokenSmith.zig+1-1
......@@ -160,7 +160,7 @@ pub fn gen(smith: *Smith) TokenSmith {
160160 var no_period = false;
161161 var not_exponent = true;
162162 for (t.source_buf[t.source_len..][0..len], 0..) |*c, i| {
163 const invalid_period = no_period and c.* == '.' or i + 1 == len;
163 const invalid_period = (no_period and c.* == '.') or i + 1 == len;
164164 const is_exponent = c.* == '-' or c.* == '+';
165165 const invalid_exponent = not_exponent and is_exponent;
166166 const valid_exponent = !not_exponent and is_exponent;
lib/std/zig/llvm/BitcodeReader.zig+1-1
......@@ -404,7 +404,7 @@ fn readFixed(bc: *BitcodeReader, comptime T: type, bits: u7) !T {
404404 if (bc.bit_offset == 0) bc.bit_buffer = try bc.read32Bits();
405405 const chunk_len = @min(@as(u6, 32) - bc.bit_offset, remaining);
406406 const chunk_mask = @as(u32, std.math.maxInt(u32)) >> @intCast(32 - chunk_len);
407 result |= @as(T, @intCast(bc.bit_buffer >> bc.bit_offset & chunk_mask)) << @intCast(shift);
407 result |= @as(T, @intCast((bc.bit_buffer >> bc.bit_offset) & chunk_mask)) << @intCast(shift);
408408 shift += @intCast(chunk_len);
409409 remaining -= chunk_len;
410410 bc.bit_offset = @truncate(bc.bit_offset + chunk_len);
lib/std/zig/llvm/Builder.zig+26-26
......@@ -1076,7 +1076,7 @@ pub const Type = enum(u32) {
10761076 child: Type,
10771077
10781078 fn length(self: Array) u64 {
1079 return @as(u64, self.len_hi) << 32 | self.len_lo;
1079 return (@as(u64, self.len_hi) << 32) | self.len_lo;
10801080 }
10811081 };
10821082
......@@ -9520,7 +9520,7 @@ pub const Metadata = packed struct(u32) {
95209520 size_in_bits_hi: u32,
95219521
95229522 pub fn bitSize(self: BasicType) u64 {
9523 return @as(u64, self.size_in_bits_hi) << 32 | self.size_in_bits_lo;
9523 return (@as(u64, self.size_in_bits_hi) << 32) | self.size_in_bits_lo;
95249524 }
95259525 };
95269526
......@@ -9537,10 +9537,10 @@ pub const Metadata = packed struct(u32) {
95379537 fields_tuple: Metadata.Optional,
95389538
95399539 pub fn bitSize(self: CompositeType) u64 {
9540 return @as(u64, self.size_in_bits_hi) << 32 | self.size_in_bits_lo;
9540 return (@as(u64, self.size_in_bits_hi) << 32) | self.size_in_bits_lo;
95419541 }
95429542 pub fn bitAlign(self: CompositeType) u64 {
9543 return @as(u64, self.align_in_bits_hi) << 32 | self.align_in_bits_lo;
9543 return (@as(u64, self.align_in_bits_hi) << 32) | self.align_in_bits_lo;
95449544 }
95459545 };
95469546
......@@ -9558,13 +9558,13 @@ pub const Metadata = packed struct(u32) {
95589558 offset_in_bits_hi: u32,
95599559
95609560 pub fn bitSize(self: DerivedType) u64 {
9561 return @as(u64, self.size_in_bits_hi) << 32 | self.size_in_bits_lo;
9561 return (@as(u64, self.size_in_bits_hi) << 32) | self.size_in_bits_lo;
95629562 }
95639563 pub fn bitAlign(self: DerivedType) u64 {
9564 return @as(u64, self.align_in_bits_hi) << 32 | self.align_in_bits_lo;
9564 return (@as(u64, self.align_in_bits_hi) << 32) | self.align_in_bits_lo;
95659565 }
95669566 pub fn bitOffset(self: DerivedType) u64 {
9567 return @as(u64, self.offset_in_bits_hi) << 32 | self.offset_in_bits_lo;
9567 return (@as(u64, self.offset_in_bits_hi) << 32) | self.offset_in_bits_lo;
95689568 }
95699569 };
95709570
......@@ -12457,7 +12457,7 @@ fn doubleConstAssumeCapacity(self: *Builder, val: f64) Constant {
1245712457 if (ctx.builder.constant_items.items(.tag)[rhs_index] != .double) return false;
1245812458 const rhs_data = ctx.builder.constant_items.items(.data)[rhs_index];
1245912459 const rhs_extra = ctx.builder.constantExtraData(Constant.Double, rhs_data);
12460 return @as(u64, @bitCast(lhs_key)) == @as(u64, rhs_extra.hi) << 32 | rhs_extra.lo;
12460 return @as(u64, @bitCast(lhs_key)) == (@as(u64, rhs_extra.hi) << 32) | rhs_extra.lo;
1246112461 }
1246212462 };
1246312463 const gop = self.constant_map.getOrPutAssumeCapacityAdapted(val, Adapter{ .builder = self });
......@@ -12488,8 +12488,8 @@ fn fp128ConstAssumeCapacity(self: *Builder, val: f128) Constant {
1248812488 if (ctx.builder.constant_items.items(.tag)[rhs_index] != .fp128) return false;
1248912489 const rhs_data = ctx.builder.constant_items.items(.data)[rhs_index];
1249012490 const rhs_extra = ctx.builder.constantExtraData(Constant.Fp128, rhs_data);
12491 return @as(u128, @bitCast(lhs_key)) == @as(u128, rhs_extra.hi_hi) << 96 |
12492 @as(u128, rhs_extra.hi_lo) << 64 | @as(u128, rhs_extra.lo_hi) << 32 | rhs_extra.lo_lo;
12491 return @as(u128, @bitCast(lhs_key)) == (@as(u128, rhs_extra.hi_hi) << 96) |
12492 (@as(u128, rhs_extra.hi_lo) << 64) | (@as(u128, rhs_extra.lo_hi) << 32) | rhs_extra.lo_lo;
1249312493 }
1249412494 };
1249512495 const gop = self.constant_map.getOrPutAssumeCapacityAdapted(val, Adapter{ .builder = self });
......@@ -12522,8 +12522,8 @@ fn x86_fp80ConstAssumeCapacity(self: *Builder, val: f80) Constant {
1252212522 if (ctx.builder.constant_items.items(.tag)[rhs_index] != .x86_fp80) return false;
1252312523 const rhs_data = ctx.builder.constant_items.items(.data)[rhs_index];
1252412524 const rhs_extra = ctx.builder.constantExtraData(Constant.Fp80, rhs_data);
12525 return @as(u80, @bitCast(lhs_key)) == @as(u80, rhs_extra.hi) << 64 |
12526 @as(u80, rhs_extra.lo_hi) << 32 | rhs_extra.lo_lo;
12525 return @as(u80, @bitCast(lhs_key)) == (@as(u80, rhs_extra.hi) << 64) |
12526 (@as(u80, rhs_extra.lo_hi) << 32) | rhs_extra.lo_lo;
1252712527 }
1252812528 };
1252912529 const gop = self.constant_map.getOrPutAssumeCapacityAdapted(val, Adapter{ .builder = self });
......@@ -12555,8 +12555,8 @@ fn ppc_fp128ConstAssumeCapacity(self: *Builder, val: [2]f64) Constant {
1255512555 if (ctx.builder.constant_items.items(.tag)[rhs_index] != .ppc_fp128) return false;
1255612556 const rhs_data = ctx.builder.constant_items.items(.data)[rhs_index];
1255712557 const rhs_extra = ctx.builder.constantExtraData(Constant.Fp128, rhs_data);
12558 return @as(u64, @bitCast(lhs_key[0])) == @as(u64, rhs_extra.lo_hi) << 32 | rhs_extra.lo_lo and
12559 @as(u64, @bitCast(lhs_key[1])) == @as(u64, rhs_extra.hi_hi) << 32 | rhs_extra.hi_lo;
12558 return @as(u64, @bitCast(lhs_key[0])) == (@as(u64, rhs_extra.lo_hi) << 32) | rhs_extra.lo_lo and
12559 @as(u64, @bitCast(lhs_key[1])) == (@as(u64, rhs_extra.hi_hi) << 32) | rhs_extra.hi_lo;
1256012560 }
1256112561 };
1256212562 const gop = self.constant_map.getOrPutAssumeCapacityAdapted(val, Adapter{ .builder = self });
......@@ -15225,18 +15225,18 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco
1522515225 for (limbs) |*limb| {
1522615226 const val = std.mem.littleToNative(i64, @bitCast(limb.*));
1522715227 limb.* = @bitCast(if (val >= 0)
15228 val << 1 | 0
15228 (val << 1) | 0
1522915229 else
15230 -%val << 1 | 1);
15230 (-%val << 1) | 1);
1523115231 }
1523215232 try constants_block.writeUnabbrev(5, record.items);
1523315233 continue;
1523415234 };
1523515235 try constants_block.writeAbbrev(ConstantsBlock.Integer{
1523615236 .value = @bitCast(if (val >= 0)
15237 val << 1 | 0
15237 (val << 1) | 0
1523815238 else
15239 -%val << 1 | 1),
15239 (-%val << 1) | 1),
1524015240 });
1524115241 },
1524215242 .half,
......@@ -15252,8 +15252,8 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco
1525215252 .x86_fp80 => {
1525315253 const extra = self.constantExtraData(Constant.Fp80, data);
1525415254 try constants_block.writeAbbrev(ConstantsBlock.Fp80{
15255 .hi = @as(u64, extra.hi) << 48 | @as(u64, extra.lo_hi) << 16 |
15256 extra.lo_lo >> 16,
15255 .hi = (@as(u64, extra.hi) << 48) | (@as(u64, extra.lo_hi) << 16) |
15256 (extra.lo_lo >> 16),
1525715257 .lo = @truncate(extra.lo_lo),
1525815258 });
1525915259 },
......@@ -15262,8 +15262,8 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco
1526215262 => {
1526315263 const extra = self.constantExtraData(Constant.Fp128, data);
1526415264 try constants_block.writeAbbrev(ConstantsBlock.Fp128{
15265 .lo = @as(u64, extra.lo_hi) << 32 | @as(u64, extra.lo_lo),
15266 .hi = @as(u64, extra.hi_hi) << 32 | @as(u64, extra.hi_lo),
15265 .lo = (@as(u64, extra.lo_hi) << 32) | @as(u64, extra.lo_lo),
15266 .hi = (@as(u64, extra.hi_hi) << 32) | @as(u64, extra.hi_lo),
1526715267 });
1526815268 },
1526915269 .array,
......@@ -15724,9 +15724,9 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco
1572415724 for (limbs) |*limb| {
1572515725 const val = std.mem.littleToNative(i64, @bitCast(limb.*));
1572615726 limb.* = @bitCast(if (val >= 0)
15727 val << 1 | 0
15727 (val << 1) | 0
1572815728 else
15729 -%val << 1 | 1);
15729 (-%val << 1) | 1);
1573015730 }
1573115731 try metadata_block.writeUnabbrev(@backingInt(MetadataBlock.Code.ENUMERATOR), record.items);
1573215732 continue;
......@@ -15736,9 +15736,9 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco
1573615736 .bit_width = extra.bit_width,
1573715737 .name = extra.name,
1573815738 .value = @bitCast(if (val >= 0)
15739 val << 1 | 0
15739 (val << 1) | 0
1574015740 else
15741 -%val << 1 | 1),
15741 (-%val << 1) | 1),
1574215742 }, metadata_adapter);
1574315743 },
1574415744 .subrange => {
lib/std/zig/llvm/bitcode_writer.zig+1-1
......@@ -102,7 +102,7 @@ pub fn BitcodeWriter(comptime types: []const type) type {
102102 // If input is larger than one VBR block can store
103103 // then store vbr_bits - 1 bits and a continue bit
104104 while (in_buffer > mask) {
105 try self.writeBits(in_buffer & mask | continue_bit, vbr_bits);
105 try self.writeBits((in_buffer & mask) | continue_bit, vbr_bits);
106106 in_buffer >>= @intCast(vbr_bits - 1);
107107 }
108108
lib/std/zig/parser_test.zig+42-6
......@@ -3046,19 +3046,14 @@ test "zig fmt: precedence" {
30463046 \\ !(a{});
30473047 \\ a + b{};
30483048 \\ (a + b){};
3049 \\ a << b + c;
30503049 \\ (a << b) + c;
3051 \\ a & b << c;
30523050 \\ (a & b) << c;
3053 \\ a ^ b & c;
30543051 \\ (a ^ b) & c;
3055 \\ a | b ^ c;
30563052 \\ (a | b) ^ c;
30573053 \\ a == b | c;
30583054 \\ (a == b) | c;
30593055 \\ a and b == c;
30603056 \\ (a and b) == c;
3061 \\ a or b and c;
30623057 \\ (a or b) and c;
30633058 \\ (a or b) and c;
30643059 \\ a == b and c == d;
......@@ -3067,6 +3062,47 @@ test "zig fmt: precedence" {
30673062 );
30683063}
30693064
3065test "zig fmt: ambiguous precedence" {
3066 try testError(
3067 \\test "ambiguous precedence" {
3068 \\ a & b << c;
3069 \\ a << b + c;
3070 \\ a << b | c;
3071 \\ a ^ b & c;
3072 \\ a | b ^ c;
3073 \\ a or b and c;
3074 \\ a orelse b catch c;
3075 \\ a % b % c;
3076 \\}
3077 \\
3078 , &[_]Error{
3079 .ambiguous_operator_precedence,
3080 .previous_ambiguous_operator,
3081 .hint_operator_precedence_right,
3082 .ambiguous_operator_precedence,
3083 .previous_ambiguous_operator,
3084 .hint_operator_precedence_right,
3085 .ambiguous_operator_precedence,
3086 .previous_ambiguous_operator,
3087 .hint_operator_precedence_left,
3088 .ambiguous_operator_precedence,
3089 .previous_ambiguous_operator,
3090 .hint_operator_precedence_left,
3091 .ambiguous_operator_precedence,
3092 .previous_ambiguous_operator,
3093 .hint_operator_precedence_left,
3094 .ambiguous_operator_precedence,
3095 .previous_ambiguous_operator,
3096 .hint_operator_precedence_right,
3097 .ambiguous_operator_precedence,
3098 .previous_ambiguous_operator,
3099 .hint_operator_precedence_left,
3100 .illegal_chained_operators,
3101 .previous_ambiguous_operator,
3102 .hint_operator_precedence_left,
3103 });
3104}
3105
30703106test "zig fmt: prefix operators" {
30713107 try testCanonical(
30723108 \\test "prefix operators" {
......@@ -7205,7 +7241,7 @@ test "recovery: missing comma" {
72057241 \\ 2 => {}
72067242 \\ 3 => {}
72077243 \\ else => {
7208 \\ foo & bar +;
7244 \\ foo & bar &;
72097245 \\ }
72107246 \\ }
72117247 \\}
lib/std/zig/system.zig+5-5
......@@ -266,8 +266,8 @@ pub fn resolveTargetQuery(io: Io, query: Target.Query) DetectError!Target {
266266 // Minor * 1(0),000 summed has been convention since FreeBSD 2.2 (1997)
267267 // e.g. 492101 = 4.11-STABLE = 4.(9+2)
268268 const major = value / 100_000;
269 const minor1 = value % 100_000 / 10_000; // usually 0 since 5.1
270 const minor2 = value % 10_000 / 1_000; // 0 before 5.1, minor version since
269 const minor1 = (value % 100_000) / 10_000; // usually 0 since 5.1
270 const minor2 = (value % 10_000) / 1_000; // 0 before 5.1, minor version since
271271 const patch = value % 1_000;
272272 os.version_range.semver.min = .{ .major = major, .minor = minor1 + minor2, .patch = patch };
273273 os.version_range.semver.max = os.version_range.semver.min;
......@@ -280,8 +280,8 @@ pub fn resolveTargetQuery(io: Io, query: Target.Query) DetectError!Target {
280280 // r = 0 (*)
281281 // p = patchlevel
282282 const major = value / 100_000_000;
283 const minor = value % 100_000_000 / 1_000_000;
284 const patch = value % 10_000 / 100;
283 const minor = (value % 100_000_000) / 1_000_000;
284 const patch = (value % 10_000) / 100;
285285 os.version_range.semver.min = .{ .major = major, .minor = minor, .patch = patch };
286286 os.version_range.semver.max = os.version_range.semver.min;
287287 },
......@@ -292,7 +292,7 @@ pub fn resolveTargetQuery(io: Io, query: Target.Query) DetectError!Target {
292292 // m = minor; odd-numbers indicate current dev branch
293293 // p = patch
294294 const major = value / 100_000;
295 const minor = value % 100_000 / 100;
295 const minor = (value % 100_000) / 100;
296296 const patch = value % 100;
297297 os.version_range.semver.min = .{ .major = major, .minor = minor, .patch = patch };
298298 os.version_range.semver.max = os.version_range.semver.min;
lib/std/zig/system/windows.zig+2-2
......@@ -25,7 +25,7 @@ pub fn detectRuntimeVersion() WindowsVersion {
2525 // `---` `` ``--> Sub-version (Starting from Windows 10 onwards)
2626 // \ `--> Service pack (Always zero in the constants defined)
2727 // `--> OS version (Major & minor)
28 const os_ver: u16 = @as(u16, @intCast(version_info.dwMajorVersion & 0xff)) << 8 |
28 const os_ver: u16 = (@as(u16, @intCast(version_info.dwMajorVersion & 0xff)) << 8) |
2929 @as(u16, @intCast(version_info.dwMinorVersion & 0xff));
3030 const sp_ver: u8 = 0;
3131 const sub_ver: u8 = if (os_ver >= 0x0A00) subver: {
......@@ -40,7 +40,7 @@ pub fn detectRuntimeVersion() WindowsVersion {
4040 break :subver @as(u8, @truncate(last_idx));
4141 } else 0;
4242
43 const version: u32 = @as(u32, os_ver) << 16 | @as(u16, sp_ver) << 8 | sub_ver;
43 const version: u32 = (@as(u32, os_ver) << 16) | (@as(u16, sp_ver) << 8) | sub_ver;
4444
4545 return @as(WindowsVersion, @fromBackingInt(@intCast(version)));
4646}
src/Air.zig+1-1
......@@ -1505,7 +1505,7 @@ pub const ShuffleTwoMask = enum(u32) {
15051505 return @fromBackingInt(@intCast(idx << 1));
15061506 }
15071507 pub fn bElem(idx: u32) ShuffleTwoMask {
1508 return @fromBackingInt(@intCast(idx << 1 | 1));
1508 return @fromBackingInt(@intCast((idx << 1) | 1));
15091509 }
15101510 pub const Unwrapped = union(enum) {
15111511 /// The resulting element is this index into the first runtime vector.
src/Compilation.zig+2-2
......@@ -1990,7 +1990,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic,
19901990 .path = try options.dirs.global_cache.join(arena, &.{zir_sub_dir}),
19911991 };
19921992
1993 const std_mod = options.std_mod orelse Module.create(arena, .{
1993 const std_mod = options.std_mod orelse (Module.create(arena, .{
19941994 .paths = .{
19951995 .root = try .fromRoot(arena, options.dirs, .zig_lib, "std"),
19961996 .root_src_path = "std.zig",
......@@ -2015,7 +2015,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic,
20152015 error.StackProtectorUnsupportedByTarget => unreachable,
20162016 error.StackProtectorUnavailableWithoutLibC => unreachable,
20172017 error.PatchableFunctionEntryUnsupportedByBackend => unreachable,
2018 };
2018 });
20192019
20202020 const zcu = try arena.create(Zcu);
20212021 zcu.* = .{
src/IncrementalDebugServer.zig+2-2
......@@ -243,7 +243,7 @@ fn handleCommand(zcu: *Zcu, w: *Io.Writer, cmd_str: []const u8, arg_str: []const
243243 for (zcu.incremental_debug_state.types.keys()) |type_ip_index| {
244244 const ty: Type = .fromInterned(type_ip_index);
245245 const ty_name = ty.containerTypeName(ip).fqn.toSlice(ip);
246 const success = switch (@as(u2, @intFromBool(anchor_start)) << 1 | @intFromBool(anchor_end)) {
246 const success = switch ((@as(u2, @intFromBool(anchor_start)) << 1) | @intFromBool(anchor_end)) {
247247 0b00 => std.mem.find(u8, ty_name, query) != null,
248248 0b01 => std.mem.endsWith(u8, ty_name, query),
249249 0b10 => std.mem.startsWith(u8, ty_name, query),
......@@ -264,7 +264,7 @@ fn handleCommand(zcu: *Zcu, w: *Io.Writer, cmd_str: []const u8, arg_str: []const
264264 for (zcu.incremental_debug_state.navs.keys()) |nav_index| {
265265 const nav = ip.getNav(nav_index);
266266 const nav_fqn = nav.fqn.toSlice(ip);
267 const success = switch (@as(u2, @intFromBool(anchor_start)) << 1 | @intFromBool(anchor_end)) {
267 const success = switch ((@as(u2, @intFromBool(anchor_start)) << 1) | @intFromBool(anchor_end)) {
268268 0b00 => std.mem.find(u8, nav_fqn, query) != null,
269269 0b01 => std.mem.endsWith(u8, nav_fqn, query),
270270 0b10 => std.mem.startsWith(u8, nav_fqn, query),
src/InternPool.zig+18-18
......@@ -215,7 +215,7 @@ pub const TrackedInst = extern struct {
215215 };
216216 pub fn unwrap(tracked_inst_index: TrackedInst.Index, ip: *const InternPool) Unwrapped {
217217 return .{
218 .tid = @fromBackingInt(@intCast(@backingInt(tracked_inst_index) >> ip.tid_shift_32 & ip.getTidMask())),
218 .tid = @fromBackingInt(@intCast((@backingInt(tracked_inst_index) >> ip.tid_shift_32) & ip.getTidMask())),
219219 .index = @backingInt(tracked_inst_index) & ip.getIndexMask(u32),
220220 };
221221 }
......@@ -517,7 +517,7 @@ pub const ComptimeUnit = extern struct {
517517 };
518518 fn unwrap(id: Id, ip: *const InternPool) Unwrapped {
519519 return .{
520 .tid = @fromBackingInt(@intCast(@backingInt(id) >> ip.tid_shift_32 & ip.getTidMask())),
520 .tid = @fromBackingInt(@intCast((@backingInt(id) >> ip.tid_shift_32) & ip.getTidMask())),
521521 .index = @backingInt(id) & ip.getIndexMask(u31),
522522 };
523523 }
......@@ -655,7 +655,7 @@ pub const Nav = struct {
655655 };
656656 fn unwrap(nav_index: Nav.Index, ip: *const InternPool) Unwrapped {
657657 return .{
658 .tid = @fromBackingInt(@intCast(@backingInt(nav_index) >> ip.tid_shift_30 & ip.getTidMask())),
658 .tid = @fromBackingInt(@intCast((@backingInt(nav_index) >> ip.tid_shift_30) & ip.getTidMask())),
659659 .index = @backingInt(nav_index) & ip.getIndexMask(u30),
660660 };
661661 }
......@@ -1627,7 +1627,7 @@ pub const MapIndex = enum(u32) {
16271627 };
16281628 fn unwrap(map_index: MapIndex, ip: *const InternPool) Unwrapped {
16291629 return .{
1630 .tid = @fromBackingInt(@intCast(@backingInt(map_index) >> ip.tid_shift_32 & ip.getTidMask())),
1630 .tid = @fromBackingInt(@intCast((@backingInt(map_index) >> ip.tid_shift_32) & ip.getTidMask())),
16311631 .index = @backingInt(map_index) & ip.getIndexMask(u32),
16321632 };
16331633 }
......@@ -1648,14 +1648,14 @@ pub const NamespaceIndex = enum(u32) {
16481648 assert(unwrapped.bucket_index <= ip.getIndexMask(u32) >> Local.namespaces_bucket_width);
16491649 assert(unwrapped.index <= Local.namespaces_bucket_mask);
16501650 return @fromBackingInt(@intCast(@shlExact(@as(u32, @backingInt(unwrapped.tid)), ip.tid_shift_32) |
1651 unwrapped.bucket_index << Local.namespaces_bucket_width |
1651 (unwrapped.bucket_index << Local.namespaces_bucket_width) |
16521652 unwrapped.index));
16531653 }
16541654 };
16551655 fn unwrap(namespace_index: NamespaceIndex, ip: *const InternPool) Unwrapped {
16561656 const index = @backingInt(namespace_index) & ip.getIndexMask(u32);
16571657 return .{
1658 .tid = @fromBackingInt(@intCast(@backingInt(namespace_index) >> ip.tid_shift_32 & ip.getTidMask())),
1658 .tid = @fromBackingInt(@intCast((@backingInt(namespace_index) >> ip.tid_shift_32) & ip.getTidMask())),
16591659 .bucket_index = index >> Local.namespaces_bucket_width,
16601660 .index = index & Local.namespaces_bucket_mask,
16611661 };
......@@ -1696,7 +1696,7 @@ pub const FileIndex = enum(u32) {
16961696 };
16971697 pub fn unwrap(file_index: FileIndex, ip: *const InternPool) Unwrapped {
16981698 return .{
1699 .tid = @fromBackingInt(@intCast(@backingInt(file_index) >> ip.tid_shift_32 & ip.getTidMask())),
1699 .tid = @fromBackingInt(@intCast((@backingInt(file_index) >> ip.tid_shift_32) & ip.getTidMask())),
17001700 .index = @backingInt(file_index) & ip.getIndexMask(u32),
17011701 };
17021702 }
......@@ -1755,7 +1755,7 @@ pub const String = enum(u32) {
17551755 };
17561756 fn unwrap(string: String, ip: *const InternPool) Unwrapped {
17571757 return .{
1758 .tid = @fromBackingInt(@intCast(@backingInt(string) >> ip.tid_shift_32 & ip.getTidMask())),
1758 .tid = @fromBackingInt(@intCast((@backingInt(string) >> ip.tid_shift_32) & ip.getTidMask())),
17591759 .index = @backingInt(string) & ip.getIndexMask(u32),
17601760 };
17611761 }
......@@ -4199,7 +4199,7 @@ pub const Index = enum(u32) {
41994199 };
42004200 pub fn unwrap(index: Index, ip: *const InternPool) Unwrapped {
42014201 return .{
4202 .tid = @fromBackingInt(@intCast(@backingInt(index) >> ip.tid_shift_30 & ip.getTidMask())),
4202 .tid = @fromBackingInt(@intCast((@backingInt(index) >> ip.tid_shift_30) & ip.getTidMask())),
42034203 .index = @backingInt(index) & ip.getIndexMask(u30),
42044204 };
42054205 }
......@@ -6062,7 +6062,7 @@ pub const PtrNav = struct {
60626062 };
60636063 }
60646064 fn byteOffset(data: @This()) u64 {
6065 return @as(u64, data.byte_offset_a) << 32 | data.byte_offset_b;
6065 return (@as(u64, data.byte_offset_a) << 32) | data.byte_offset_b;
60666066 }
60676067};
60686068
......@@ -6080,7 +6080,7 @@ pub const PtrUav = struct {
60806080 };
60816081 }
60826082 fn byteOffset(data: @This()) u64 {
6083 return @as(u64, data.byte_offset_a) << 32 | data.byte_offset_b;
6083 return (@as(u64, data.byte_offset_a) << 32) | data.byte_offset_b;
60846084 }
60856085};
60866086
......@@ -6101,7 +6101,7 @@ pub const PtrUavAligned = struct {
61016101 };
61026102 }
61036103 fn byteOffset(data: @This()) u64 {
6104 return @as(u64, data.byte_offset_a) << 32 | data.byte_offset_b;
6104 return (@as(u64, data.byte_offset_a) << 32) | data.byte_offset_b;
61056105 }
61066106};
61076107
......@@ -6119,7 +6119,7 @@ pub const PtrComptimeAlloc = struct {
61196119 };
61206120 }
61216121 fn byteOffset(data: @This()) u64 {
6122 return @as(u64, data.byte_offset_a) << 32 | data.byte_offset_b;
6122 return (@as(u64, data.byte_offset_a) << 32) | data.byte_offset_b;
61236123 }
61246124};
61256125
......@@ -6137,7 +6137,7 @@ pub const PtrComptimeField = struct {
61376137 };
61386138 }
61396139 fn byteOffset(data: @This()) u64 {
6140 return @as(u64, data.byte_offset_a) << 32 | data.byte_offset_b;
6140 return (@as(u64, data.byte_offset_a) << 32) | data.byte_offset_b;
61416141 }
61426142};
61436143
......@@ -6155,7 +6155,7 @@ pub const PtrBase = struct {
61556155 };
61566156 }
61576157 fn byteOffset(data: @This()) u64 {
6158 return @as(u64, data.byte_offset_a) << 32 | data.byte_offset_b;
6158 return (@as(u64, data.byte_offset_a) << 32) | data.byte_offset_b;
61596159 }
61606160};
61616161
......@@ -6175,7 +6175,7 @@ pub const PtrBaseIndex = struct {
61756175 };
61766176 }
61776177 fn byteOffset(data: @This()) u64 {
6178 return @as(u64, data.byte_offset_a) << 32 | data.byte_offset_b;
6178 return (@as(u64, data.byte_offset_a) << 32) | data.byte_offset_b;
61796179 }
61806180};
61816181
......@@ -6191,7 +6191,7 @@ pub const PtrInt = struct {
61916191 };
61926192 }
61936193 fn byteOffset(data: @This()) u64 {
6194 return @as(u64, data.byte_offset_a) << 32 | data.byte_offset_b;
6194 return (@as(u64, data.byte_offset_a) << 32) | data.byte_offset_b;
61956195 }
61966196};
61976197
......@@ -12634,7 +12634,7 @@ const PackedCallingConvention = packed struct(u18) {
1263412634 std.lang.CallingConvention.SpirvFragmentOptions => .{
1263512635 .tag = tag,
1263612636 .incoming_stack_alignment = .none,
12637 .extra = @as(u4, @backingInt(pl.depth_assumption)) << 1 | @intFromBool(pl.pixel_centered_integer),
12637 .extra = (@as(u4, @backingInt(pl.depth_assumption)) << 1) | @intFromBool(pl.pixel_centered_integer),
1263812638 },
1263912639 std.lang.CallingConvention.SpirvMeshOptions => .{
1264012640 .tag = tag,
src/Sema.zig+2-2
......@@ -29942,10 +29942,10 @@ fn coerceVarArgParam(
2994229942 if (!uncasted_ty.validateExtern(.param_ty, zcu)) break :int inst;
2994329943 const target = zcu.getTarget();
2994429944 const uncasted_info = uncasted_ty.intInfo(zcu);
29945 if (uncasted_info.bits <= target.cTypeBitSize(switch (uncasted_info.signedness) {
29945 if (uncasted_info.bits <= (target.cTypeBitSize(switch (uncasted_info.signedness) {
2994629946 .signed => .int,
2994729947 .unsigned => .uint,
29948 }) orelse break :int inst) break :int try sema.coerce(block, switch (uncasted_info.signedness) {
29948 }) orelse break :int inst)) break :int try sema.coerce(block, switch (uncasted_info.signedness) {
2994929949 .signed => .c_int,
2995029950 .unsigned => .c_uint,
2995129951 }, inst, inst_src);
src/codegen/aarch64/Assemble.zig+2-2
......@@ -164,7 +164,7 @@ const matchers = matchers: {
164164 return @call(.auto, encode, args);
165165 } else if (pattern_token[0] == '<') {
166166 const symbol_name = comptime pattern_token[1 .. std.mem.findScalarPos(u8, pattern_token, 1, '|') orelse
167 pattern_token.len - 1];
167 (pattern_token.len - 1)];
168168 const symbol = @field(Symbol, symbol_name);
169169 const symbol_ptr = &@field(symbols, symbol_name);
170170 const symbol_value = zonCast(SymbolSpec, @field(instruction.symbols, symbol_name), .{}).parse(source_token) orelse {
......@@ -453,7 +453,7 @@ const SymbolSpec = union(enum) {
453453 } else {
454454 const Repr = std.math.FloatRepr(f16);
455455 const repr: Repr = @bitCast(fimm);
456 if (repr.mantissa & std.math.maxInt(Repr.Mantissa) >> 5 != 0 or switch (repr.exponent) {
456 if ((repr.mantissa & (std.math.maxInt(Repr.Mantissa) >> 5)) != 0 or switch (repr.exponent) {
457457 .denormal, .infinite => true,
458458 else => std.math.cast(i3, repr.exponent.unbias() - 1) == null,
459459 }) {
src/codegen/aarch64/Disassemble.zig+4-4
......@@ -31,7 +31,7 @@ pub fn printInstruction(dis: Disassemble, inst: aarch64.encoding.Instruction, wr
3131 .unallocated => break :unallocated,
3232 .pc_relative_addressing => |pc_relative_addressing| {
3333 const group = pc_relative_addressing.group;
34 const imm = (@as(i33, group.immhi) << 2 | @as(i33, group.immlo) << 0) + @as(i33, switch (group.op) {
34 const imm = ((@as(i33, group.immhi) << 2) | (@as(i33, group.immlo) << 0)) + @as(i33, switch (group.op) {
3535 .adr => aarch64.encoding.Instruction.size,
3636 .adrp => 0,
3737 });
......@@ -311,7 +311,7 @@ pub fn printInstruction(dis: Disassemble, inst: aarch64.encoding.Instruction, wr
311311 .hint => |hint| return writer.print("{f}{s}#0x{x}", .{
312312 fmtCase(.hint, dis.case),
313313 dis.mnemonic_operands_separator,
314 @as(u7, hint.CRm) << 3 | @as(u7, hint.op2) << 0,
314 (@as(u7, hint.CRm) << 3) | (@as(u7, hint.op2) << 0),
315315 }),
316316 else => |decoded| return writer.print("{f}", .{fmtCase(decoded, dis.case)}),
317317 },
......@@ -365,8 +365,8 @@ pub fn printInstruction(dis: Disassemble, inst: aarch64.encoding.Instruction, wr
365365 dis.mnemonic_operands_separator,
366366 group.Rt.decode(.{}).general(@fromBackingInt(@intCast(group.b5))).fmtCase(dis.case),
367367 dis.operands_separator,
368 @as(u6, group.b5) << 5 |
369 @as(u6, group.b40) << 0,
368 (@as(u6, group.b5) << 5) |
369 (@as(u6, group.b40) << 0),
370370 dis.operands_separator,
371371 @as(u8, if (imm < 0) '-' else '+'),
372372 @abs(imm) << 2,
src/codegen/aarch64/Mir.zig+3-3
......@@ -208,7 +208,7 @@ fn emitReloc(
208208 };
209209 try atom.addReloc(gpa, .{
210210 .r_offset = offset,
211 .r_info = @as(u64, @backingInt(sym_index)) << 32 | @backingInt(r_type),
211 .r_info = (@as(u64, @backingInt(sym_index)) << 32) | @backingInt(r_type),
212212 .r_addend = @bitCast(addend),
213213 }, zo);
214214 } else if (lf.cast(.macho)) |mf| {
......@@ -265,7 +265,7 @@ fn emitReloc(
265265 };
266266 try atom.addReloc(gpa, .{
267267 .r_offset = offset,
268 .r_info = @as(u64, @backingInt(sym_index)) << 32 | @backingInt(r_type),
268 .r_info = (@as(u64, @backingInt(sym_index)) << 32) | @backingInt(r_type),
269269 .r_addend = @bitCast(addend),
270270 }, zo);
271271 } else if (lf.cast(.macho)) |mf| {
......@@ -328,7 +328,7 @@ fn emitReloc(
328328 };
329329 try atom.addReloc(gpa, .{
330330 .r_offset = offset,
331 .r_info = @as(u64, @backingInt(sym_index)) << 32 | @backingInt(r_type),
331 .r_info = (@as(u64, @backingInt(sym_index)) << 32) | @backingInt(r_type),
332332 .r_addend = @bitCast(addend),
333333 }, zo);
334334 } else if (lf.cast(.macho)) |mf| {
src/codegen/aarch64/Select.zig+4-4
......@@ -8099,7 +8099,7 @@ fn movImmediate(isel: *Select, dst_reg: Register, src_imm: u64) !void {
80998099 .{ .immediate = .{
81008100 .N = @fromBackingInt(@intCast(elem_width >> 6)),
81018101 .immr = hi + mid_masked,
8102 .imms = ((((lo + hi) & smask) | mid_masked) - 1) | -%@as(u6, @truncate(elem_width)) << 1,
8102 .imms = ((((lo + hi) & smask) | mid_masked) - 1) | (-%@as(u6, @truncate(elem_width)) << 1),
81038103 } },
81048104 ));
81058105 }
......@@ -10831,7 +10831,7 @@ pub const Value = struct {
1083110831 if (feat_fp16) {
1083210832 const Repr = std.math.FloatRepr(f16);
1083310833 const repr: Repr = @bitCast(imm);
10834 if (repr.mantissa & std.math.maxInt(Repr.Mantissa) >> 5 == 0 and switch (repr.exponent) {
10834 if (repr.mantissa & (std.math.maxInt(Repr.Mantissa) >> 5) == 0 and switch (repr.exponent) {
1083510835 .denormal, .infinite => false,
1083610836 else => std.math.cast(i3, repr.exponent.unbias() - 1) != null,
1083710837 }) break :free try isel.emit(.fmov(mat.ra.h(), .{ .immediate = imm }));
......@@ -10855,7 +10855,7 @@ pub const Value = struct {
1085510855 } };
1085610856 const Repr = std.math.FloatRepr(f32);
1085710857 const repr: Repr = @bitCast(imm);
10858 if (repr.mantissa & std.math.maxInt(Repr.Mantissa) >> 5 == 0 and switch (repr.exponent) {
10858 if (repr.mantissa & (std.math.maxInt(Repr.Mantissa) >> 5) == 0 and switch (repr.exponent) {
1085910859 .denormal, .infinite => false,
1086010860 else => std.math.cast(i3, repr.exponent.unbias() - 1) != null,
1086110861 }) break :free try isel.emit(.fmov(mat.ra.s(), .{ .immediate = @floatCast(imm) }));
......@@ -10878,7 +10878,7 @@ pub const Value = struct {
1087810878 } };
1087910879 const Repr = std.math.FloatRepr(f64);
1088010880 const repr: Repr = @bitCast(imm);
10881 if (repr.mantissa & std.math.maxInt(Repr.Mantissa) >> 5 == 0 and switch (repr.exponent) {
10881 if (repr.mantissa & (std.math.maxInt(Repr.Mantissa) >> 5) == 0 and switch (repr.exponent) {
1088210882 .denormal, .infinite => false,
1088310883 else => std.math.cast(i3, repr.exponent.unbias() - 1) != null,
1088410884 }) break :free try isel.emit(.fmov(mat.ra.d(), .{ .immediate = @floatCast(imm) }));
src/codegen/aarch64/encoding.zig+19-19
......@@ -11886,9 +11886,9 @@ pub const Instruction = packed union {
1188611886 .cmode = switch (arrangement) {
1188711887 else => unreachable,
1188811888 .@"4h", .@"8h" => @as(u3, 0b100) |
11889 @as(u3, @as(u1, @intCast(@shrExact(shifted_immediate.lsl, 3)))) << 0,
11889 (@as(u3, @as(u1, @intCast(@shrExact(shifted_immediate.lsl, 3)))) << 0),
1189011890 .@"2s", .@"4s" => @as(u3, 0b000) |
11891 @as(u3, @as(u2, @intCast(@shrExact(shifted_immediate.lsl, 3)))) << 0,
11891 (@as(u3, @as(u2, @intCast(@shrExact(shifted_immediate.lsl, 3)))) << 0),
1189211892 },
1189311893 .imm3 = @intCast(shifted_immediate.immediate >> 5),
1189411894 .Q = arrangement.size(),
......@@ -12384,7 +12384,7 @@ pub const Instruction = packed union {
1238412384 .dup = .{
1238512385 .Rd = d.alias.encode(.{ .V = true }),
1238612386 .Rn = n.alias.encode(.{ .V = true }),
12387 .imm5 = @shlExact(@as(u5, n.format.element.index) << 1 | @as(u5, 0b1), @backingInt(elem_size)),
12387 .imm5 = @shlExact((@as(u5, n.format.element.index) << 1) | @as(u5, 0b1), @backingInt(elem_size)),
1238812388 },
1238912389 } } };
1239012390 },
......@@ -12400,7 +12400,7 @@ pub const Instruction = packed union {
1240012400 .Rd = d.alias.encode(.{ .V = true }),
1240112401 .Rn = n.alias.encode(.{ .V = true }),
1240212402 .imm4 = .element,
12403 .imm5 = @shlExact(@as(u5, element.index) << 1 | @as(u5, 0b1), @backingInt(elem_size)),
12403 .imm5 = @shlExact((@as(u5, element.index) << 1) | @as(u5, 0b1), @backingInt(elem_size)),
1240412404 .Q = arrangement.size(),
1240512405 },
1240612406 } } };
......@@ -14195,7 +14195,7 @@ pub const Instruction = packed union {
1419514195 .Rd = d.alias.encode(.{ .V = true }),
1419614196 .Rn = n.alias.encode(.{ .V = true }),
1419714197 .imm4 = .{ .element = element.index << @intCast(@backingInt(elem_size)) },
14198 .imm5 = (@as(u5, d.format.element.index) << 1 | @as(u5, 0b1) << 0) << @backingInt(elem_size),
14198 .imm5 = ((@as(u5, d.format.element.index) << 1) | (@as(u5, 0b1) << 0)) << @backingInt(elem_size),
1419914199 .op = .element,
1420014200 },
1420114201 } } };
......@@ -14211,7 +14211,7 @@ pub const Instruction = packed union {
1421114211 .Rd = d.alias.encode(.{ .V = true }),
1421214212 .Rn = n.alias.encode(.{}),
1421314213 .imm4 = .{ .general = .general },
14214 .imm5 = (@as(u5, d.format.element.index) << 1 | @as(u5, 0b1) << 0) << @backingInt(elem_size),
14214 .imm5 = ((@as(u5, d.format.element.index) << 1) | (@as(u5, 0b1) << 0)) << @backingInt(elem_size),
1421514215 .op = .general,
1421614216 },
1421714217 } } };
......@@ -15072,16 +15072,16 @@ pub const Instruction = packed union {
1507215072 .lsl => |amount| switch (arrangement) {
1507315073 else => unreachable,
1507415074 .@"8b", .@"16b" => @as(u4, 0b1110) |
15075 @as(u4, @as(u0, @intCast(@shrExact(amount, 3)))) << 1,
15075 (@as(u4, @as(u0, @intCast(@shrExact(amount, 3)))) << 1),
1507615076 .@"4h", .@"8h" => @as(u4, 0b1000) |
15077 @as(u4, @as(u1, @intCast(@shrExact(amount, 3)))) << 1,
15077 (@as(u4, @as(u1, @intCast(@shrExact(amount, 3)))) << 1),
1507815078 .@"2s", .@"4s" => @as(u4, 0b0000) |
15079 @as(u4, @as(u2, @intCast(@shrExact(amount, 3)))) << 1,
15079 (@as(u4, @as(u2, @intCast(@shrExact(amount, 3)))) << 1),
1508015080 },
1508115081 .msl => |amount| switch (arrangement) {
1508215082 else => unreachable,
1508315083 .@"2s", .@"4s" => @as(u4, 0b1100) |
15084 @as(u4, @as(u1, @intCast(@shrExact(amount, 3) - 1))) << 0,
15084 (@as(u4, @as(u1, @intCast(@shrExact(amount, 3) - 1))) << 0),
1508515085 },
1508615086 .replicate => switch (arrangement) {
1508715087 else => unreachable,
......@@ -15345,9 +15345,9 @@ pub const Instruction = packed union {
1534515345 .cmode = switch (arrangement) {
1534615346 else => unreachable,
1534715347 .@"4h", .@"8h" => @as(u3, 0b100) |
15348 @as(u3, @as(u1, @intCast(@shrExact(shifted_immediate.lsl, 3)))) << 0,
15348 (@as(u3, @as(u1, @intCast(@shrExact(shifted_immediate.lsl, 3)))) << 0),
1534915349 .@"2s", .@"4s" => @as(u3, 0b000) |
15350 @as(u3, @as(u2, @intCast(@shrExact(shifted_immediate.lsl, 3)))) << 0,
15350 (@as(u3, @as(u2, @intCast(@shrExact(shifted_immediate.lsl, 3)))) << 0),
1535115351 },
1535215352 .imm3 = @intCast(shifted_immediate.immediate >> 5),
1535315353 .Q = arrangement.size(),
......@@ -15660,9 +15660,9 @@ pub const Instruction = packed union {
1566015660 .Rn = n.alias.encode(.{ .V = true }),
1566115661 .imm5 = switch (vs) {
1566215662 else => unreachable,
15663 .byte => @as(u5, @as(u4, @intCast(n.format.element.index))) << 1 | @as(u5, 0b1) << 0,
15664 .half => @as(u5, @as(u3, @intCast(n.format.element.index))) << 2 | @as(u5, 0b10) << 0,
15665 .single => @as(u5, @as(u2, @intCast(n.format.element.index))) << 3 | @as(u5, 0b100) << 0,
15663 .byte => (@as(u5, @as(u4, @intCast(n.format.element.index))) << 1) | (@as(u5, 0b1) << 0),
15664 .half => (@as(u5, @as(u3, @intCast(n.format.element.index))) << 2) | (@as(u5, 0b10) << 0),
15665 .single => (@as(u5, @as(u2, @intCast(n.format.element.index))) << 3) | (@as(u5, 0b100) << 0),
1566615666 },
1566715667 .Q = sf,
1566815668 },
......@@ -16492,10 +16492,10 @@ pub const Instruction = packed union {
1649216492 .Rn = n.alias.encode(.{ .V = true }),
1649316493 .imm5 = switch (vs) {
1649416494 else => unreachable,
16495 .byte => @as(u5, @as(u4, @intCast(n.format.element.index))) << 1 | @as(u5, 0b1) << 0,
16496 .half => @as(u5, @as(u3, @intCast(n.format.element.index))) << 2 | @as(u5, 0b10) << 0,
16497 .single => @as(u5, @as(u2, @intCast(n.format.element.index))) << 3 | @as(u5, 0b100) << 0,
16498 .double => @as(u5, @as(u1, @intCast(n.format.element.index))) << 4 | @as(u5, 0b1000) << 0,
16495 .byte => (@as(u5, @as(u4, @intCast(n.format.element.index))) << 1) | (@as(u5, 0b1) << 0),
16496 .half => (@as(u5, @as(u3, @intCast(n.format.element.index))) << 2) | (@as(u5, 0b10) << 0),
16497 .single => (@as(u5, @as(u2, @intCast(n.format.element.index))) << 3) | (@as(u5, 0b100) << 0),
16498 .double => (@as(u5, @as(u1, @intCast(n.format.element.index))) << 4) | (@as(u5, 0b1000) << 0),
1649916499 },
1650016500 .Q = sf,
1650116501 },
src/codegen/loongarch/Mir.zig+1-1
......@@ -181,7 +181,7 @@ fn emitReloc(
181181 const atom = zo.symbol(@backingInt(atom_index)).atom(ef).?;
182182 try atom.addReloc(zcu.gpa, .{
183183 .r_offset = offset,
184 .r_info = @as(u64, @backingInt(sym_index)) << 32 | @backingInt(reloc_type),
184 .r_info = (@as(u64, @backingInt(sym_index)) << 32) | @backingInt(reloc_type),
185185 .r_addend = @bitCast(addend),
186186 }, zo);
187187 } else unreachable;
src/codegen/riscv64/CodeGen.zig+2-2
......@@ -1764,7 +1764,7 @@ fn finishAir(
17641764) !void {
17651765 const tomb_bits = func.liveness.getTombBits(inst);
17661766 for (0.., operands) |op_index, op| {
1767 if (tomb_bits & @as(Air.Liveness.Bpi, 1) << @intCast(op_index) == 0) continue;
1767 if (tomb_bits & (@as(Air.Liveness.Bpi, 1) << @intCast(op_index)) == 0) continue;
17681768 if (func.reused_operands.isSet(op_index)) continue;
17691769 try func.processDeath(op.toIndexAllowNone() orelse continue);
17701770 }
......@@ -6272,7 +6272,7 @@ fn airAsm(func: *Func, inst: Air.Inst.Index) !void {
62726272 "";
62736273
62746274 op.* = switch (args.items[
6275 arg_map.get(op_str["%[".len .. mod_index orelse op_str.len - "]".len]) orelse
6275 arg_map.get(op_str["%[".len .. mod_index orelse (op_str.len - "]".len)]) orelse
62766276 return func.fail("no matching constraint: '{s}'", .{op_str})
62776277 ]) {
62786278 .lea_symbol => |sym_off| if (mem.eql(u8, modifier, "plt")) blk: {
src/codegen/riscv64/encoding.zig+2-2
......@@ -582,8 +582,8 @@ pub const Instruction = union(Lir.Format) {
582582
583583 .opcode = opcode,
584584 .funct3 = @backingInt(amo.width),
585 .funct7 = @as(u7, amo.funct5) << 2 |
586 @as(u7, @intFromBool(ops[3].barrier == .rl)) << 1 |
585 .funct7 = (@as(u7, amo.funct5) << 2) |
586 (@as(u7, @intFromBool(ops[3].barrier == .rl)) << 1) |
587587 @as(u7, @intFromBool(ops[4].barrier == .aq)),
588588 },
589589 else => unreachable,
src/codegen/sparc64/CodeGen.zig+2-2
......@@ -3475,11 +3475,11 @@ fn finishAirBookkeeping(self: *Self) void {
34753475fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Air.Liveness.bpi - 1]Air.Inst.Ref) void {
34763476 const tomb_bits = self.liveness.getTombBits(inst);
34773477 for (0.., operands) |op_index, op| {
3478 if (tomb_bits & @as(Air.Liveness.Bpi, 1) << @intCast(op_index) == 0) continue;
3478 if (tomb_bits & (@as(Air.Liveness.Bpi, 1) << @intCast(op_index)) == 0) continue;
34793479 if (self.reused_operands.isSet(op_index)) continue;
34803480 self.processDeath(op.toIndexAllowNone() orelse continue);
34813481 }
3482 if (tomb_bits & 1 << (Air.Liveness.bpi - 1) == 0) {
3482 if (tomb_bits & (1 << (Air.Liveness.bpi - 1)) == 0) {
34833483 log.debug("%{d} => {}", .{ inst, result });
34843484 const branch = &self.branch_stack.items[self.branch_stack.items.len - 1];
34853485 branch.inst_table.putAssumeCapacityNoClobber(inst, result);
src/codegen/spirv/CodeGen.zig+1-1
......@@ -1191,7 +1191,7 @@ fn constInt(cg: *CodeGen, ty: Type, value: anytype) !Id {
11911191 const truncated_value = if (backing_bits == 64)
11921192 value64
11931193 else
1194 value64 & (@as(u64, 1) << @intCast(backing_bits)) - 1;
1194 value64 & ((@as(u64, 1) << @intCast(backing_bits)) - 1);
11951195
11961196 break :blk switch (backing_bits) {
11971197 1...32 => .{ .uint32 = @truncate(truncated_value) },
src/codegen/x86_64/CodeGen.zig+17-17
......@@ -173255,7 +173255,7 @@ fn finishAir(
173255173255) !void {
173256173256 const tomb_bits = self.liveness.getTombBits(inst);
173257173257 for (0.., operands) |op_index, op| {
173258 if (tomb_bits & @as(Air.Liveness.Bpi, 1) << @intCast(op_index) == 0) continue;
173258 if (tomb_bits & (@as(Air.Liveness.Bpi, 1) << @intCast(op_index)) == 0) continue;
173259173259 if (self.reused_operands.isSet(op_index)) continue;
173260173260 try self.processDeath(op.toIndexAllowNone() orelse continue, .{});
173261173261 }
......@@ -176321,7 +176321,7 @@ fn lowerSwitchBr(
176321176321 const unsigned_condition_ty = try cg.pt.intType(.unsigned, cg.intInfo(condition_ty).?.bits);
176322176322
176323176323 const ExpectedContents = extern struct {
176324 liveness_deaths: [1 << 8 | 1]Air.Inst.Index,
176324 liveness_deaths: [(1 << 8) | 1]Air.Inst.Index,
176325176325 bigint_limbs: [std.math.big.int.calcTwosCompLimbCount(1 << 10)]std.math.big.Limb,
176326176326 relocs: [1 << 6]Mir.Inst.Index,
176327176327 };
......@@ -177310,7 +177310,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
177310177310 else
177311177311 "";
177312177312 op.* = switch (args[
177313 arg_map.get(op_str["%[".len .. colon orelse op_str.len - "]".len]) orelse
177313 arg_map.get(op_str["%[".len .. colon orelse (op_str.len - "]".len)]) orelse
177314177314 return self.fail("no matching constraint: '{s}'", .{op_str})
177315177315 ]) {
177316177316 .immediate => |imm| if (std.mem.eql(u8, modifier, "") or
......@@ -177454,7 +177454,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
177454177454 else
177455177455 "";
177456177456 break :disp switch (args[
177457 arg_map.get(op_str["%[".len .. colon orelse open - "]".len]) orelse
177457 arg_map.get(op_str["%[".len .. colon orelse (open - "]".len)]) orelse
177458177458 return self.fail("no matching constraint: '{s}'", .{op_str})
177459177459 ]) {
177460177460 .immediate => |imm| if (std.mem.eql(u8, modifier, "") or
......@@ -179566,7 +179566,7 @@ fn atomicOp(
179566179566 };
179567179567 defer if (mem_lock) |lock| self.register_manager.unlockReg(lock);
179568179568
179569 const use_sse = rmw_op orelse .Xchg != .Xchg and val_ty.isRuntimeFloat();
179569 const use_sse = (rmw_op orelse .Xchg) != .Xchg and val_ty.isRuntimeFloat();
179570179570 const strat: enum { lock, loop, libcall } = if (use_sse) .loop else switch (rmw_op orelse .Xchg) {
179571179571 .Xchg,
179572179572 .Add,
......@@ -179626,7 +179626,7 @@ fn atomicOp(
179626179626
179627179627 try self.asmRegisterMemory(.{ ._, .mov }, registerAlias(.rax, val_abi_size), ptr_mem);
179628179628 const loop: Mir.Inst.Index = @intCast(self.mir_instructions.len);
179629 if (!use_sse and rmw_op orelse .Xchg != .Xchg) {
179629 if (!use_sse and (rmw_op orelse .Xchg) != .Xchg) {
179630179630 try self.genSetReg(tmp_reg, val_ty, .{ .register = .rax }, .{});
179631179631 }
179632179632 if (rmw_op) |op| if (use_sse) {
......@@ -188854,7 +188854,7 @@ const Temp = struct {
188854188854 for (0.., op_refs, op_temps) |op_index, op_ref, op_temp| {
188855188855 if (op_temp.index == temp.index) continue;
188856188856 if (op_temp.tracking(cg).short != .dead) try op_temp.die(cg);
188857 if (tomb_bits & @as(Air.Liveness.Bpi, 1) << @intCast(op_index) == 0) continue;
188857 if (tomb_bits & (@as(Air.Liveness.Bpi, 1) << @intCast(op_index)) == 0) continue;
188858188858 if (cg.reused_operands.isSet(op_index)) continue;
188859188859 try cg.processDeath(op_ref.toIndexAllowNone() orelse continue, .{});
188860188860 }
......@@ -188916,7 +188916,7 @@ const Temp = struct {
188916188916 }
188917188917 for (0.., op_refs, op_temps) |op_index, op_ref, op_temp| {
188918188918 if (op_temp.index != temp.index) continue;
188919 if (tomb_bits & @as(Air.Liveness.Bpi, 1) << @intCast(op_index) == 0) continue;
188919 if (tomb_bits & (@as(Air.Liveness.Bpi, 1) << @intCast(op_index)) == 0) continue;
188920188920 if (cg.reused_operands.isSet(op_index)) continue;
188921188921 try cg.processDeath(op_ref.toIndexAllowNone() orelse continue, .{});
188922188922 }
......@@ -190117,9 +190117,9 @@ const Select = struct {
190117190117 (@as(u64, std.math.maxInt(u64)) >> @intCast(res_scalar_info.bits - scalar_info.bits))),
190118190118 .@"0x1p63_mem" => switch (res_scalar_info.bits) {
190119190119 else => unreachable,
190120 16 => @as(i64, @as(i16, @bitCast(@as(f16, 0x1p63)))) << 64 - 16,
190121 32 => @as(i64, @as(i32, @bitCast(@as(f32, 0x1p63)))) << 64 - 32,
190122 64 => @as(i64, @as(i64, @bitCast(@as(f64, 0x1p63)))) << 64 - 64,
190120 16 => @as(i64, @as(i16, @bitCast(@as(f16, 0x1p63)))) << (64 - 16),
190121 32 => @as(i64, @as(i32, @bitCast(@as(f32, 0x1p63)))) << (64 - 32),
190122 64 => @as(i64, @as(i64, @bitCast(@as(f64, 0x1p63)))) << (64 - 64),
190123190123 },
190124190124 };
190125190125 const shift: u6 = @intCast(64 - res_scalar_info.bits);
......@@ -191518,8 +191518,8 @@ const Select = struct {
191518191518 @as(SignedImm, @intCast(s.cg.nonBoolScalarBitSize(op.flags.base.ref.typeOf(s)))),
191519191519 .log2_src0_elem_size => @intCast(std.math.log2(Select.Operand.Ref.src0.typeOf(s).indexableElem(s.cg.pt.zcu).abiSize(s.cg.pt.zcu))),
191520191520 .elem_mask => @as(u8, std.math.maxInt(u8)) >> @intCast(
191521 8 - ((s.cg.unalignedSize(op.flags.base.ref.typeOf(s)) - 1) %
191522 @divExact(op.flags.base.size.bitSize(s.cg.target), 8) + 1 >>
191521 8 - (((s.cg.unalignedSize(op.flags.base.ref.typeOf(s)) - 1) %
191522 @divExact(op.flags.base.size.bitSize(s.cg.target), 8) + 1) >>
191523191523 op.flags.index.scale.toLog2()),
191524191524 ),
191525191525 inline .smin, .smax, .umax, .smin_shr_src1, .smax_shr_src1, .umax_shr_src1 => |adjust| switch (op.flags.base.size) {
......@@ -191548,7 +191548,7 @@ const Select = struct {
191548191548 },
191549191549 .repeat => switch (SignedImm) {
191550191550 else => unreachable,
191551 i64 => return @as(i64, op.imm) << 32 | @as(u32, @bitCast(op.imm)),
191551 i64 => return (@as(i64, op.imm) << 32) | @as(u32, @bitCast(op.imm)),
191552191552 },
191553191553 };
191554191554 const rhs = op.flags.adjust.rhs.toLog2();
......@@ -191559,10 +191559,10 @@ const Select = struct {
191559191559 break :op_res op_res[0];
191560191560 },
191561191561 .div => @shrExact(lhs, rhs),
191562 .div_8_down => lhs >> 3 & @as(SignedImm, -1) << rhs,
191562 .div_8_down => (lhs >> 3) & (@as(SignedImm, -1) << rhs),
191563191563 .rem_8_mul => lhs & ((@as(SignedImm, 8) << rhs) - 1),
191564 .up_2_mul => ((lhs - 1) & @as(SignedImm, -2) << rhs) + (@as(SignedImm, 2) << rhs),
191565 .up_32_mul => ((lhs - 1) & @as(SignedImm, -32) << rhs) + (@as(SignedImm, 32) << rhs),
191564 .up_2_mul => ((lhs - 1) & (@as(SignedImm, -2) << rhs)) + (@as(SignedImm, 2) << rhs),
191565 .up_32_mul => ((lhs - 1) & (@as(SignedImm, -32) << rhs)) + (@as(SignedImm, 32) << rhs),
191566191566 };
191567191567 const disp: SignedImm = @bitCast(@as(UnsignedImm, @as(u32, @bitCast(op.imm))));
191568191568 return switch (op.flags.adjust.sign) {
src/codegen/x86_64/Disassembler.zig+1-1
......@@ -378,7 +378,7 @@ fn parseEncoding(dis: *Disassembler, prefixes: Prefixes) !?Encoding {
378378}
379379
380380fn parseGpRegister(low_enc: u3, is_extended: bool, rex: Rex, bit_size: u64) Register {
381 const reg_id: u4 = @as(u4, @intCast(@intFromBool(is_extended))) << 3 | low_enc;
381 const reg_id: u4 = (@as(u4, @intCast(@intFromBool(is_extended))) << 3) | low_enc;
382382 const reg = @as(Register, @fromBackingInt(@intCast(reg_id))).toBitSize(bit_size);
383383 return switch (reg) {
384384 .spl => if (rex.present or rex.isSet()) .spl else .ah,
src/codegen/x86_64/Emit.zig+6-6
......@@ -694,13 +694,13 @@ pub fn emitMir(emit: *Emit) Error!void {
694694
695695 for (emit.table_relocs.items) |table_reloc| try atom.addReloc(gpa, .{
696696 .r_offset = table_reloc.source_offset,
697 .r_info = @as(u64, @backingInt(emit.atom_id)) << 32 | @backingInt(std.elf.R_X86_64.@"32S"),
697 .r_info = (@as(u64, @backingInt(emit.atom_id)) << 32) | @backingInt(std.elf.R_X86_64.@"32S"),
698698 .r_addend = @as(i64, table_offset) + table_reloc.target_offset,
699699 }, zo);
700700 for (emit.lower.mir.table) |entry| {
701701 try atom.addReloc(gpa, .{
702702 .r_offset = table_offset,
703 .r_info = @as(u64, @backingInt(emit.atom_id)) << 32 | @backingInt(std.elf.R_X86_64.@"64"),
703 .r_info = (@as(u64, @backingInt(emit.atom_id)) << 32) | @backingInt(std.elf.R_X86_64.@"64"),
704704 .r_addend = emit.code_offset_mapping.items[entry],
705705 }, zo);
706706 table_offset += ptr_size;
......@@ -812,7 +812,7 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI
812812 .PC32;
813813 try atom.addReloc(gpa, .{
814814 .r_offset = end_offset - 4,
815 .r_info = @as(u64, @backingInt(target.symbol)) << 32 | @backingInt(r_type),
815 .r_info = (@as(u64, @backingInt(target.symbol)) << 32) | @backingInt(r_type),
816816 .r_addend = if (emit.pic) reloc.off - 4 else reloc.off,
817817 }, zo);
818818 } else if (emit.bin_file.cast(.macho)) |macho_file| {
......@@ -854,7 +854,7 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI
854854 const r_type: std.elf.R_X86_64 = .PLT32;
855855 try atom.addReloc(gpa, .{
856856 .r_offset = end_offset - 4,
857 .r_info = @as(u64, @backingInt(target.symbol)) << 32 | @backingInt(r_type),
857 .r_info = (@as(u64, @backingInt(target.symbol)) << 32) | @backingInt(r_type),
858858 .r_addend = reloc.off - 4,
859859 }, zo);
860860 } else if (emit.bin_file.cast(.elf2)) |elf| try elf.addReloc(
......@@ -894,7 +894,7 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI
894894 const r_type: std.elf.R_X86_64 = if (emit.pic) .TLSLD else unreachable;
895895 try atom.addReloc(gpa, .{
896896 .r_offset = end_offset - 4,
897 .r_info = @as(u64, @backingInt(target_symbol)) << 32 | @backingInt(r_type),
897 .r_info = (@as(u64, @backingInt(target_symbol)) << 32) | @backingInt(r_type),
898898 .r_addend = reloc.off - 4,
899899 }, zo);
900900 } else if (emit.bin_file.cast(.elf2)) |elf| try elf.addReloc(
......@@ -912,7 +912,7 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI
912912 const r_type: std.elf.R_X86_64 = if (emit.pic) .DTPOFF32 else .TPOFF32;
913913 try atom.addReloc(gpa, .{
914914 .r_offset = end_offset - 4,
915 .r_info = @as(u64, @backingInt(target.symbol)) << 32 | @backingInt(r_type),
915 .r_info = (@as(u64, @backingInt(target.symbol)) << 32) | @backingInt(r_type),
916916 .r_addend = reloc.off,
917917 }, zo);
918918 } else if (emit.bin_file.cast(.elf2)) |elf| try elf.addReloc(
src/codegen/x86_64/Mir.zig+1-1
......@@ -1949,7 +1949,7 @@ pub const Memory = struct {
19491949 assert(mem.info.base == .reg);
19501950 return encoder.Instruction.Memory.initMoffs(
19511951 @fromBackingInt(@intCast(mem.base)),
1952 @as(u64, mem.extra) << 32 | mem.off,
1952 (@as(u64, mem.extra) << 32) | mem.off,
19531953 );
19541954 },
19551955 }
src/codegen/x86_64/bits.zig+1-1
......@@ -664,7 +664,7 @@ pub const Register = enum(u8) {
664664 .general_purpose, .gphi => if (reg.isExtended())
665665 reg.enc()
666666 else
667 @as(u3, @truncate(@as(u24, 0o54673120) >> @as(u5, reg.enc()) * 3)),
667 @as(u3, @truncate(@as(u24, 0o54673120) >> (@as(u5, reg.enc()) * 3))),
668668 .sse => 17 + @as(u6, reg.enc()),
669669 .x87 => 33 + @as(u6, reg.enc()),
670670 .mmx => 41 + @as(u6, reg.enc()),
src/codegen/x86_64/encoder.zig+14-14
......@@ -844,25 +844,25 @@ fn Encoder(comptime opts: Options) type {
844844 try self.w.writeByte(0b1100_0100);
845845
846846 try self.w.writeByte(
847 @as(u8, ~@intFromBool(fields.r)) << 7 |
848 @as(u8, ~@intFromBool(fields.x)) << 6 |
849 @as(u8, ~@intFromBool(fields.b)) << 5 |
850 @as(u8, @backingInt(fields.m)) << 0,
847 (@as(u8, ~@intFromBool(fields.r)) << 7) |
848 (@as(u8, ~@intFromBool(fields.x)) << 6) |
849 (@as(u8, ~@intFromBool(fields.b)) << 5) |
850 (@as(u8, @backingInt(fields.m)) << 0),
851851 );
852852
853853 try self.w.writeByte(
854 @as(u8, @intFromBool(fields.w)) << 7 |
855 @as(u8, ~@as(u4, @intCast(fields.v.enc()))) << 3 |
856 @as(u8, @intFromBool(fields.l)) << 2 |
857 @as(u8, @backingInt(fields.p)) << 0,
854 (@as(u8, @intFromBool(fields.w)) << 7) |
855 (@as(u8, ~@as(u4, @intCast(fields.v.enc()))) << 3) |
856 (@as(u8, @intFromBool(fields.l)) << 2) |
857 (@as(u8, @backingInt(fields.p)) << 0),
858858 );
859859 } else {
860860 try self.w.writeByte(0b1100_0101);
861861 try self.w.writeByte(
862 @as(u8, ~@intFromBool(fields.r)) << 7 |
863 @as(u8, ~@as(u4, @intCast(fields.v.enc()))) << 3 |
864 @as(u8, @intFromBool(fields.l)) << 2 |
865 @as(u8, @backingInt(fields.p)) << 0,
862 (@as(u8, ~@intFromBool(fields.r)) << 7) |
863 (@as(u8, ~@as(u4, @intCast(fields.v.enc()))) << 3) |
864 (@as(u8, @intFromBool(fields.l)) << 2) |
865 (@as(u8, @backingInt(fields.p)) << 0),
866866 );
867867 }
868868 }
......@@ -910,7 +910,7 @@ fn Encoder(comptime opts: Options) type {
910910 ///
911911 /// Remember to add a REX prefix byte if reg or rm are extended!
912912 pub fn modRm(self: Self, mod: u2, reg_or_opx: u3, rm: u3) !void {
913 try self.w.writeByte(@as(u8, mod) << 6 | @as(u8, reg_or_opx) << 3 | rm);
913 try self.w.writeByte((@as(u8, mod) << 6) | (@as(u8, reg_or_opx) << 3) | rm);
914914 }
915915
916916 /// Construct a ModR/M byte using direct r/m addressing
......@@ -996,7 +996,7 @@ fn Encoder(comptime opts: Options) type {
996996 ///
997997 /// Remember to add a REX prefix byte if index or base are extended!
998998 pub fn sib(self: Self, scale: u2, index: u3, base: u3) !void {
999 try self.w.writeByte(@as(u8, scale) << 6 | @as(u8, index) << 3 | base);
999 try self.w.writeByte((@as(u8, scale) << 6) | (@as(u8, index) << 3) | base);
10001000 }
10011001
10021002 /// Construct a SIB byte with scale * index + base, no frills.
src/fmt.zig+2-1
......@@ -323,7 +323,8 @@ fn fmtPathDir(
323323
324324 if (mem.startsWith(u8, entry.name, ".")) continue;
325325
326 if (is_dir or entry.kind == .file and (mem.endsWith(u8, entry.name, ".zig") or mem.endsWith(u8, entry.name, ".zon"))) {
326 const is_zig_or_zon = entry.kind == .file and (mem.endsWith(u8, entry.name, ".zig") or mem.endsWith(u8, entry.name, ".zon"));
327 if (is_dir or is_zig_or_zon) {
327328 const full_path = try fs.path.join(fmt.gpa, &[_][]const u8{ file_path, entry.name });
328329 defer fmt.gpa.free(full_path);
329330
src/link/Dwarf.zig+3-3
......@@ -697,7 +697,7 @@ const Unit = struct {
697697 fw.writeByte(DW.LNS.extended_op) catch unreachable;
698698 const extended_op_bytes = fw.end;
699699 var op_len_bytes: u5 = 1;
700 while (true) switch (std.math.order(len - extended_op_bytes - op_len_bytes, @as(u32, 1) << 7 * op_len_bytes)) {
700 while (true) switch (std.math.order(len - extended_op_bytes - op_len_bytes, @as(u32, 1) << (7 * op_len_bytes))) {
701701 .lt => break fw.writeUleb128(len - extended_op_bytes - op_len_bytes) catch unreachable,
702702 .eq => {
703703 // no length will ever work, so undercount and futz with the leb encoding to make up the missing byte
......@@ -893,7 +893,7 @@ const Entry = struct {
893893 fw.writeUleb128(try dwarf.refAbbrevCode(.pad_n)) catch unreachable;
894894 const abbrev_code_bytes = fw.end;
895895 var block_len_bytes: u5 = 1;
896 while (true) switch (std.math.order(len - abbrev_code_bytes - block_len_bytes, @as(u32, 1) << 7 * block_len_bytes)) {
896 while (true) switch (std.math.order(len - abbrev_code_bytes - block_len_bytes, @as(u32, 1) << (7 * block_len_bytes))) {
897897 .lt => break fw.writeUleb128(len - abbrev_code_bytes - block_len_bytes) catch unreachable,
898898 .eq => {
899899 // no length will ever work, so undercount and futz with the leb encoding to make up the missing byte
......@@ -915,7 +915,7 @@ const Entry = struct {
915915 fw.writeByte(DW.LNS.extended_op) catch unreachable;
916916 const extended_op_bytes = fw.end;
917917 var op_len_bytes: u5 = 1;
918 while (true) switch (std.math.order(len - extended_op_bytes - op_len_bytes, @as(u32, 1) << 7 * op_len_bytes)) {
918 while (true) switch (std.math.order(len - extended_op_bytes - op_len_bytes, @as(u32, 1) << (7 * op_len_bytes))) {
919919 .lt => break fw.writeUleb128(len - extended_op_bytes - op_len_bytes) catch unreachable,
920920 .eq => {
921921 // no length will ever work, so undercount and futz with the leb encoding to make up the missing byte
src/link/Dwarf2.zig+2-2
......@@ -1891,7 +1891,7 @@ pub fn genDebugInfoPadding(dwarf: *Dwarf, di_w: *std.Io.Writer, size: u64) std.I
18911891 var block_len_size: u5 = 1;
18921892 while (true) switch (std.math.order(
18931893 size - abbrev_code_size - block_len_size,
1894 @as(u64, 1) << 7 * block_len_size,
1894 @as(u64, 1) << (7 * block_len_size),
18951895 )) {
18961896 .lt => break try di_w.writeUleb128(size - abbrev_code_size - block_len_size),
18971897 .eq => {
......@@ -2023,7 +2023,7 @@ pub fn genDebugLinePadding(dl_w: *std.Io.Writer, size: u64) std.Io.Writer.Error!
20232023 var op_len_size: u5 = 1;
20242024 while (true) switch (std.math.order(
20252025 size - extended_op_size - op_len_size,
2026 @as(u64, 1) << 7 * op_len_size,
2026 @as(u64, 1) << (7 * op_len_size),
20272027 )) {
20282028 .lt => break try dl_w.writeUleb128(size - extended_op_size - op_len_size),
20292029 .eq => {
src/link/Elf2.zig+4-4
......@@ -7694,11 +7694,11 @@ fn loadArchive(elf: *Elf, path: std.Build.Cache.Path, fr: *Io.File.Reader) (Load
76947694 {
76957695 break :load_object;
76967696 }
7697 const member = header.name() orelse member: {
7698 const strtab_offset = header.nameOffset() catch |err| switch (err) {
7697 const member = header.name() orelse (member: {
7698 const strtab_offset = (header.nameOffset() catch |err| switch (err) {
76997699 error.Overflow => break :member error.Overflow,
77007700 error.InvalidCharacter => break :load_object,
7701 } orelse break :load_object;
7701 }) orelse break :load_object;
77027702 const strtab_written = strtab.written();
77037703 if (strtab_offset > strtab_written.len) break :member error.Overflow;
77047704 const member = std.mem.sliceTo(strtab_written[strtab_offset..], '\n');
......@@ -7708,7 +7708,7 @@ fn loadArchive(elf: *Elf, path: std.Build.Cache.Path, fr: *Io.File.Reader) (Load
77087708 member;
77097709 } catch |err| switch (err) {
77107710 error.Overflow => return diags.failParse(path, "bad member name offset", .{}),
7711 };
7711 });
77127712 try elf.loadObject(path, member, fr, .{ .offset = offset, .size = size });
77137713 }
77147714 try fr.seekTo(std.mem.alignForward(u64, offset + size, 2));
src/link/MachO/UnwindInfo.zig+1-1
......@@ -228,7 +228,7 @@ pub fn generate(info: *UnwindInfo, macho_file: *MachO) !void {
228228 if (next.getAtomAddress(macho_file) >= range_start_max) {
229229 break;
230230 } else if (info.getCommonEncoding(next.enc) != null or
231 page.getPageEncoding(next.enc) != null and !is_dwarf)
231 (page.getPageEncoding(next.enc) != null and !is_dwarf))
232232 {
233233 i += 1;
234234 space_left -= 1;
src/link/MachO/load_commands.zig+2-2
......@@ -266,8 +266,8 @@ pub fn writeDylibIdLC(macho_file: *MachO, writer: *Writer) !void {
266266 try writeDylibLC(.{
267267 .cmd = .ID_DYLIB,
268268 .name = install_name,
269 .current_version = @as(u32, @intCast(curr.major << 16 | curr.minor << 8 | curr.patch)),
270 .compatibility_version = @as(u32, @intCast(compat.major << 16 | compat.minor << 8 | compat.patch)),
269 .current_version = @as(u32, @intCast((curr.major << 16) | (curr.minor << 8) | curr.patch)),
270 .compatibility_version = @as(u32, @intCast((compat.major << 16) | (compat.minor << 8) | compat.patch)),
271271 }, writer);
272272}
273273
src/link/Wasm/Flush.zig+1-1
......@@ -1128,7 +1128,7 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void {
11281128 // indirect function table elements
11291129 const table_index: u32 = @intCast(
11301130 wasm.table_imports.getIndex(wasm.preloaded_strings.__indirect_function_table) orelse
1131 wasm.table_imports.entries.len + wasm.tables.getIndex(.__indirect_function_table).?,
1131 (wasm.table_imports.entries.len + wasm.tables.getIndex(.__indirect_function_table).?),
11321132 );
11331133 // passive with implicit 0-index table or set table index manually
11341134 const flags: u32 = if (table_index == 0) 0x0 else 0x02;
src/link/riscv.zig+2-2
......@@ -90,8 +90,8 @@ fn bitSlice(
9090 value: anytype,
9191 comptime high: comptime_int,
9292 comptime low: comptime_int,
93) std.math.IntFittingRange(0, 1 << high - low) {
94 return @truncate((value >> low) & (1 << (high - low + 1)) - 1);
93) std.math.IntFittingRange(0, 1 << (high - low)) {
94 return @truncate((value >> low) & ((1 << (high - low + 1)) - 1));
9595}
9696
9797pub const Eflags = packed struct(u32) {
src/main.zig+1-1
......@@ -3524,7 +3524,7 @@ fn buildOutputType(
35243524 };
35253525
35263526 const thread_limit = @min(
3527 @max(n_jobs orelse std.Thread.getCpuCount() catch 1, 1),
3527 @max(n_jobs orelse (std.Thread.getCpuCount() catch 1), 1),
35283528 std.math.maxInt(Zcu.PerThread.IdBacking),
35293529 );
35303530 try setThreadLimit(arena, thread_limit);
test/Runner.zig+4-4
......@@ -811,7 +811,7 @@ pub const DelimitedReader = struct {
811811 const d: *DelimitedReader = @fieldParentPtr("interface", r);
812812 const block = try d.unlimited.peekGreedy(d.delimiter.len);
813813 d.remaining = .limited(std.mem.findPos(u8, block, d.remaining.toInt().?, d.delimiter) orelse
814 block.len - d.delimiter.len + 1);
814 (block.len - d.delimiter.len + 1));
815815 if (d.remaining == .nothing) return error.EndOfStream;
816816 const n = try d.unlimited.stream(w, limit.min(d.remaining));
817817 d.remaining = d.remaining.subtract(n).?;
......@@ -821,7 +821,7 @@ pub const DelimitedReader = struct {
821821 const d: *DelimitedReader = @fieldParentPtr("interface", r);
822822 const block = try d.unlimited.peekGreedy(d.delimiter.len);
823823 d.remaining = .limited(std.mem.findPos(u8, block, d.remaining.toInt().?, d.delimiter) orelse
824 block.len - d.delimiter.len + 1);
824 (block.len - d.delimiter.len + 1));
825825 if (d.remaining == .nothing) return error.EndOfStream;
826826 const n = try d.unlimited.discard(limit.min(d.remaining));
827827 d.remaining = d.remaining.subtract(n).?;
......@@ -1397,9 +1397,9 @@ fn handleCommand(
13971397 return update.fail("compiler failed to send terminating error_bundle", .{});
13981398 },
13991399 }
1400 assert(contents_r.discardRemaining() catch |err| switch (err) {
1400 assert((contents_r.discardRemaining() catch |err| switch (err) {
14011401 error.ReadFailed => return error.ContentsReadFailed,
1402 } == 0);
1402 }) == 0);
14031403 switch (cmd) {
14041404 .todo, .skip => {},
14051405 else => update.allow_skip = false,
test/behavior/bitcast.zig+1-1
......@@ -470,7 +470,7 @@ test "@bitCast of packed struct with void field and multiple integers" {
470470 fn doTheTest(x: u8, y: u8) !void {
471471 const foo = @as(@This(), .{ .x = x, .v = {}, .y = y });
472472 const as_int: u16 = @bitCast(foo);
473 try expect(as_int == @as(u16, y) << 8 | x);
473 try expect(as_int == (@as(u16, y) << 8) | x);
474474 }
475475 };
476476 try S.doTheTest(123, 45);
test/behavior/error.zig+1-1
......@@ -209,7 +209,7 @@ fn testErrorSetType() !void {
209209
210210 const a: MyErrSet!i32 = 5678;
211211 const b: MyErrSet!i32 = MyErrSet.OutOfMemory;
212 try expect(b catch error.OutOfMemory == error.OutOfMemory);
212 try expect((b catch error.OutOfMemory) == error.OutOfMemory);
213213
214214 if (a) |value| try expect(value == 5678) else |err| switch (err) {
215215 error.OutOfMemory => unreachable,
test/behavior/math.zig+3-3
......@@ -49,10 +49,10 @@ fn testThreeExprInARow(f: bool, t: bool) !void {
4949 try assertFalse(1 | 2 | 4 != 7);
5050 try assertFalse(3 ^ 6 ^ 8 != 13);
5151 try assertFalse(7 & 14 & 28 != 4);
52 try assertFalse(9 << 1 << 2 != 9 << 3);
53 try assertFalse(90 >> 1 >> 2 != 90 >> 3);
52 try assertFalse((9 << 1) << 2 != 9 << 3);
53 try assertFalse((90 >> 1) >> 2 != 90 >> 3);
5454 try assertFalse(100 - 1 + 1000 != 1099);
55 try assertFalse(5 * 4 / 2 % 3 != 1);
55 try assertFalse((5 * 4 / 2) % 3 != 1);
5656 try assertFalse(@as(i32, @as(i32, 5)) != 5);
5757 try assertFalse(!!false);
5858 try assertFalse(@as(i32, 7) != --(@as(i32, 7)));
test/behavior/try.zig+3-3
......@@ -186,9 +186,9 @@ test "try ptr propagation mutate" {
186186 res1.* += 1;
187187 res2.* += 1;
188188
189 try expect(f0 catch unreachable == 1);
190 try expect(f1 catch unreachable == 2);
191 try expect(f2 catch unreachable == 3);
189 try expect((f0 catch unreachable) == 1);
190 try expect((f1 catch unreachable) == 2);
191 try expect((f2 catch unreachable) == 3);
192192
193193 try expect(res0.* == 1);
194194 try expect(res1.* == 2);
test/behavior/x86_64/binary.zig+2-2
......@@ -5503,7 +5503,7 @@ inline fn shrExact(comptime Type: type, lhs: Type, rhs: Type) Type {
55035503 const bit_cast_rhs: AsSignedness(Type, .unsigned) = @bitCast(rhs);
55045504 const truncate_rhs: Log2Int(Type) = @truncate(bit_cast_rhs);
55055505 const final_rhs = if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % @as(Log2Int(Type), @splat(bits)) else truncate_rhs;
5506 return @shrExact(lhs >> final_rhs << final_rhs, final_rhs);
5506 return @shrExact((lhs >> final_rhs) << final_rhs, final_rhs);
55075507}
55085508test shrExact {
55095509 const test_shr_exact = binary(shrExact, .{});
......@@ -5527,7 +5527,7 @@ inline fn shlExactUnsafe(comptime Type: type, lhs: Type, rhs: Type) Type {
55275527 const bit_cast_rhs: AsSignedness(Type, .unsigned) = @bitCast(rhs);
55285528 const truncate_rhs: Log2Int(Type) = @truncate(bit_cast_rhs);
55295529 const final_rhs = if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % @as(Log2Int(Type), @splat(bits)) else truncate_rhs;
5530 return @shlExact(lhs << final_rhs >> final_rhs, final_rhs);
5530 return @shlExact((lhs << final_rhs) >> final_rhs, final_rhs);
55315531}
55325532test shlExactUnsafe {
55335533 const test_shl_exact_unsafe = binary(shlExactUnsafe, .{});
test/behavior/x86_64/cast.zig+4-4
......@@ -14502,15 +14502,15 @@ inline fn intCast(comptime Result: type, comptime Type: type, rhs: Type, comptim
1450214502 // TODO: if (bits == 0) rhs else rhs >> bits,
1450314503 .shift => |bits| if (bits == 0) rhs else switch (@typeInfo(Type)) {
1450414504 .int => if (ct_rhs < 0)
14505 rhs | imin(Type) >> bits
14505 rhs | (imin(Type) >> bits)
1450614506 else
14507 rhs & imax(Type) >> bits,
14508 .vector => rhs | @select(
14507 rhs & (imax(Type) >> bits),
14508 .vector => (rhs | @select(
1450914509 Scalar(Type),
1451014510 ct_rhs < @as(Type, @splat(0)),
1451114511 @as(Type, @splat(imin(Scalar(Type)) >> bits)),
1451214512 @as(Type, @splat(0)),
14513 ) & ~@select(
14513 )) & ~@select(
1451414514 Scalar(Type),
1451514515 ct_rhs >= @as(Type, @splat(0)),
1451614516 @as(Type, @splat(imin(Scalar(Type)) >> bits)),
tools/loongarch/OpcodeDesc.zig+2-2
......@@ -95,10 +95,10 @@ pub const Format = struct {
9595 const index: Slot.Index = try .parse(&reader);
9696 const length = try takeInteger(u5, &reader);
9797 const post_proc = post_proc: {
98 if ('p' == reader.peekByte() catch |err| switch (err) {
98 if ('p' == (reader.peekByte() catch |err| switch (err) {
9999 error.EndOfStream => ' ',
100100 else => return err,
101 }) {
101 })) {
102102 reader.toss(1);
103103 break :post_proc try Slot.PostProcess.parse(&reader);
104104 } else break :post_proc Slot.PostProcess.none;