Allow using -C force-unwind-tables=no when panic=unwind
This commit is contained in:
parent
58f32da346
commit
2fd4dd20d7
7 changed files with 74 additions and 27 deletions
8
src/test/assembly/panic-no-unwind-no-uwtable.rs
Normal file
8
src/test/assembly/panic-no-unwind-no-uwtable.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// assembly-output: emit-asm
|
||||
// only-x86_64-unknown-linux-gnu
|
||||
// compile-flags: -C panic=unwind -C force-unwind-tables=n -O
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
||||
// CHECK-NOT: .cfi_startproc
|
||||
pub fn foo() {}
|
||||
12
src/test/assembly/panic-unwind-no-uwtable.rs
Normal file
12
src/test/assembly/panic-unwind-no-uwtable.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// assembly-output: emit-asm
|
||||
// only-x86_64-unknown-linux-gnu
|
||||
// compile-flags: -C panic=unwind -C force-unwind-tables=n
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
||||
// CHECK-LABEL: foo:
|
||||
// CHECK: .cfi_startproc
|
||||
#[no_mangle]
|
||||
fn foo() {
|
||||
panic!();
|
||||
}
|
||||
|
|
@ -3,5 +3,9 @@
|
|||
|
||||
#![crate_type="lib"]
|
||||
|
||||
// CHECK-LABEL: define{{.*}}void @foo
|
||||
// CHECK-NOT: attributes #{{.*}} uwtable
|
||||
pub fn foo() {}
|
||||
#[no_mangle]
|
||||
fn foo() {
|
||||
panic!();
|
||||
}
|
||||
|
|
|
|||
6
src/test/codegen/panic-unwind-default-uwtable.rs
Normal file
6
src/test/codegen/panic-unwind-default-uwtable.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// compile-flags: -C panic=unwind -C no-prepopulate-passes
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
||||
// CHECK: attributes #{{.*}} uwtable
|
||||
pub fn foo() {}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
// Tests that the compiler errors if the user tries to turn off unwind tables
|
||||
// when they are required.
|
||||
//
|
||||
// dont-check-compiler-stderr
|
||||
// compile-flags: -C panic=unwind -C force-unwind-tables=no
|
||||
//
|
||||
// error-pattern: panic=unwind requires unwind tables, they cannot be disabled with `-C force-unwind-tables=no`.
|
||||
|
||||
pub fn main() {
|
||||
}
|
||||
34
src/test/ui/unwind-no-uwtable.rs
Normal file
34
src/test/ui/unwind-no-uwtable.rs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
// run-pass
|
||||
// ignore-windows target requires uwtable
|
||||
// ignore-wasm32-bare no proper panic=unwind support
|
||||
// compile-flags: -C panic=unwind -C force-unwind-tables=n
|
||||
|
||||
use std::panic::{self, AssertUnwindSafe};
|
||||
|
||||
struct Increase<'a>(&'a mut u8);
|
||||
|
||||
impl Drop for Increase<'_> {
|
||||
fn drop(&mut self) {
|
||||
*self.0 += 1;
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
fn unwind() {
|
||||
panic!();
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
fn increase(count: &mut u8) {
|
||||
let _increase = Increase(count);
|
||||
unwind();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut count = 0;
|
||||
assert!(panic::catch_unwind(AssertUnwindSafe(
|
||||
#[inline(never)]
|
||||
|| increase(&mut count)
|
||||
)).is_err());
|
||||
assert_eq!(count, 1);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue