Skip to content

Commit

Permalink
Add test case for foreign Rust exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdd0121 committed Oct 7, 2022
1 parent 6930869 commit eb4caf1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/test/run-make-fulldeps/foreign-rust-exceptions/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include ../tools.mk

all:
$(RUSTC) bar.rs --crate-type=cdylib
$(RUSTC) foo.rs
$(call RUN,foo) 2>&1 | $(CGREP) "Rust cannot catch foreign exceptions"
7 changes: 7 additions & 0 deletions src/test/run-make-fulldeps/foreign-rust-exceptions/bar.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#![crate_type = "cdylib"]
#![feature(c_unwind)]

#[no_mangle]
extern "C-unwind" fn panic() {
panic!();
}
12 changes: 12 additions & 0 deletions src/test/run-make-fulldeps/foreign-rust-exceptions/foo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![feature(c_unwind)]

#[link(name = "bar")]
extern "C-unwind" {
fn panic();
}

fn main() {
let _ = std::panic::catch_unwind(|| {
unsafe { panic() };
});
}

0 comments on commit eb4caf1

Please sign in to comment.