mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
unreachable still codegens to unreachable in ReleaseFast test mode
closes #430
This commit is contained in:
parent
5dddb45ec7
commit
629aa10c56
@ -1879,7 +1879,7 @@ static LLVMValueRef ir_render_err_to_int(CodeGen *g, IrExecutable *executable, I
|
||||
static LLVMValueRef ir_render_unreachable(CodeGen *g, IrExecutable *executable,
|
||||
IrInstructionUnreachable *unreachable_instruction)
|
||||
{
|
||||
if (ir_want_debug_safety(g, &unreachable_instruction->base) || g->is_test_build) {
|
||||
if (ir_want_debug_safety(g, &unreachable_instruction->base)) {
|
||||
gen_debug_safety_crash(g, PanicMsgIdUnreachable);
|
||||
} else {
|
||||
LLVMBuildUnreachable(g->builder);
|
||||
|
||||
@ -12,7 +12,15 @@ error InvalidDebugInfo;
|
||||
error UnsupportedDebugInfo;
|
||||
|
||||
pub fn assert(ok: bool) {
|
||||
if (!ok) unreachable // assertion failure
|
||||
if (!ok) {
|
||||
// In ReleaseFast test mode, we still want assert(false) to crash, so
|
||||
// we insert an explicit call to @panic instead of unreachable.
|
||||
if (builtin.is_test) {
|
||||
@panic("assertion failure")
|
||||
} else {
|
||||
unreachable // assertion failure
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var panicking = false;
|
||||
|
||||
@ -17,6 +17,7 @@ comptime {
|
||||
|
||||
const builtin = @import("builtin");
|
||||
const is_test = builtin.is_test;
|
||||
const assert = @import("../../debug.zig").assert;
|
||||
|
||||
const __udivmoddi4 = @import("udivmoddi4.zig").__udivmoddi4;
|
||||
|
||||
@ -292,8 +293,3 @@ fn test_one_udivsi3(a: u32, b: u32, expected_q: u32) {
|
||||
const q: u32 = __udivsi3(a, b);
|
||||
assert(q == expected_q);
|
||||
}
|
||||
|
||||
|
||||
fn assert(ok: bool) {
|
||||
if (!ok) unreachable;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user