forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#65346 - RalfJung:nounwind-tests, r=nagisa
nounwind tests and cleanup This is a follow-up to @pnkfelix' rust-lang#65020. In particular it adds some tests as @nagisa asked. It also does a cleanup that the original PR omitted to reduce backporting risks. I hope I finally managed to write an uncontroversial PR in this area. ;) This should not change any behavior, just test it better.
- Loading branch information
Showing
5 changed files
with
63 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// compile-flags: -C opt-level=0 | ||
|
||
#![crate_type = "lib"] | ||
#![feature(unwind_attributes)] | ||
|
||
// Make sure these all do *not* get the attribute. | ||
// We disable optimizations to prevent LLVM from infering the attribute. | ||
// CHECK-NOT: nounwind | ||
|
||
// "C" ABI | ||
// pub extern fn foo() {} // FIXME right now we don't abort-on-panic but add `nounwind` nevertheless | ||
#[unwind(allowed)] | ||
pub extern fn foo_allowed() {} | ||
|
||
// "Rust" | ||
// (`extern "Rust"` could be removed as all `fn` get it implicitly; we leave it in for clarity.) | ||
pub extern "Rust" fn bar() {} | ||
#[unwind(allowed)] | ||
pub extern "Rust" fn bar_allowed() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// compile-flags: -C no-prepopulate-passes | ||
|
||
#![crate_type = "lib"] | ||
#![feature(unwind_attributes)] | ||
|
||
extern { | ||
// CHECK: Function Attrs:{{.*}}nounwind | ||
// CHECK-NEXT: declare void @extern_fn | ||
fn extern_fn(); | ||
// CHECK-NOT: Function Attrs:{{.*}}nounwind | ||
// CHECK: declare void @unwinding_extern_fn | ||
#[unwind(allowed)] | ||
fn unwinding_extern_fn(); | ||
// CHECK-NOT: nounwind | ||
// CHECK: declare void @aborting_extern_fn | ||
#[unwind(aborts)] | ||
fn aborting_extern_fn(); // FIXME: we want to have the attribute here | ||
} | ||
|
||
extern "Rust" { | ||
// CHECK-NOT: nounwind | ||
// CHECK: declare void @rust_extern_fn | ||
fn rust_extern_fn(); | ||
// CHECK-NOT: nounwind | ||
// CHECK: declare void @rust_unwinding_extern_fn | ||
#[unwind(allowed)] | ||
fn rust_unwinding_extern_fn(); | ||
// CHECK-NOT: nounwind | ||
// CHECK: declare void @rust_aborting_extern_fn | ||
#[unwind(aborts)] | ||
fn rust_aborting_extern_fn(); // FIXME: we want to have the attribute here | ||
} | ||
|
||
pub unsafe fn force_declare() { | ||
extern_fn(); | ||
unwinding_extern_fn(); | ||
aborting_extern_fn(); | ||
rust_extern_fn(); | ||
rust_unwinding_extern_fn(); | ||
rust_aborting_extern_fn(); | ||
} |