aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2023-08-13 09:54:58 +0100
committerAndrew Kelley <andrew@ziglang.org>2023-08-14 11:43:21 -0700
commit8f3ccbbe367bea66d7f0f364a957870eb2cc95a0 (patch)
tree33dad0b953904d39e75490b05f414bdbc09869bb /test
parent1054e67f01e0f2eff1adf4982189ebba0a3696ab (diff)
downloadzig-8f3ccbbe367bea66d7f0f364a957870eb2cc95a0.tar.gz
zig-8f3ccbbe367bea66d7f0f364a957870eb2cc95a0.zip
Sema: provide source location when analyzing panic handler
The panic handler decl_val was previously given a `unneeded` source location, which was then added to the reference trace, resulting in a crash if the source location was used in the reference trace. This commit makes two trivial changes: * Don't add unneeded source locations to the ref table (panic in debug, silently ignore in release) * Pass a real source location when analyzing the panic handler
Diffstat (limited to 'test')
-rw-r--r--test/cases/compile_errors/panic_has_source_location.zig17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/cases/compile_errors/panic_has_source_location.zig b/test/cases/compile_errors/panic_has_source_location.zig
new file mode 100644
index 0000000000..6e9d16d76d
--- /dev/null
+++ b/test/cases/compile_errors/panic_has_source_location.zig
@@ -0,0 +1,17 @@
+const std = @import("std");
+
+export fn foo() void {
+ // This should appear in the reference trace
+ // (and definitely shouldn't crash due to an unneeded source location!)
+ @panic("oh no");
+}
+
+pub fn panic(_: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn {
+ @compileError("panic");
+}
+
+// error
+// backend=stage2
+// target=native
+//
+// :10:5: error: panic