fix inline asm test by not hardcoding symbol names

This commit is contained in:
cynecx 2021-11-28 21:52:27 +01:00
parent 7f870be4b5
commit 233dede5b6
2 changed files with 18 additions and 6 deletions

View File

@ -3,7 +3,7 @@
// run-pass
// needs-asm-support
#![feature(asm, asm_unwind)]
#![feature(asm, asm_sym, asm_unwind)]
use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe};
@ -15,7 +15,6 @@ fn drop(&mut self) {
}
}
#[no_mangle]
extern "C" fn panicky() {
resume_unwind(Box::new(()));
}
@ -24,7 +23,14 @@ fn main() {
let flag = &mut true;
catch_unwind(AssertUnwindSafe(|| {
let _foo = Foo(flag);
unsafe { asm!("bl _panicky", clobber_abi("C"), options(may_unwind)) };
unsafe {
asm!(
"bl {}",
sym panicky,
clobber_abi("C"),
options(may_unwind)
);
}
}))
.expect_err("expected a panic");
assert_eq!(*flag, false);

View File

@ -3,7 +3,7 @@
// run-pass
// needs-asm-support
#![feature(asm, asm_unwind)]
#![feature(asm, asm_sym, asm_unwind)]
use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe};
@ -15,7 +15,6 @@ fn drop(&mut self) {
}
}
#[no_mangle]
extern "C" fn panicky() {
resume_unwind(Box::new(()));
}
@ -24,7 +23,14 @@ fn main() {
let flag = &mut true;
catch_unwind(AssertUnwindSafe(|| {
let _foo = Foo(flag);
unsafe { asm!("call panicky", clobber_abi("C"), options(may_unwind)) };
unsafe {
asm!(
"call {}",
sym panicky,
clobber_abi("C"),
options(may_unwind)
);
}
}))
.expect_err("expected a panic");
assert_eq!(*flag, false);