mirror of
https://github.com/ziglang/zig.git
synced 2026-02-17 06:49:23 +00:00
parent
ad9040443c
commit
0f633167c5
@ -668,6 +668,7 @@ static LLVMValueRef get_safety_crash_err_fn(CodeGen *g) {
|
||||
|
||||
g->generate_error_name_table = true;
|
||||
generate_error_name_table(g);
|
||||
assert(g->err_name_table != nullptr);
|
||||
|
||||
size_t unwrap_err_msg_text_len = strlen(unwrap_err_msg_text);
|
||||
size_t err_buf_len = strlen(unwrap_err_msg_text) + g->largest_err_name_len;
|
||||
@ -755,7 +756,6 @@ static void gen_debug_safety_crash_for_err(CodeGen *g, LLVMValueRef err_val) {
|
||||
LLVMValueRef safety_crash_err_fn = get_safety_crash_err_fn(g);
|
||||
LLVMBuildCall(g->builder, safety_crash_err_fn, &err_val, 1, "");
|
||||
LLVMBuildUnreachable(g->builder);
|
||||
|
||||
}
|
||||
|
||||
static void add_bounds_check(CodeGen *g, LLVMValueRef target_val,
|
||||
@ -2649,7 +2649,7 @@ static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, IrExecutable *execu
|
||||
LLVMValueRef err_union_ptr = ir_llvm_value(g, instruction->value);
|
||||
LLVMValueRef err_union_handle = get_handle_value(g, err_union_ptr, err_union_type, is_volatile);
|
||||
|
||||
if (ir_want_debug_safety(g, &instruction->base) && instruction->safety_check_on) {
|
||||
if (ir_want_debug_safety(g, &instruction->base) && instruction->safety_check_on && g->error_decls.length > 1) {
|
||||
LLVMValueRef err_val;
|
||||
if (type_has_bits(child_type)) {
|
||||
LLVMValueRef err_val_ptr = LLVMBuildStructGEP(g->builder, err_union_handle, err_union_err_index, "");
|
||||
|
||||
@ -7,4 +7,5 @@ pub fn addCases(cases: &tests.BuildExamplesContext) {
|
||||
cases.add("example/guess_number/main.zig");
|
||||
cases.addBuildFile("example/shared_library/build.zig");
|
||||
cases.addBuildFile("example/mix_o_files/build.zig");
|
||||
cases.addBuildFile("test/standalone/issue_339/build.zig");
|
||||
}
|
||||
|
||||
8
test/standalone/issue_339/build.zig
Normal file
8
test/standalone/issue_339/build.zig
Normal file
@ -0,0 +1,8 @@
|
||||
const Builder = @import("std").build.Builder;
|
||||
|
||||
pub fn build(b: &Builder) {
|
||||
const obj = b.addObject("test", "test.zig");
|
||||
|
||||
const test_step = b.step("test", "Test the program");
|
||||
test_step.dependOn(&obj.step);
|
||||
}
|
||||
7
test/standalone/issue_339/test.zig
Normal file
7
test/standalone/issue_339/test.zig
Normal file
@ -0,0 +1,7 @@
|
||||
pub fn panic(msg: []const u8) -> noreturn { @breakpoint(); while (true) {} }
|
||||
|
||||
fn bar() -> %void {}
|
||||
|
||||
export fn foo() {
|
||||
%%bar();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user