| ... | @@ -4,6 +4,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -4,6 +4,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 4 | { | 4 | { |
| 5 | const check_panic_msg = | 5 | const check_panic_msg = |
| 6 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 6 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 7 | \\ _ = stack_trace; |
| 7 | \\ if (std.mem.eql(u8, message, "reached unreachable code")) { | 8 | \\ if (std.mem.eql(u8, message, "reached unreachable code")) { |
| 8 | \\ std.process.exit(126); // good | 9 | \\ std.process.exit(126); // good |
| 9 | \\ } | 10 | \\ } |
| ... | @@ -45,6 +46,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -45,6 +46,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 45 | { | 46 | { |
| 46 | const check_panic_msg = | 47 | const check_panic_msg = |
| 47 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 48 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 49 | \\ _ = stack_trace; |
| 48 | \\ if (std.mem.eql(u8, message, "invalid enum value")) { | 50 | \\ if (std.mem.eql(u8, message, "invalid enum value")) { |
| 49 | \\ std.process.exit(126); // good | 51 | \\ std.process.exit(126); // good |
| 50 | \\ } | 52 | \\ } |
| ... | @@ -62,6 +64,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -62,6 +64,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 62 | \\ var e: E = undefined; | 64 | \\ var e: E = undefined; |
| 63 | \\ @memset(@ptrCast([*]u8, &e), 0x55, @sizeOf(E)); | 65 | \\ @memset(@ptrCast([*]u8, &e), 0x55, @sizeOf(E)); |
| 64 | \\ var n = @tagName(e); | 66 | \\ var n = @tagName(e); |
| | 67 | \\ _ = n; |
| 65 | \\} | 68 | \\} |
| 66 | ); | 69 | ); |
| 67 | | 70 | |
| ... | @@ -76,6 +79,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -76,6 +79,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 76 | \\ @memset(@ptrCast([*]u8, &u), 0x55, @sizeOf(U)); | 79 | \\ @memset(@ptrCast([*]u8, &u), 0x55, @sizeOf(U)); |
| 77 | \\ var t: @typeInfo(U).Union.tag_type.? = u; | 80 | \\ var t: @typeInfo(U).Union.tag_type.? = u; |
| 78 | \\ var n = @tagName(t); | 81 | \\ var n = @tagName(t); |
| | 82 | \\ _ = n; |
| 79 | \\} | 83 | \\} |
| 80 | ); | 84 | ); |
| 81 | } | 85 | } |
| ... | @@ -83,6 +87,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -83,6 +87,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 83 | { | 87 | { |
| 84 | const check_panic_msg = | 88 | const check_panic_msg = |
| 85 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 89 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 90 | \\ _ = stack_trace; |
| 86 | \\ if (std.mem.eql(u8, message, "index out of bounds")) { | 91 | \\ if (std.mem.eql(u8, message, "index out of bounds")) { |
| 87 | \\ std.process.exit(126); // good | 92 | \\ std.process.exit(126); // good |
| 88 | \\ } | 93 | \\ } |
| ... | @@ -96,6 +101,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -96,6 +101,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 96 | \\pub fn main() void { | 101 | \\pub fn main() void { |
| 97 | \\ var buf = [4]u8{'a','b','c',0}; | 102 | \\ var buf = [4]u8{'a','b','c',0}; |
| 98 | \\ const slice = buf[0..4 :0]; | 103 | \\ const slice = buf[0..4 :0]; |
| | 104 | \\ _ = slice; |
| 99 | \\} | 105 | \\} |
| 100 | ); | 106 | ); |
| 101 | cases.addRuntimeSafety("slicing operator with sentinel", | 107 | cases.addRuntimeSafety("slicing operator with sentinel", |
| ... | @@ -104,6 +110,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -104,6 +110,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 104 | \\pub fn main() void { | 110 | \\pub fn main() void { |
| 105 | \\ var buf = [4]u8{'a','b','c',0}; | 111 | \\ var buf = [4]u8{'a','b','c',0}; |
| 106 | \\ const slice = buf[0..:0]; | 112 | \\ const slice = buf[0..:0]; |
| | 113 | \\ _ = slice; |
| 107 | \\} | 114 | \\} |
| 108 | ); | 115 | ); |
| 109 | cases.addRuntimeSafety("slicing operator with sentinel", | 116 | cases.addRuntimeSafety("slicing operator with sentinel", |
| ... | @@ -112,6 +119,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -112,6 +119,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 112 | \\pub fn main() void { | 119 | \\pub fn main() void { |
| 113 | \\ var buf_zero = [0]u8{}; | 120 | \\ var buf_zero = [0]u8{}; |
| 114 | \\ const slice = buf_zero[0..0 :0]; | 121 | \\ const slice = buf_zero[0..0 :0]; |
| | 122 | \\ _ = slice; |
| 115 | \\} | 123 | \\} |
| 116 | ); | 124 | ); |
| 117 | cases.addRuntimeSafety("slicing operator with sentinel", | 125 | cases.addRuntimeSafety("slicing operator with sentinel", |
| ... | @@ -120,6 +128,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -120,6 +128,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 120 | \\pub fn main() void { | 128 | \\pub fn main() void { |
| 121 | \\ var buf_zero = [0]u8{}; | 129 | \\ var buf_zero = [0]u8{}; |
| 122 | \\ const slice = buf_zero[0..:0]; | 130 | \\ const slice = buf_zero[0..:0]; |
| | 131 | \\ _ = slice; |
| 123 | \\} | 132 | \\} |
| 124 | ); | 133 | ); |
| 125 | cases.addRuntimeSafety("slicing operator with sentinel", | 134 | cases.addRuntimeSafety("slicing operator with sentinel", |
| ... | @@ -129,6 +138,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -129,6 +138,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 129 | \\ var buf_sentinel = [2:0]u8{'a','b'}; | 138 | \\ var buf_sentinel = [2:0]u8{'a','b'}; |
| 130 | \\ @ptrCast(*[3]u8, &buf_sentinel)[2] = 0; | 139 | \\ @ptrCast(*[3]u8, &buf_sentinel)[2] = 0; |
| 131 | \\ const slice = buf_sentinel[0..3 :0]; | 140 | \\ const slice = buf_sentinel[0..3 :0]; |
| | 141 | \\ _ = slice; |
| 132 | \\} | 142 | \\} |
| 133 | ); | 143 | ); |
| 134 | cases.addRuntimeSafety("slicing operator with sentinel", | 144 | cases.addRuntimeSafety("slicing operator with sentinel", |
| ... | @@ -137,6 +147,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -137,6 +147,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 137 | \\pub fn main() void { | 147 | \\pub fn main() void { |
| 138 | \\ var buf_slice: []const u8 = &[3]u8{ 'a', 'b', 0 }; | 148 | \\ var buf_slice: []const u8 = &[3]u8{ 'a', 'b', 0 }; |
| 139 | \\ const slice = buf_slice[0..3 :0]; | 149 | \\ const slice = buf_slice[0..3 :0]; |
| | 150 | \\ _ = slice; |
| 140 | \\} | 151 | \\} |
| 141 | ); | 152 | ); |
| 142 | cases.addRuntimeSafety("slicing operator with sentinel", | 153 | cases.addRuntimeSafety("slicing operator with sentinel", |
| ... | @@ -145,6 +156,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -145,6 +156,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 145 | \\pub fn main() void { | 156 | \\pub fn main() void { |
| 146 | \\ var buf_slice: []const u8 = &[3]u8{ 'a', 'b', 0 }; | 157 | \\ var buf_slice: []const u8 = &[3]u8{ 'a', 'b', 0 }; |
| 147 | \\ const slice = buf_slice[0.. :0]; | 158 | \\ const slice = buf_slice[0.. :0]; |
| | 159 | \\ _ = slice; |
| 148 | \\} | 160 | \\} |
| 149 | ); | 161 | ); |
| 150 | } | 162 | } |
| ... | @@ -153,6 +165,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -153,6 +165,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 153 | \\const std = @import("std"); | 165 | \\const std = @import("std"); |
| 154 | \\const V = @import("std").meta.Vector; | 166 | \\const V = @import("std").meta.Vector; |
| 155 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 167 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 168 | \\ _ = stack_trace; |
| 156 | \\ if (std.mem.eql(u8, message, "integer cast truncated bits")) { | 169 | \\ if (std.mem.eql(u8, message, "integer cast truncated bits")) { |
| 157 | \\ std.process.exit(126); // good | 170 | \\ std.process.exit(126); // good |
| 158 | \\ } | 171 | \\ } |
| ... | @@ -161,6 +174,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -161,6 +174,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 161 | \\pub fn main() void { | 174 | \\pub fn main() void { |
| 162 | \\ var x = @splat(4, @as(u32, 0xdeadbeef)); | 175 | \\ var x = @splat(4, @as(u32, 0xdeadbeef)); |
| 163 | \\ var y = @intCast(V(4, u16), x); | 176 | \\ var y = @intCast(V(4, u16), x); |
| | 177 | \\ _ = y; |
| 164 | \\} | 178 | \\} |
| 165 | ); | 179 | ); |
| 166 | | 180 | |
| ... | @@ -168,6 +182,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -168,6 +182,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 168 | \\const std = @import("std"); | 182 | \\const std = @import("std"); |
| 169 | \\const V = @import("std").meta.Vector; | 183 | \\const V = @import("std").meta.Vector; |
| 170 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 184 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 185 | \\ _ = stack_trace; |
| 171 | \\ if (std.mem.eql(u8, message, "integer cast truncated bits")) { | 186 | \\ if (std.mem.eql(u8, message, "integer cast truncated bits")) { |
| 172 | \\ std.process.exit(126); // good | 187 | \\ std.process.exit(126); // good |
| 173 | \\ } | 188 | \\ } |
| ... | @@ -176,6 +191,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -176,6 +191,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 176 | \\pub fn main() void { | 191 | \\pub fn main() void { |
| 177 | \\ var x = @splat(4, @as(u32, 0x80000000)); | 192 | \\ var x = @splat(4, @as(u32, 0x80000000)); |
| 178 | \\ var y = @intCast(V(4, i32), x); | 193 | \\ var y = @intCast(V(4, i32), x); |
| | 194 | \\ _ = y; |
| 179 | \\} | 195 | \\} |
| 180 | ); | 196 | ); |
| 181 | | 197 | |
| ... | @@ -183,6 +199,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -183,6 +199,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 183 | \\const std = @import("std"); | 199 | \\const std = @import("std"); |
| 184 | \\const V = @import("std").meta.Vector; | 200 | \\const V = @import("std").meta.Vector; |
| 185 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 201 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 202 | \\ _ = stack_trace; |
| 186 | \\ if (std.mem.eql(u8, message, "attempt to cast negative value to unsigned integer")) { | 203 | \\ if (std.mem.eql(u8, message, "attempt to cast negative value to unsigned integer")) { |
| 187 | \\ std.process.exit(126); // good | 204 | \\ std.process.exit(126); // good |
| 188 | \\ } | 205 | \\ } |
| ... | @@ -191,12 +208,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -191,12 +208,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 191 | \\pub fn main() void { | 208 | \\pub fn main() void { |
| 192 | \\ var x = @splat(4, @as(i32, -2147483647)); | 209 | \\ var x = @splat(4, @as(i32, -2147483647)); |
| 193 | \\ var y = @intCast(V(4, u32), x); | 210 | \\ var y = @intCast(V(4, u32), x); |
| | 211 | \\ _ = y; |
| 194 | \\} | 212 | \\} |
| 195 | ); | 213 | ); |
| 196 | | 214 | |
| 197 | cases.addRuntimeSafety("shift left by huge amount", | 215 | cases.addRuntimeSafety("shift left by huge amount", |
| 198 | \\const std = @import("std"); | 216 | \\const std = @import("std"); |
| 199 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 217 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 218 | \\ _ = stack_trace; |
| 200 | \\ if (std.mem.eql(u8, message, "shift amount is greater than the type size")) { | 219 | \\ if (std.mem.eql(u8, message, "shift amount is greater than the type size")) { |
| 201 | \\ std.process.exit(126); // good | 220 | \\ std.process.exit(126); // good |
| 202 | \\ } | 221 | \\ } |
| ... | @@ -206,12 +225,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -206,12 +225,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 206 | \\ var x: u24 = 42; | 225 | \\ var x: u24 = 42; |
| 207 | \\ var y: u5 = 24; | 226 | \\ var y: u5 = 24; |
| 208 | \\ var z = x >> y; | 227 | \\ var z = x >> y; |
| | 228 | \\ _ = z; |
| 209 | \\} | 229 | \\} |
| 210 | ); | 230 | ); |
| 211 | | 231 | |
| 212 | cases.addRuntimeSafety("shift right by huge amount", | 232 | cases.addRuntimeSafety("shift right by huge amount", |
| 213 | \\const std = @import("std"); | 233 | \\const std = @import("std"); |
| 214 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 234 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 235 | \\ _ = stack_trace; |
| 215 | \\ if (std.mem.eql(u8, message, "shift amount is greater than the type size")) { | 236 | \\ if (std.mem.eql(u8, message, "shift amount is greater than the type size")) { |
| 216 | \\ std.process.exit(126); // good | 237 | \\ std.process.exit(126); // good |
| 217 | \\ } | 238 | \\ } |
| ... | @@ -221,12 +242,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -221,12 +242,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 221 | \\ var x: u24 = 42; | 242 | \\ var x: u24 = 42; |
| 222 | \\ var y: u5 = 24; | 243 | \\ var y: u5 = 24; |
| 223 | \\ var z = x << y; | 244 | \\ var z = x << y; |
| | 245 | \\ _ = z; |
| 224 | \\} | 246 | \\} |
| 225 | ); | 247 | ); |
| 226 | | 248 | |
| 227 | cases.addRuntimeSafety("slice sentinel mismatch - optional pointers", | 249 | cases.addRuntimeSafety("slice sentinel mismatch - optional pointers", |
| 228 | \\const std = @import("std"); | 250 | \\const std = @import("std"); |
| 229 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 251 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 252 | \\ _ = stack_trace; |
| 230 | \\ if (std.mem.eql(u8, message, "sentinel mismatch")) { | 253 | \\ if (std.mem.eql(u8, message, "sentinel mismatch")) { |
| 231 | \\ std.process.exit(126); // good | 254 | \\ std.process.exit(126); // good |
| 232 | \\ } | 255 | \\ } |
| ... | @@ -235,12 +258,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -235,12 +258,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 235 | \\pub fn main() void { | 258 | \\pub fn main() void { |
| 236 | \\ var buf: [4]?*i32 = undefined; | 259 | \\ var buf: [4]?*i32 = undefined; |
| 237 | \\ const slice = buf[0..3 :null]; | 260 | \\ const slice = buf[0..3 :null]; |
| | 261 | \\ _ = slice; |
| 238 | \\} | 262 | \\} |
| 239 | ); | 263 | ); |
| 240 | | 264 | |
| 241 | cases.addRuntimeSafety("slice sentinel mismatch - floats", | 265 | cases.addRuntimeSafety("slice sentinel mismatch - floats", |
| 242 | \\const std = @import("std"); | 266 | \\const std = @import("std"); |
| 243 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 267 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 268 | \\ _ = stack_trace; |
| 244 | \\ if (std.mem.eql(u8, message, "sentinel mismatch")) { | 269 | \\ if (std.mem.eql(u8, message, "sentinel mismatch")) { |
| 245 | \\ std.process.exit(126); // good | 270 | \\ std.process.exit(126); // good |
| 246 | \\ } | 271 | \\ } |
| ... | @@ -249,12 +274,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -249,12 +274,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 249 | \\pub fn main() void { | 274 | \\pub fn main() void { |
| 250 | \\ var buf: [4]f32 = undefined; | 275 | \\ var buf: [4]f32 = undefined; |
| 251 | \\ const slice = buf[0..3 :1.2]; | 276 | \\ const slice = buf[0..3 :1.2]; |
| | 277 | \\ _ = slice; |
| 252 | \\} | 278 | \\} |
| 253 | ); | 279 | ); |
| 254 | | 280 | |
| 255 | cases.addRuntimeSafety("pointer slice sentinel mismatch", | 281 | cases.addRuntimeSafety("pointer slice sentinel mismatch", |
| 256 | \\const std = @import("std"); | 282 | \\const std = @import("std"); |
| 257 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 283 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 284 | \\ _ = stack_trace; |
| 258 | \\ if (std.mem.eql(u8, message, "sentinel mismatch")) { | 285 | \\ if (std.mem.eql(u8, message, "sentinel mismatch")) { |
| 259 | \\ std.process.exit(126); // good | 286 | \\ std.process.exit(126); // good |
| 260 | \\ } | 287 | \\ } |
| ... | @@ -264,12 +291,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -264,12 +291,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 264 | \\ var buf: [4]u8 = undefined; | 291 | \\ var buf: [4]u8 = undefined; |
| 265 | \\ const ptr: [*]u8 = &buf; | 292 | \\ const ptr: [*]u8 = &buf; |
| 266 | \\ const slice = ptr[0..3 :0]; | 293 | \\ const slice = ptr[0..3 :0]; |
| | 294 | \\ _ = slice; |
| 267 | \\} | 295 | \\} |
| 268 | ); | 296 | ); |
| 269 | | 297 | |
| 270 | cases.addRuntimeSafety("slice slice sentinel mismatch", | 298 | cases.addRuntimeSafety("slice slice sentinel mismatch", |
| 271 | \\const std = @import("std"); | 299 | \\const std = @import("std"); |
| 272 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 300 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 301 | \\ _ = stack_trace; |
| 273 | \\ if (std.mem.eql(u8, message, "sentinel mismatch")) { | 302 | \\ if (std.mem.eql(u8, message, "sentinel mismatch")) { |
| 274 | \\ std.process.exit(126); // good | 303 | \\ std.process.exit(126); // good |
| 275 | \\ } | 304 | \\ } |
| ... | @@ -279,12 +308,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -279,12 +308,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 279 | \\ var buf: [4]u8 = undefined; | 308 | \\ var buf: [4]u8 = undefined; |
| 280 | \\ const slice = buf[0..]; | 309 | \\ const slice = buf[0..]; |
| 281 | \\ const slice2 = slice[0..3 :0]; | 310 | \\ const slice2 = slice[0..3 :0]; |
| | 311 | \\ _ = slice2; |
| 282 | \\} | 312 | \\} |
| 283 | ); | 313 | ); |
| 284 | | 314 | |
| 285 | cases.addRuntimeSafety("array slice sentinel mismatch", | 315 | cases.addRuntimeSafety("array slice sentinel mismatch", |
| 286 | \\const std = @import("std"); | 316 | \\const std = @import("std"); |
| 287 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 317 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 318 | \\ _ = stack_trace; |
| 288 | \\ if (std.mem.eql(u8, message, "sentinel mismatch")) { | 319 | \\ if (std.mem.eql(u8, message, "sentinel mismatch")) { |
| 289 | \\ std.process.exit(126); // good | 320 | \\ std.process.exit(126); // good |
| 290 | \\ } | 321 | \\ } |
| ... | @@ -293,12 +324,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -293,12 +324,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 293 | \\pub fn main() void { | 324 | \\pub fn main() void { |
| 294 | \\ var buf: [4]u8 = undefined; | 325 | \\ var buf: [4]u8 = undefined; |
| 295 | \\ const slice = buf[0..3 :0]; | 326 | \\ const slice = buf[0..3 :0]; |
| | 327 | \\ _ = slice; |
| 296 | \\} | 328 | \\} |
| 297 | ); | 329 | ); |
| 298 | | 330 | |
| 299 | cases.addRuntimeSafety("intToPtr with misaligned address", | 331 | cases.addRuntimeSafety("intToPtr with misaligned address", |
| 300 | \\const std = @import("std"); | 332 | \\const std = @import("std"); |
| 301 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 333 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 334 | \\ _ = stack_trace; |
| 302 | \\ if (std.mem.eql(u8, message, "incorrect alignment")) { | 335 | \\ if (std.mem.eql(u8, message, "incorrect alignment")) { |
| 303 | \\ std.os.exit(126); // good | 336 | \\ std.os.exit(126); // good |
| 304 | \\ } | 337 | \\ } |
| ... | @@ -307,16 +340,20 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -307,16 +340,20 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 307 | \\pub fn main() void { | 340 | \\pub fn main() void { |
| 308 | \\ var x: usize = 5; | 341 | \\ var x: usize = 5; |
| 309 | \\ var y = @intToPtr([*]align(4) u8, x); | 342 | \\ var y = @intToPtr([*]align(4) u8, x); |
| | 343 | \\ _ = y; |
| 310 | \\} | 344 | \\} |
| 311 | ); | 345 | ); |
| 312 | | 346 | |
| 313 | cases.addRuntimeSafety("resuming a non-suspended function which never been suspended", | 347 | cases.addRuntimeSafety("resuming a non-suspended function which never been suspended", |
| 314 | \\const std = @import("std"); | 348 | \\const std = @import("std"); |
| 315 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 349 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 350 | \\ _ = message; |
| | 351 | \\ _ = stack_trace; |
| 316 | \\ std.os.exit(126); | 352 | \\ std.os.exit(126); |
| 317 | \\} | 353 | \\} |
| 318 | \\fn foo() void { | 354 | \\fn foo() void { |
| 319 | \\ var f = async bar(@frame()); | 355 | \\ var f = async bar(@frame()); |
| | 356 | \\ _ = f; |
| 320 | \\ std.os.exit(0); | 357 | \\ std.os.exit(0); |
| 321 | \\} | 358 | \\} |
| 322 | \\ | 359 | \\ |
| ... | @@ -335,6 +372,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -335,6 +372,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 335 | cases.addRuntimeSafety("resuming a non-suspended function which has been suspended and resumed", | 372 | cases.addRuntimeSafety("resuming a non-suspended function which has been suspended and resumed", |
| 336 | \\const std = @import("std"); | 373 | \\const std = @import("std"); |
| 337 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 374 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 375 | \\ _ = message; |
| | 376 | \\ _ = stack_trace; |
| 338 | \\ std.os.exit(126); | 377 | \\ std.os.exit(126); |
| 339 | \\} | 378 | \\} |
| 340 | \\fn foo() void { | 379 | \\fn foo() void { |
| ... | @@ -342,6 +381,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -342,6 +381,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 342 | \\ global_frame = @frame(); | 381 | \\ global_frame = @frame(); |
| 343 | \\ } | 382 | \\ } |
| 344 | \\ var f = async bar(@frame()); | 383 | \\ var f = async bar(@frame()); |
| | 384 | \\ _ = f; |
| 345 | \\ std.os.exit(0); | 385 | \\ std.os.exit(0); |
| 346 | \\} | 386 | \\} |
| 347 | \\ | 387 | \\ |
| ... | @@ -363,6 +403,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -363,6 +403,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 363 | cases.addRuntimeSafety("nosuspend function call, callee suspends", | 403 | cases.addRuntimeSafety("nosuspend function call, callee suspends", |
| 364 | \\const std = @import("std"); | 404 | \\const std = @import("std"); |
| 365 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 405 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 406 | \\ _ = message; |
| | 407 | \\ _ = stack_trace; |
| 366 | \\ std.os.exit(126); | 408 | \\ std.os.exit(126); |
| 367 | \\} | 409 | \\} |
| 368 | \\pub fn main() void { | 410 | \\pub fn main() void { |
| ... | @@ -379,6 +421,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -379,6 +421,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 379 | cases.addRuntimeSafety("awaiting twice", | 421 | cases.addRuntimeSafety("awaiting twice", |
| 380 | \\const std = @import("std"); | 422 | \\const std = @import("std"); |
| 381 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 423 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 424 | \\ _ = message; |
| | 425 | \\ _ = stack_trace; |
| 382 | \\ std.os.exit(126); | 426 | \\ std.os.exit(126); |
| 383 | \\} | 427 | \\} |
| 384 | \\var frame: anyframe = undefined; | 428 | \\var frame: anyframe = undefined; |
| ... | @@ -404,12 +448,15 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -404,12 +448,15 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 404 | cases.addRuntimeSafety("@asyncCall with too small a frame", | 448 | cases.addRuntimeSafety("@asyncCall with too small a frame", |
| 405 | \\const std = @import("std"); | 449 | \\const std = @import("std"); |
| 406 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 450 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 451 | \\ _ = message; |
| | 452 | \\ _ = stack_trace; |
| 407 | \\ std.os.exit(126); | 453 | \\ std.os.exit(126); |
| 408 | \\} | 454 | \\} |
| 409 | \\pub fn main() void { | 455 | \\pub fn main() void { |
| 410 | \\ var bytes: [1]u8 align(16) = undefined; | 456 | \\ var bytes: [1]u8 align(16) = undefined; |
| 411 | \\ var ptr = other; | 457 | \\ var ptr = other; |
| 412 | \\ var frame = @asyncCall(&bytes, {}, ptr, .{}); | 458 | \\ var frame = @asyncCall(&bytes, {}, ptr, .{}); |
| | 459 | \\ _ = frame; |
| 413 | \\} | 460 | \\} |
| 414 | \\fn other() callconv(.Async) void { | 461 | \\fn other() callconv(.Async) void { |
| 415 | \\ suspend {} | 462 | \\ suspend {} |
| ... | @@ -419,6 +466,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -419,6 +466,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 419 | cases.addRuntimeSafety("resuming a function which is awaiting a frame", | 466 | cases.addRuntimeSafety("resuming a function which is awaiting a frame", |
| 420 | \\const std = @import("std"); | 467 | \\const std = @import("std"); |
| 421 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 468 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 469 | \\ _ = message; |
| | 470 | \\ _ = stack_trace; |
| 422 | \\ std.os.exit(126); | 471 | \\ std.os.exit(126); |
| 423 | \\} | 472 | \\} |
| 424 | \\pub fn main() void { | 473 | \\pub fn main() void { |
| ... | @@ -437,6 +486,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -437,6 +486,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 437 | cases.addRuntimeSafety("resuming a function which is awaiting a call", | 486 | cases.addRuntimeSafety("resuming a function which is awaiting a call", |
| 438 | \\const std = @import("std"); | 487 | \\const std = @import("std"); |
| 439 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 488 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 489 | \\ _ = message; |
| | 490 | \\ _ = stack_trace; |
| 440 | \\ std.os.exit(126); | 491 | \\ std.os.exit(126); |
| 441 | \\} | 492 | \\} |
| 442 | \\pub fn main() void { | 493 | \\pub fn main() void { |
| ... | @@ -454,6 +505,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -454,6 +505,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 454 | cases.addRuntimeSafety("invalid resume of async function", | 505 | cases.addRuntimeSafety("invalid resume of async function", |
| 455 | \\const std = @import("std"); | 506 | \\const std = @import("std"); |
| 456 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 507 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 508 | \\ _ = message; |
| | 509 | \\ _ = stack_trace; |
| 457 | \\ std.os.exit(126); | 510 | \\ std.os.exit(126); |
| 458 | \\} | 511 | \\} |
| 459 | \\pub fn main() void { | 512 | \\pub fn main() void { |
| ... | @@ -469,61 +522,78 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -469,61 +522,78 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 469 | cases.addRuntimeSafety(".? operator on null pointer", | 522 | cases.addRuntimeSafety(".? operator on null pointer", |
| 470 | \\const std = @import("std"); | 523 | \\const std = @import("std"); |
| 471 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 524 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 525 | \\ _ = message; |
| | 526 | \\ _ = stack_trace; |
| 472 | \\ std.os.exit(126); | 527 | \\ std.os.exit(126); |
| 473 | \\} | 528 | \\} |
| 474 | \\pub fn main() void { | 529 | \\pub fn main() void { |
| 475 | \\ var ptr: ?*i32 = null; | 530 | \\ var ptr: ?*i32 = null; |
| 476 | \\ var b = ptr.?; | 531 | \\ var b = ptr.?; |
| | 532 | \\ _ = b; |
| 477 | \\} | 533 | \\} |
| 478 | ); | 534 | ); |
| 479 | | 535 | |
| 480 | cases.addRuntimeSafety(".? operator on C pointer", | 536 | cases.addRuntimeSafety(".? operator on C pointer", |
| 481 | \\const std = @import("std"); | 537 | \\const std = @import("std"); |
| 482 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 538 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 539 | \\ _ = message; |
| | 540 | \\ _ = stack_trace; |
| 483 | \\ std.os.exit(126); | 541 | \\ std.os.exit(126); |
| 484 | \\} | 542 | \\} |
| 485 | \\pub fn main() void { | 543 | \\pub fn main() void { |
| 486 | \\ var ptr: [*c]i32 = null; | 544 | \\ var ptr: [*c]i32 = null; |
| 487 | \\ var b = ptr.?; | 545 | \\ var b = ptr.?; |
| | 546 | \\ _ = b; |
| 488 | \\} | 547 | \\} |
| 489 | ); | 548 | ); |
| 490 | | 549 | |
| 491 | cases.addRuntimeSafety("@intToPtr address zero to non-optional pointer", | 550 | cases.addRuntimeSafety("@intToPtr address zero to non-optional pointer", |
| 492 | \\const std = @import("std"); | 551 | \\const std = @import("std"); |
| 493 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 552 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 553 | \\ _ = message; |
| | 554 | \\ _ = stack_trace; |
| 494 | \\ std.os.exit(126); | 555 | \\ std.os.exit(126); |
| 495 | \\} | 556 | \\} |
| 496 | \\pub fn main() void { | 557 | \\pub fn main() void { |
| 497 | \\ var zero: usize = 0; | 558 | \\ var zero: usize = 0; |
| 498 | \\ var b = @intToPtr(*i32, zero); | 559 | \\ var b = @intToPtr(*i32, zero); |
| | 560 | \\ _ = b; |
| 499 | \\} | 561 | \\} |
| 500 | ); | 562 | ); |
| 501 | | 563 | |
| 502 | cases.addRuntimeSafety("@intToPtr address zero to non-optional byte-aligned pointer", | 564 | cases.addRuntimeSafety("@intToPtr address zero to non-optional byte-aligned pointer", |
| 503 | \\const std = @import("std"); | 565 | \\const std = @import("std"); |
| 504 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 566 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 567 | \\ _ = message; |
| | 568 | \\ _ = stack_trace; |
| 505 | \\ std.os.exit(126); | 569 | \\ std.os.exit(126); |
| 506 | \\} | 570 | \\} |
| 507 | \\pub fn main() void { | 571 | \\pub fn main() void { |
| 508 | \\ var zero: usize = 0; | 572 | \\ var zero: usize = 0; |
| 509 | \\ var b = @intToPtr(*u8, zero); | 573 | \\ var b = @intToPtr(*u8, zero); |
| | 574 | \\ _ = b; |
| 510 | \\} | 575 | \\} |
| 511 | ); | 576 | ); |
| 512 | | 577 | |
| 513 | cases.addRuntimeSafety("pointer casting null to non-optional pointer", | 578 | cases.addRuntimeSafety("pointer casting null to non-optional pointer", |
| 514 | \\const std = @import("std"); | 579 | \\const std = @import("std"); |
| 515 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 580 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 581 | \\ _ = message; |
| | 582 | \\ _ = stack_trace; |
| 516 | \\ std.os.exit(126); | 583 | \\ std.os.exit(126); |
| 517 | \\} | 584 | \\} |
| 518 | \\pub fn main() void { | 585 | \\pub fn main() void { |
| 519 | \\ var c_ptr: [*c]u8 = 0; | 586 | \\ var c_ptr: [*c]u8 = 0; |
| 520 | \\ var zig_ptr: *u8 = c_ptr; | 587 | \\ var zig_ptr: *u8 = c_ptr; |
| | 588 | \\ _ = zig_ptr; |
| 521 | \\} | 589 | \\} |
| 522 | ); | 590 | ); |
| 523 | | 591 | |
| 524 | cases.addRuntimeSafety("@intToEnum - no matching tag value", | 592 | cases.addRuntimeSafety("@intToEnum - no matching tag value", |
| 525 | \\const std = @import("std"); | 593 | \\const std = @import("std"); |
| 526 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 594 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 595 | \\ _ = message; |
| | 596 | \\ _ = stack_trace; |
| 527 | \\ std.os.exit(126); | 597 | \\ std.os.exit(126); |
| 528 | \\} | 598 | \\} |
| 529 | \\const Foo = enum { | 599 | \\const Foo = enum { |
| ... | @@ -537,12 +607,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -537,12 +607,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 537 | \\fn bar(a: u2) Foo { | 607 | \\fn bar(a: u2) Foo { |
| 538 | \\ return @intToEnum(Foo, a); | 608 | \\ return @intToEnum(Foo, a); |
| 539 | \\} | 609 | \\} |
| 540 | \\fn baz(a: Foo) void {} | 610 | \\fn baz(_: Foo) void {} |
| 541 | ); | 611 | ); |
| 542 | | 612 | |
| 543 | cases.addRuntimeSafety("@floatToInt cannot fit - negative to unsigned", | 613 | cases.addRuntimeSafety("@floatToInt cannot fit - negative to unsigned", |
| 544 | \\const std = @import("std"); | 614 | \\const std = @import("std"); |
| 545 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 615 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 616 | \\ _ = message; |
| | 617 | \\ _ = stack_trace; |
| 546 | \\ std.os.exit(126); | 618 | \\ std.os.exit(126); |
| 547 | \\} | 619 | \\} |
| 548 | \\pub fn main() void { | 620 | \\pub fn main() void { |
| ... | @@ -551,12 +623,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -551,12 +623,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 551 | \\fn bar(a: f32) u8 { | 623 | \\fn bar(a: f32) u8 { |
| 552 | \\ return @floatToInt(u8, a); | 624 | \\ return @floatToInt(u8, a); |
| 553 | \\} | 625 | \\} |
| 554 | \\fn baz(a: u8) void { } | 626 | \\fn baz(_: u8) void { } |
| 555 | ); | 627 | ); |
| 556 | | 628 | |
| 557 | cases.addRuntimeSafety("@floatToInt cannot fit - negative out of range", | 629 | cases.addRuntimeSafety("@floatToInt cannot fit - negative out of range", |
| 558 | \\const std = @import("std"); | 630 | \\const std = @import("std"); |
| 559 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 631 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 632 | \\ _ = message; |
| | 633 | \\ _ = stack_trace; |
| 560 | \\ std.os.exit(126); | 634 | \\ std.os.exit(126); |
| 561 | \\} | 635 | \\} |
| 562 | \\pub fn main() void { | 636 | \\pub fn main() void { |
| ... | @@ -565,12 +639,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -565,12 +639,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 565 | \\fn bar(a: f32) i8 { | 639 | \\fn bar(a: f32) i8 { |
| 566 | \\ return @floatToInt(i8, a); | 640 | \\ return @floatToInt(i8, a); |
| 567 | \\} | 641 | \\} |
| 568 | \\fn baz(a: i8) void { } | 642 | \\fn baz(_: i8) void { } |
| 569 | ); | 643 | ); |
| 570 | | 644 | |
| 571 | cases.addRuntimeSafety("@floatToInt cannot fit - positive out of range", | 645 | cases.addRuntimeSafety("@floatToInt cannot fit - positive out of range", |
| 572 | \\const std = @import("std"); | 646 | \\const std = @import("std"); |
| 573 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 647 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 648 | \\ _ = message; |
| | 649 | \\ _ = stack_trace; |
| 574 | \\ std.os.exit(126); | 650 | \\ std.os.exit(126); |
| 575 | \\} | 651 | \\} |
| 576 | \\pub fn main() void { | 652 | \\pub fn main() void { |
| ... | @@ -579,12 +655,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -579,12 +655,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 579 | \\fn bar(a: f32) u8 { | 655 | \\fn bar(a: f32) u8 { |
| 580 | \\ return @floatToInt(u8, a); | 656 | \\ return @floatToInt(u8, a); |
| 581 | \\} | 657 | \\} |
| 582 | \\fn baz(a: u8) void { } | 658 | \\fn baz(_: u8) void { } |
| 583 | ); | 659 | ); |
| 584 | | 660 | |
| 585 | cases.addRuntimeSafety("calling panic", | 661 | cases.addRuntimeSafety("calling panic", |
| 586 | \\const std = @import("std"); | 662 | \\const std = @import("std"); |
| 587 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 663 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 664 | \\ _ = message; |
| | 665 | \\ _ = stack_trace; |
| 588 | \\ std.os.exit(126); | 666 | \\ std.os.exit(126); |
| 589 | \\} | 667 | \\} |
| 590 | \\pub fn main() void { | 668 | \\pub fn main() void { |
| ... | @@ -595,6 +673,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -595,6 +673,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 595 | cases.addRuntimeSafety("out of bounds slice access", | 673 | cases.addRuntimeSafety("out of bounds slice access", |
| 596 | \\const std = @import("std"); | 674 | \\const std = @import("std"); |
| 597 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 675 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 676 | \\ _ = message; |
| | 677 | \\ _ = stack_trace; |
| 598 | \\ std.os.exit(126); | 678 | \\ std.os.exit(126); |
| 599 | \\} | 679 | \\} |
| 600 | \\pub fn main() void { | 680 | \\pub fn main() void { |
| ... | @@ -604,12 +684,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -604,12 +684,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 604 | \\fn bar(a: []const i32) i32 { | 684 | \\fn bar(a: []const i32) i32 { |
| 605 | \\ return a[4]; | 685 | \\ return a[4]; |
| 606 | \\} | 686 | \\} |
| 607 | \\fn baz(a: i32) void { } | 687 | \\fn baz(_: i32) void { } |
| 608 | ); | 688 | ); |
| 609 | | 689 | |
| 610 | cases.addRuntimeSafety("integer addition overflow", | 690 | cases.addRuntimeSafety("integer addition overflow", |
| 611 | \\const std = @import("std"); | 691 | \\const std = @import("std"); |
| 612 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 692 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 693 | \\ _ = message; |
| | 694 | \\ _ = stack_trace; |
| 613 | \\ std.os.exit(126); | 695 | \\ std.os.exit(126); |
| 614 | \\} | 696 | \\} |
| 615 | \\pub fn main() !void { | 697 | \\pub fn main() !void { |
| ... | @@ -624,12 +706,15 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -624,12 +706,15 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 624 | cases.addRuntimeSafety("vector integer addition overflow", | 706 | cases.addRuntimeSafety("vector integer addition overflow", |
| 625 | \\const std = @import("std"); | 707 | \\const std = @import("std"); |
| 626 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 708 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 709 | \\ _ = message; |
| | 710 | \\ _ = stack_trace; |
| 627 | \\ std.os.exit(126); | 711 | \\ std.os.exit(126); |
| 628 | \\} | 712 | \\} |
| 629 | \\pub fn main() void { | 713 | \\pub fn main() void { |
| 630 | \\ var a: std.meta.Vector(4, i32) = [_]i32{ 1, 2, 2147483643, 4 }; | 714 | \\ var a: std.meta.Vector(4, i32) = [_]i32{ 1, 2, 2147483643, 4 }; |
| 631 | \\ var b: std.meta.Vector(4, i32) = [_]i32{ 5, 6, 7, 8 }; | 715 | \\ var b: std.meta.Vector(4, i32) = [_]i32{ 5, 6, 7, 8 }; |
| 632 | \\ const x = add(a, b); | 716 | \\ const x = add(a, b); |
| | 717 | \\ _ = x; |
| 633 | \\} | 718 | \\} |
| 634 | \\fn add(a: std.meta.Vector(4, i32), b: std.meta.Vector(4, i32)) std.meta.Vector(4, i32) { | 719 | \\fn add(a: std.meta.Vector(4, i32), b: std.meta.Vector(4, i32)) std.meta.Vector(4, i32) { |
| 635 | \\ return a + b; | 720 | \\ return a + b; |
| ... | @@ -639,12 +724,15 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -639,12 +724,15 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 639 | cases.addRuntimeSafety("vector integer subtraction overflow", | 724 | cases.addRuntimeSafety("vector integer subtraction overflow", |
| 640 | \\const std = @import("std"); | 725 | \\const std = @import("std"); |
| 641 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 726 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 727 | \\ _ = message; |
| | 728 | \\ _ = stack_trace; |
| 642 | \\ std.os.exit(126); | 729 | \\ std.os.exit(126); |
| 643 | \\} | 730 | \\} |
| 644 | \\pub fn main() void { | 731 | \\pub fn main() void { |
| 645 | \\ var a: std.meta.Vector(4, u32) = [_]u32{ 1, 2, 8, 4 }; | 732 | \\ var a: std.meta.Vector(4, u32) = [_]u32{ 1, 2, 8, 4 }; |
| 646 | \\ var b: std.meta.Vector(4, u32) = [_]u32{ 5, 6, 7, 8 }; | 733 | \\ var b: std.meta.Vector(4, u32) = [_]u32{ 5, 6, 7, 8 }; |
| 647 | \\ const x = sub(b, a); | 734 | \\ const x = sub(b, a); |
| | 735 | \\ _ = x; |
| 648 | \\} | 736 | \\} |
| 649 | \\fn sub(a: std.meta.Vector(4, u32), b: std.meta.Vector(4, u32)) std.meta.Vector(4, u32) { | 737 | \\fn sub(a: std.meta.Vector(4, u32), b: std.meta.Vector(4, u32)) std.meta.Vector(4, u32) { |
| 650 | \\ return a - b; | 738 | \\ return a - b; |
| ... | @@ -654,12 +742,15 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -654,12 +742,15 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 654 | cases.addRuntimeSafety("vector integer multiplication overflow", | 742 | cases.addRuntimeSafety("vector integer multiplication overflow", |
| 655 | \\const std = @import("std"); | 743 | \\const std = @import("std"); |
| 656 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 744 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 745 | \\ _ = message; |
| | 746 | \\ _ = stack_trace; |
| 657 | \\ std.os.exit(126); | 747 | \\ std.os.exit(126); |
| 658 | \\} | 748 | \\} |
| 659 | \\pub fn main() void { | 749 | \\pub fn main() void { |
| 660 | \\ var a: std.meta.Vector(4, u8) = [_]u8{ 1, 2, 200, 4 }; | 750 | \\ var a: std.meta.Vector(4, u8) = [_]u8{ 1, 2, 200, 4 }; |
| 661 | \\ var b: std.meta.Vector(4, u8) = [_]u8{ 5, 6, 2, 8 }; | 751 | \\ var b: std.meta.Vector(4, u8) = [_]u8{ 5, 6, 2, 8 }; |
| 662 | \\ const x = mul(b, a); | 752 | \\ const x = mul(b, a); |
| | 753 | \\ _ = x; |
| 663 | \\} | 754 | \\} |
| 664 | \\fn mul(a: std.meta.Vector(4, u8), b: std.meta.Vector(4, u8)) std.meta.Vector(4, u8) { | 755 | \\fn mul(a: std.meta.Vector(4, u8), b: std.meta.Vector(4, u8)) std.meta.Vector(4, u8) { |
| 665 | \\ return a * b; | 756 | \\ return a * b; |
| ... | @@ -669,11 +760,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -669,11 +760,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 669 | cases.addRuntimeSafety("vector integer negation overflow", | 760 | cases.addRuntimeSafety("vector integer negation overflow", |
| 670 | \\const std = @import("std"); | 761 | \\const std = @import("std"); |
| 671 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 762 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 763 | \\ _ = message; |
| | 764 | \\ _ = stack_trace; |
| 672 | \\ std.os.exit(126); | 765 | \\ std.os.exit(126); |
| 673 | \\} | 766 | \\} |
| 674 | \\pub fn main() void { | 767 | \\pub fn main() void { |
| 675 | \\ var a: std.meta.Vector(4, i16) = [_]i16{ 1, -32768, 200, 4 }; | 768 | \\ var a: std.meta.Vector(4, i16) = [_]i16{ 1, -32768, 200, 4 }; |
| 676 | \\ const x = neg(a); | 769 | \\ const x = neg(a); |
| | 770 | \\ _ = x; |
| 677 | \\} | 771 | \\} |
| 678 | \\fn neg(a: std.meta.Vector(4, i16)) std.meta.Vector(4, i16) { | 772 | \\fn neg(a: std.meta.Vector(4, i16)) std.meta.Vector(4, i16) { |
| 679 | \\ return -a; | 773 | \\ return -a; |
| ... | @@ -683,6 +777,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -683,6 +777,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 683 | cases.addRuntimeSafety("integer subtraction overflow", | 777 | cases.addRuntimeSafety("integer subtraction overflow", |
| 684 | \\const std = @import("std"); | 778 | \\const std = @import("std"); |
| 685 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 779 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 780 | \\ _ = message; |
| | 781 | \\ _ = stack_trace; |
| 686 | \\ std.os.exit(126); | 782 | \\ std.os.exit(126); |
| 687 | \\} | 783 | \\} |
| 688 | \\pub fn main() !void { | 784 | \\pub fn main() !void { |
| ... | @@ -697,6 +793,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -697,6 +793,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 697 | cases.addRuntimeSafety("integer multiplication overflow", | 793 | cases.addRuntimeSafety("integer multiplication overflow", |
| 698 | \\const std = @import("std"); | 794 | \\const std = @import("std"); |
| 699 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 795 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 796 | \\ _ = message; |
| | 797 | \\ _ = stack_trace; |
| 700 | \\ std.os.exit(126); | 798 | \\ std.os.exit(126); |
| 701 | \\} | 799 | \\} |
| 702 | \\pub fn main() !void { | 800 | \\pub fn main() !void { |
| ... | @@ -711,6 +809,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -711,6 +809,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 711 | cases.addRuntimeSafety("integer negation overflow", | 809 | cases.addRuntimeSafety("integer negation overflow", |
| 712 | \\const std = @import("std"); | 810 | \\const std = @import("std"); |
| 713 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 811 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 812 | \\ _ = message; |
| | 813 | \\ _ = stack_trace; |
| 714 | \\ std.os.exit(126); | 814 | \\ std.os.exit(126); |
| 715 | \\} | 815 | \\} |
| 716 | \\pub fn main() !void { | 816 | \\pub fn main() !void { |
| ... | @@ -725,6 +825,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -725,6 +825,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 725 | cases.addRuntimeSafety("signed integer division overflow", | 825 | cases.addRuntimeSafety("signed integer division overflow", |
| 726 | \\const std = @import("std"); | 826 | \\const std = @import("std"); |
| 727 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 827 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 828 | \\ _ = message; |
| | 829 | \\ _ = stack_trace; |
| 728 | \\ std.os.exit(126); | 830 | \\ std.os.exit(126); |
| 729 | \\} | 831 | \\} |
| 730 | \\pub fn main() !void { | 832 | \\pub fn main() !void { |
| ... | @@ -739,6 +841,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -739,6 +841,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 739 | cases.addRuntimeSafety("signed integer division overflow - vectors", | 841 | cases.addRuntimeSafety("signed integer division overflow - vectors", |
| 740 | \\const std = @import("std"); | 842 | \\const std = @import("std"); |
| 741 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 843 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 844 | \\ _ = message; |
| | 845 | \\ _ = stack_trace; |
| 742 | \\ std.os.exit(126); | 846 | \\ std.os.exit(126); |
| 743 | \\} | 847 | \\} |
| 744 | \\pub fn main() !void { | 848 | \\pub fn main() !void { |
| ... | @@ -755,6 +859,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -755,6 +859,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 755 | cases.addRuntimeSafety("signed shift left overflow", | 859 | cases.addRuntimeSafety("signed shift left overflow", |
| 756 | \\const std = @import("std"); | 860 | \\const std = @import("std"); |
| 757 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 861 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 862 | \\ _ = message; |
| | 863 | \\ _ = stack_trace; |
| 758 | \\ std.os.exit(126); | 864 | \\ std.os.exit(126); |
| 759 | \\} | 865 | \\} |
| 760 | \\pub fn main() !void { | 866 | \\pub fn main() !void { |
| ... | @@ -769,6 +875,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -769,6 +875,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 769 | cases.addRuntimeSafety("unsigned shift left overflow", | 875 | cases.addRuntimeSafety("unsigned shift left overflow", |
| 770 | \\const std = @import("std"); | 876 | \\const std = @import("std"); |
| 771 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 877 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 878 | \\ _ = message; |
| | 879 | \\ _ = stack_trace; |
| 772 | \\ std.os.exit(126); | 880 | \\ std.os.exit(126); |
| 773 | \\} | 881 | \\} |
| 774 | \\pub fn main() !void { | 882 | \\pub fn main() !void { |
| ... | @@ -783,6 +891,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -783,6 +891,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 783 | cases.addRuntimeSafety("signed shift right overflow", | 891 | cases.addRuntimeSafety("signed shift right overflow", |
| 784 | \\const std = @import("std"); | 892 | \\const std = @import("std"); |
| 785 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 893 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 894 | \\ _ = message; |
| | 895 | \\ _ = stack_trace; |
| 786 | \\ std.os.exit(126); | 896 | \\ std.os.exit(126); |
| 787 | \\} | 897 | \\} |
| 788 | \\pub fn main() !void { | 898 | \\pub fn main() !void { |
| ... | @@ -797,6 +907,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -797,6 +907,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 797 | cases.addRuntimeSafety("unsigned shift right overflow", | 907 | cases.addRuntimeSafety("unsigned shift right overflow", |
| 798 | \\const std = @import("std"); | 908 | \\const std = @import("std"); |
| 799 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 909 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 910 | \\ _ = message; |
| | 911 | \\ _ = stack_trace; |
| 800 | \\ std.os.exit(126); | 912 | \\ std.os.exit(126); |
| 801 | \\} | 913 | \\} |
| 802 | \\pub fn main() !void { | 914 | \\pub fn main() !void { |
| ... | @@ -811,10 +923,13 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -811,10 +923,13 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 811 | cases.addRuntimeSafety("integer division by zero", | 923 | cases.addRuntimeSafety("integer division by zero", |
| 812 | \\const std = @import("std"); | 924 | \\const std = @import("std"); |
| 813 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 925 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 926 | \\ _ = message; |
| | 927 | \\ _ = stack_trace; |
| 814 | \\ std.os.exit(126); | 928 | \\ std.os.exit(126); |
| 815 | \\} | 929 | \\} |
| 816 | \\pub fn main() void { | 930 | \\pub fn main() void { |
| 817 | \\ const x = div0(999, 0); | 931 | \\ const x = div0(999, 0); |
| | 932 | \\ _ = x; |
| 818 | \\} | 933 | \\} |
| 819 | \\fn div0(a: i32, b: i32) i32 { | 934 | \\fn div0(a: i32, b: i32) i32 { |
| 820 | \\ return @divTrunc(a, b); | 935 | \\ return @divTrunc(a, b); |
| ... | @@ -824,12 +939,15 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -824,12 +939,15 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 824 | cases.addRuntimeSafety("integer division by zero - vectors", | 939 | cases.addRuntimeSafety("integer division by zero - vectors", |
| 825 | \\const std = @import("std"); | 940 | \\const std = @import("std"); |
| 826 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 941 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 942 | \\ _ = message; |
| | 943 | \\ _ = stack_trace; |
| 827 | \\ std.os.exit(126); | 944 | \\ std.os.exit(126); |
| 828 | \\} | 945 | \\} |
| 829 | \\pub fn main() void { | 946 | \\pub fn main() void { |
| 830 | \\ var a: std.meta.Vector(4, i32) = [4]i32{111, 222, 333, 444}; | 947 | \\ var a: std.meta.Vector(4, i32) = [4]i32{111, 222, 333, 444}; |
| 831 | \\ var b: std.meta.Vector(4, i32) = [4]i32{111, 0, 333, 444}; | 948 | \\ var b: std.meta.Vector(4, i32) = [4]i32{111, 0, 333, 444}; |
| 832 | \\ const x = div0(a, b); | 949 | \\ const x = div0(a, b); |
| | 950 | \\ _ = x; |
| 833 | \\} | 951 | \\} |
| 834 | \\fn div0(a: std.meta.Vector(4, i32), b: std.meta.Vector(4, i32)) std.meta.Vector(4, i32) { | 952 | \\fn div0(a: std.meta.Vector(4, i32), b: std.meta.Vector(4, i32)) std.meta.Vector(4, i32) { |
| 835 | \\ return @divTrunc(a, b); | 953 | \\ return @divTrunc(a, b); |
| ... | @@ -839,6 +957,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -839,6 +957,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 839 | cases.addRuntimeSafety("exact division failure", | 957 | cases.addRuntimeSafety("exact division failure", |
| 840 | \\const std = @import("std"); | 958 | \\const std = @import("std"); |
| 841 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 959 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 960 | \\ _ = message; |
| | 961 | \\ _ = stack_trace; |
| 842 | \\ std.os.exit(126); | 962 | \\ std.os.exit(126); |
| 843 | \\} | 963 | \\} |
| 844 | \\pub fn main() !void { | 964 | \\pub fn main() !void { |
| ... | @@ -853,12 +973,15 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -853,12 +973,15 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 853 | cases.addRuntimeSafety("exact division failure - vectors", | 973 | cases.addRuntimeSafety("exact division failure - vectors", |
| 854 | \\const std = @import("std"); | 974 | \\const std = @import("std"); |
| 855 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 975 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 976 | \\ _ = message; |
| | 977 | \\ _ = stack_trace; |
| 856 | \\ std.os.exit(126); | 978 | \\ std.os.exit(126); |
| 857 | \\} | 979 | \\} |
| 858 | \\pub fn main() !void { | 980 | \\pub fn main() !void { |
| 859 | \\ var a: std.meta.Vector(4, i32) = [4]i32{111, 222, 333, 444}; | 981 | \\ var a: std.meta.Vector(4, i32) = [4]i32{111, 222, 333, 444}; |
| 860 | \\ var b: std.meta.Vector(4, i32) = [4]i32{111, 222, 333, 441}; | 982 | \\ var b: std.meta.Vector(4, i32) = [4]i32{111, 222, 333, 441}; |
| 861 | \\ const x = divExact(a, b); | 983 | \\ const x = divExact(a, b); |
| | 984 | \\ _ = x; |
| 862 | \\} | 985 | \\} |
| 863 | \\fn divExact(a: std.meta.Vector(4, i32), b: std.meta.Vector(4, i32)) std.meta.Vector(4, i32) { | 986 | \\fn divExact(a: std.meta.Vector(4, i32), b: std.meta.Vector(4, i32)) std.meta.Vector(4, i32) { |
| 864 | \\ return @divExact(a, b); | 987 | \\ return @divExact(a, b); |
| ... | @@ -868,6 +991,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -868,6 +991,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 868 | cases.addRuntimeSafety("cast []u8 to bigger slice of wrong size", | 991 | cases.addRuntimeSafety("cast []u8 to bigger slice of wrong size", |
| 869 | \\const std = @import("std"); | 992 | \\const std = @import("std"); |
| 870 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 993 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 994 | \\ _ = message; |
| | 995 | \\ _ = stack_trace; |
| 871 | \\ std.os.exit(126); | 996 | \\ std.os.exit(126); |
| 872 | \\} | 997 | \\} |
| 873 | \\pub fn main() !void { | 998 | \\pub fn main() !void { |
| ... | @@ -882,6 +1007,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -882,6 +1007,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 882 | cases.addRuntimeSafety("value does not fit in shortening cast", | 1007 | cases.addRuntimeSafety("value does not fit in shortening cast", |
| 883 | \\const std = @import("std"); | 1008 | \\const std = @import("std"); |
| 884 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 1009 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 1010 | \\ _ = message; |
| | 1011 | \\ _ = stack_trace; |
| 885 | \\ std.os.exit(126); | 1012 | \\ std.os.exit(126); |
| 886 | \\} | 1013 | \\} |
| 887 | \\pub fn main() !void { | 1014 | \\pub fn main() !void { |
| ... | @@ -896,6 +1023,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -896,6 +1023,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 896 | cases.addRuntimeSafety("value does not fit in shortening cast - u0", | 1023 | cases.addRuntimeSafety("value does not fit in shortening cast - u0", |
| 897 | \\const std = @import("std"); | 1024 | \\const std = @import("std"); |
| 898 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 1025 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 1026 | \\ _ = message; |
| | 1027 | \\ _ = stack_trace; |
| 899 | \\ std.os.exit(126); | 1028 | \\ std.os.exit(126); |
| 900 | \\} | 1029 | \\} |
| 901 | \\pub fn main() !void { | 1030 | \\pub fn main() !void { |
| ... | @@ -910,6 +1039,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -910,6 +1039,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 910 | cases.addRuntimeSafety("signed integer not fitting in cast to unsigned integer", | 1039 | cases.addRuntimeSafety("signed integer not fitting in cast to unsigned integer", |
| 911 | \\const std = @import("std"); | 1040 | \\const std = @import("std"); |
| 912 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 1041 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 1042 | \\ _ = message; |
| | 1043 | \\ _ = stack_trace; |
| 913 | \\ std.os.exit(126); | 1044 | \\ std.os.exit(126); |
| 914 | \\} | 1045 | \\} |
| 915 | \\pub fn main() !void { | 1046 | \\pub fn main() !void { |
| ... | @@ -924,28 +1055,35 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -924,28 +1055,35 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 924 | cases.addRuntimeSafety("signed integer not fitting in cast to unsigned integer - widening", | 1055 | cases.addRuntimeSafety("signed integer not fitting in cast to unsigned integer - widening", |
| 925 | \\const std = @import("std"); | 1056 | \\const std = @import("std"); |
| 926 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 1057 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 1058 | \\ _ = message; |
| | 1059 | \\ _ = stack_trace; |
| 927 | \\ std.os.exit(126); | 1060 | \\ std.os.exit(126); |
| 928 | \\} | 1061 | \\} |
| 929 | \\pub fn main() void { | 1062 | \\pub fn main() void { |
| 930 | \\ var value: c_short = -1; | 1063 | \\ var value: c_short = -1; |
| 931 | \\ var casted = @intCast(u32, value); | 1064 | \\ var casted = @intCast(u32, value); |
| | 1065 | \\ _ = casted; |
| 932 | \\} | 1066 | \\} |
| 933 | ); | 1067 | ); |
| 934 | | 1068 | |
| 935 | cases.addRuntimeSafety("unsigned integer not fitting in cast to signed integer - same bit count", | 1069 | cases.addRuntimeSafety("unsigned integer not fitting in cast to signed integer - same bit count", |
| 936 | \\const std = @import("std"); | 1070 | \\const std = @import("std"); |
| 937 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 1071 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 1072 | \\ _ = message; |
| | 1073 | \\ _ = stack_trace; |
| 938 | \\ std.os.exit(126); | 1074 | \\ std.os.exit(126); |
| 939 | \\} | 1075 | \\} |
| 940 | \\pub fn main() void { | 1076 | \\pub fn main() void { |
| 941 | \\ var value: u8 = 245; | 1077 | \\ var value: u8 = 245; |
| 942 | \\ var casted = @intCast(i8, value); | 1078 | \\ var casted = @intCast(i8, value); |
| | 1079 | \\ _ = casted; |
| 943 | \\} | 1080 | \\} |
| 944 | ); | 1081 | ); |
| 945 | | 1082 | |
| 946 | cases.addRuntimeSafety("unwrap error", | 1083 | cases.addRuntimeSafety("unwrap error", |
| 947 | \\const std = @import("std"); | 1084 | \\const std = @import("std"); |
| 948 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 1085 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 1086 | \\ _ = stack_trace; |
| 949 | \\ if (std.mem.eql(u8, message, "attempt to unwrap error: Whatever")) { | 1087 | \\ if (std.mem.eql(u8, message, "attempt to unwrap error: Whatever")) { |
| 950 | \\ std.os.exit(126); // good | 1088 | \\ std.os.exit(126); // good |
| 951 | \\ } | 1089 | \\ } |
| ... | @@ -962,6 +1100,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -962,6 +1100,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 962 | cases.addRuntimeSafety("cast integer to global error and no code matches", | 1100 | cases.addRuntimeSafety("cast integer to global error and no code matches", |
| 963 | \\const std = @import("std"); | 1101 | \\const std = @import("std"); |
| 964 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 1102 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 1103 | \\ _ = message; |
| | 1104 | \\ _ = stack_trace; |
| 965 | \\ std.os.exit(126); | 1105 | \\ std.os.exit(126); |
| 966 | \\} | 1106 | \\} |
| 967 | \\pub fn main() void { | 1107 | \\pub fn main() void { |
| ... | @@ -975,6 +1115,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -975,6 +1115,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 975 | cases.addRuntimeSafety("@errSetCast error not present in destination", | 1115 | cases.addRuntimeSafety("@errSetCast error not present in destination", |
| 976 | \\const std = @import("std"); | 1116 | \\const std = @import("std"); |
| 977 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 1117 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 1118 | \\ _ = message; |
| | 1119 | \\ _ = stack_trace; |
| 978 | \\ std.os.exit(126); | 1120 | \\ std.os.exit(126); |
| 979 | \\} | 1121 | \\} |
| 980 | \\const Set1 = error{A, B}; | 1122 | \\const Set1 = error{A, B}; |
| ... | @@ -990,6 +1132,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -990,6 +1132,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 990 | cases.addRuntimeSafety("@alignCast misaligned", | 1132 | cases.addRuntimeSafety("@alignCast misaligned", |
| 991 | \\const std = @import("std"); | 1133 | \\const std = @import("std"); |
| 992 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 1134 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 1135 | \\ _ = message; |
| | 1136 | \\ _ = stack_trace; |
| 993 | \\ std.os.exit(126); | 1137 | \\ std.os.exit(126); |
| 994 | \\} | 1138 | \\} |
| 995 | \\pub fn main() !void { | 1139 | \\pub fn main() !void { |
| ... | @@ -1007,6 +1151,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -1007,6 +1151,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 1007 | cases.addRuntimeSafety("bad union field access", | 1151 | cases.addRuntimeSafety("bad union field access", |
| 1008 | \\const std = @import("std"); | 1152 | \\const std = @import("std"); |
| 1009 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 1153 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 1154 | \\ _ = message; |
| | 1155 | \\ _ = stack_trace; |
| 1010 | \\ std.os.exit(126); | 1156 | \\ std.os.exit(126); |
| 1011 | \\} | 1157 | \\} |
| 1012 | \\ | 1158 | \\ |
| ... | @@ -1031,6 +1177,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -1031,6 +1177,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 1031 | cases.addRuntimeSafety("@intCast to u0", | 1177 | cases.addRuntimeSafety("@intCast to u0", |
| 1032 | \\const std = @import("std"); | 1178 | \\const std = @import("std"); |
| 1033 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 1179 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 1180 | \\ _ = message; |
| | 1181 | \\ _ = stack_trace; |
| 1034 | \\ std.os.exit(126); | 1182 | \\ std.os.exit(126); |
| 1035 | \\} | 1183 | \\} |
| 1036 | \\ | 1184 | \\ |
| ... | @@ -1040,6 +1188,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -1040,6 +1188,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 1040 | \\ | 1188 | \\ |
| 1041 | \\fn bar(one: u1, not_zero: i32) void { | 1189 | \\fn bar(one: u1, not_zero: i32) void { |
| 1042 | \\ var x = one << @intCast(u0, not_zero); | 1190 | \\ var x = one << @intCast(u0, not_zero); |
| | 1191 | \\ _ = x; |
| 1043 | \\} | 1192 | \\} |
| 1044 | ); | 1193 | ); |
| 1045 | | 1194 | |
| ... | @@ -1049,6 +1198,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -1049,6 +1198,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 1049 | \\const std = @import("std"); | 1198 | \\const std = @import("std"); |
| 1050 | \\ | 1199 | \\ |
| 1051 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 1200 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 1201 | \\ _ = message; |
| | 1202 | \\ _ = stack_trace; |
| 1052 | \\ std.os.exit(126); | 1203 | \\ std.os.exit(126); |
| 1053 | \\} | 1204 | \\} |
| 1054 | \\ | 1205 | \\ |
| ... | @@ -1058,6 +1209,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -1058,6 +1209,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 1058 | \\ const p = nonFailing(); | 1209 | \\ const p = nonFailing(); |
| 1059 | \\ resume p; | 1210 | \\ resume p; |
| 1060 | \\ const p2 = async printTrace(p); | 1211 | \\ const p2 = async printTrace(p); |
| | 1212 | \\ _ = p2; |
| 1061 | \\} | 1213 | \\} |
| 1062 | \\ | 1214 | \\ |
| 1063 | \\fn nonFailing() anyframe->anyerror!void { | 1215 | \\fn nonFailing() anyframe->anyerror!void { |
| ... | @@ -1084,12 +1236,15 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -1084,12 +1236,15 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 1084 | cases.addRuntimeSafety("slicing null C pointer", | 1236 | cases.addRuntimeSafety("slicing null C pointer", |
| 1085 | \\const std = @import("std"); | 1237 | \\const std = @import("std"); |
| 1086 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | 1238 | \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| | 1239 | \\ _ = message; |
| | 1240 | \\ _ = stack_trace; |
| 1087 | \\ std.os.exit(126); | 1241 | \\ std.os.exit(126); |
| 1088 | \\} | 1242 | \\} |
| 1089 | \\ | 1243 | \\ |
| 1090 | \\pub fn main() void { | 1244 | \\pub fn main() void { |
| 1091 | \\ var ptr: [*c]const u32 = null; | 1245 | \\ var ptr: [*c]const u32 = null; |
| 1092 | \\ var slice = ptr[0..3]; | 1246 | \\ var slice = ptr[0..3]; |
| | 1247 | \\ _ = slice; |
| 1093 | \\} | 1248 | \\} |
| 1094 | ); | 1249 | ); |
| 1095 | } | 1250 | } |