diff options
| author | bors <bors@rust-lang.org> | 2021-12-04 05:59:16 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-12-04 05:59:16 +0000 |
| commit | 887999d163bace7e79370b952bdd1f930ff4cdd5 (patch) | |
| tree | 0b2a5642dfe49a0cebe9744394169acebf412ccc /src/test/ui | |
| parent | f5815727786aa1ed2793af05cf65c5d79c290c67 (diff) | |
| parent | 3dbb621c72e57c7eee9c10f20316d76c59168f83 (diff) | |
Auto merge of #88439 - cynecx:unwind_asm, r=Amanieu
Unwinding support for inline assembly r? `@Amanieu`
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/asm/aarch64/bad-options.stderr | 24 | ||||
| -rw-r--r-- | src/test/ui/asm/aarch64/may_unwind.rs | 37 | ||||
| -rw-r--r-- | src/test/ui/asm/aarch64/parse-error.stderr | 20 | ||||
| -rw-r--r-- | src/test/ui/asm/may_unwind.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/asm/x86_64/bad-options.stderr | 24 | ||||
| -rw-r--r-- | src/test/ui/asm/x86_64/may_unwind.rs | 37 | ||||
| -rw-r--r-- | src/test/ui/asm/x86_64/parse-error.stderr | 20 | ||||
| -rw-r--r-- | src/test/ui/feature-gates/feature-gate-asm_unwind.rs | 10 | ||||
| -rw-r--r-- | src/test/ui/feature-gates/feature-gate-asm_unwind.stderr | 12 |
9 files changed, 149 insertions, 44 deletions
diff --git a/src/test/ui/asm/aarch64/bad-options.stderr b/src/test/ui/asm/aarch64/bad-options.stderr index 21bcc4a9c7b..867e0433eae 100644 --- a/src/test/ui/asm/aarch64/bad-options.stderr +++ b/src/test/ui/asm/aarch64/bad-options.stderr @@ -36,41 +36,41 @@ LL | asm!("{}", out(reg) foo, clobber_abi("C")); | | | generic outputs -error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` +error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `nomem` --> $DIR/bad-options.rs:28:25 | LL | global_asm!("", options(nomem)); - | ^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` -error: expected one of `)`, `att_syntax`, or `raw`, found `readonly` +error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `readonly` --> $DIR/bad-options.rs:30:25 | LL | global_asm!("", options(readonly)); - | ^^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` -error: expected one of `)`, `att_syntax`, or `raw`, found `noreturn` +error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `noreturn` --> $DIR/bad-options.rs:32:25 | LL | global_asm!("", options(noreturn)); - | ^^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` -error: expected one of `)`, `att_syntax`, or `raw`, found `pure` +error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `pure` --> $DIR/bad-options.rs:34:25 | LL | global_asm!("", options(pure)); - | ^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` -error: expected one of `)`, `att_syntax`, or `raw`, found `nostack` +error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `nostack` --> $DIR/bad-options.rs:36:25 | LL | global_asm!("", options(nostack)); - | ^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` -error: expected one of `)`, `att_syntax`, or `raw`, found `preserves_flags` +error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `preserves_flags` --> $DIR/bad-options.rs:38:25 | LL | global_asm!("", options(preserves_flags)); - | ^^^^^^^^^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^^^^^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` error: invalid ABI for `clobber_abi` --> $DIR/bad-options.rs:20:18 diff --git a/src/test/ui/asm/aarch64/may_unwind.rs b/src/test/ui/asm/aarch64/may_unwind.rs new file mode 100644 index 00000000000..94cc7d75049 --- /dev/null +++ b/src/test/ui/asm/aarch64/may_unwind.rs @@ -0,0 +1,37 @@ +// min-llvm-version: 13.0.0 +// only-aarch64 +// run-pass +// needs-asm-support + +#![feature(asm, asm_sym, asm_unwind)] + +use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe}; + +struct Foo<'a>(&'a mut bool); + +impl Drop for Foo<'_> { + fn drop(&mut self) { + *self.0 = false; + } +} + +extern "C" fn panicky() { + resume_unwind(Box::new(())); +} + +fn main() { + let flag = &mut true; + catch_unwind(AssertUnwindSafe(|| { + let _foo = Foo(flag); + unsafe { + asm!( + "bl {}", + sym panicky, + clobber_abi("C"), + options(may_unwind) + ); + } + })) + .expect_err("expected a panic"); + assert_eq!(*flag, false); +} diff --git a/src/test/ui/asm/aarch64/parse-error.stderr b/src/test/ui/asm/aarch64/parse-error.stderr index 3d88cef5c7d..a143c3b2b28 100644 --- a/src/test/ui/asm/aarch64/parse-error.stderr +++ b/src/test/ui/asm/aarch64/parse-error.stderr @@ -64,11 +64,11 @@ error: argument to `sym` must be a path expression LL | asm!("{}", sym foo + bar); | ^^^^^^^^^ -error: expected one of `)`, `att_syntax`, `nomem`, `noreturn`, `nostack`, `preserves_flags`, `pure`, `raw`, or `readonly`, found `foo` +error: expected one of `)`, `att_syntax`, `may_unwind`, `nomem`, `noreturn`, `nostack`, `preserves_flags`, `pure`, `raw`, or `readonly`, found `foo` --> $DIR/parse-error.rs:31:26 | LL | asm!("", options(foo)); - | ^^^ expected one of 9 possible tokens + | ^^^ expected one of 10 possible tokens error: expected one of `)` or `,`, found `foo` --> $DIR/parse-error.rs:33:32 @@ -76,11 +76,11 @@ error: expected one of `)` or `,`, found `foo` LL | asm!("", options(nomem foo)); | ^^^ expected one of `)` or `,` -error: expected one of `)`, `att_syntax`, `nomem`, `noreturn`, `nostack`, `preserves_flags`, `pure`, `raw`, or `readonly`, found `foo` +error: expected one of `)`, `att_syntax`, `may_unwind`, `nomem`, `noreturn`, `nostack`, `preserves_flags`, `pure`, `raw`, or `readonly`, found `foo` --> $DIR/parse-error.rs:35:33 | LL | asm!("", options(nomem, foo)); - | ^^^ expected one of 9 possible tokens + | ^^^ expected one of 10 possible tokens error: arguments are not allowed after options --> $DIR/parse-error.rs:37:31 @@ -260,23 +260,23 @@ error: expected one of `,`, `.`, `?`, or an operator, found `FOO` LL | global_asm!("{}", const(reg) FOO); | ^^^ expected one of `,`, `.`, `?`, or an operator -error: expected one of `)`, `att_syntax`, or `raw`, found `FOO` +error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `FOO` --> $DIR/parse-error.rs:100:25 | LL | global_asm!("", options(FOO)); - | ^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` -error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` +error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `nomem` --> $DIR/parse-error.rs:102:25 | LL | global_asm!("", options(nomem FOO)); - | ^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` -error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` +error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `nomem` --> $DIR/parse-error.rs:104:25 | LL | global_asm!("", options(nomem, FOO)); - | ^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` error: arguments are not allowed after options --> $DIR/parse-error.rs:106:30 diff --git a/src/test/ui/asm/may_unwind.rs b/src/test/ui/asm/may_unwind.rs new file mode 100644 index 00000000000..436e8b9d95a --- /dev/null +++ b/src/test/ui/asm/may_unwind.rs @@ -0,0 +1,9 @@ +// min-llvm-version: 13.0.0 +// run-pass +// needs-asm-support + +#![feature(asm, asm_unwind)] + +fn main() { + unsafe { asm!("", options(may_unwind)) }; +} diff --git a/src/test/ui/asm/x86_64/bad-options.stderr b/src/test/ui/asm/x86_64/bad-options.stderr index e2351840eef..a63c42aac27 100644 --- a/src/test/ui/asm/x86_64/bad-options.stderr +++ b/src/test/ui/asm/x86_64/bad-options.stderr @@ -45,41 +45,41 @@ LL | asm!("{}", out(reg) foo, clobber_abi("C"), clobber_abi("C")); | | clobber_abi | generic outputs -error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` +error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `nomem` --> $DIR/bad-options.rs:31:25 | LL | global_asm!("", options(nomem)); - | ^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` -error: expected one of `)`, `att_syntax`, or `raw`, found `readonly` +error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `readonly` --> $DIR/bad-options.rs:33:25 | LL | global_asm!("", options(readonly)); - | ^^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` -error: expected one of `)`, `att_syntax`, or `raw`, found `noreturn` +error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `noreturn` --> $DIR/bad-options.rs:35:25 | LL | global_asm!("", options(noreturn)); - | ^^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` -error: expected one of `)`, `att_syntax`, or `raw`, found `pure` +error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `pure` --> $DIR/bad-options.rs:37:25 | LL | global_asm!("", options(pure)); - | ^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` -error: expected one of `)`, `att_syntax`, or `raw`, found `nostack` +error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `nostack` --> $DIR/bad-options.rs:39:25 | LL | global_asm!("", options(nostack)); - | ^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` -error: expected one of `)`, `att_syntax`, or `raw`, found `preserves_flags` +error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `preserves_flags` --> $DIR/bad-options.rs:41:25 | LL | global_asm!("", options(preserves_flags)); - | ^^^^^^^^^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^^^^^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` error: invalid ABI for `clobber_abi` --> $DIR/bad-options.rs:20:18 diff --git a/src/test/ui/asm/x86_64/may_unwind.rs b/src/test/ui/asm/x86_64/may_unwind.rs new file mode 100644 index 00000000000..5ac4dd9b956 --- /dev/null +++ b/src/test/ui/asm/x86_64/may_unwind.rs @@ -0,0 +1,37 @@ +// min-llvm-version: 13.0.0 +// only-x86_64 +// run-pass +// needs-asm-support + +#![feature(asm, asm_sym, asm_unwind)] + +use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe}; + +struct Foo<'a>(&'a mut bool); + +impl Drop for Foo<'_> { + fn drop(&mut self) { + *self.0 = false; + } +} + +extern "C" fn panicky() { + resume_unwind(Box::new(())); +} + +fn main() { + let flag = &mut true; + catch_unwind(AssertUnwindSafe(|| { + let _foo = Foo(flag); + unsafe { + asm!( + "call {}", + sym panicky, + clobber_abi("C"), + options(may_unwind) + ); + } + })) + .expect_err("expected a panic"); + assert_eq!(*flag, false); +} diff --git a/src/test/ui/asm/x86_64/parse-error.stderr b/src/test/ui/asm/x86_64/parse-error.stderr index 018df9826c6..4f16c15af38 100644 --- a/src/test/ui/asm/x86_64/parse-error.stderr +++ b/src/test/ui/asm/x86_64/parse-error.stderr @@ -64,11 +64,11 @@ error: argument to `sym` must be a path expression LL | asm!("{}", sym foo + bar); | ^^^^^^^^^ -error: expected one of `)`, `att_syntax`, `nomem`, `noreturn`, `nostack`, `preserves_flags`, `pure`, `raw`, or `readonly`, found `foo` +error: expected one of `)`, `att_syntax`, `may_unwind`, `nomem`, `noreturn`, `nostack`, `preserves_flags`, `pure`, `raw`, or `readonly`, found `foo` --> $DIR/parse-error.rs:31:26 | LL | asm!("", options(foo)); - | ^^^ expected one of 9 possible tokens + | ^^^ expected one of 10 possible tokens error: expected one of `)` or `,`, found `foo` --> $DIR/parse-error.rs:33:32 @@ -76,11 +76,11 @@ error: expected one of `)` or `,`, found `foo` LL | asm!("", options(nomem foo)); | ^^^ expected one of `)` or `,` -error: expected one of `)`, `att_syntax`, `nomem`, `noreturn`, `nostack`, `preserves_flags`, `pure`, `raw`, or `readonly`, found `foo` +error: expected one of `)`, `att_syntax`, `may_unwind`, `nomem`, `noreturn`, `nostack`, `preserves_flags`, `pure`, `raw`, or `readonly`, found `foo` --> $DIR/parse-error.rs:35:33 | LL | asm!("", options(nomem, foo)); - | ^^^ expected one of 9 possible tokens + | ^^^ expected one of 10 possible tokens error: arguments are not allowed after options --> $DIR/parse-error.rs:37:31 @@ -266,23 +266,23 @@ error: expected one of `,`, `.`, `?`, or an operator, found `FOO` LL | global_asm!("{}", const(reg) FOO); | ^^^ expected one of `,`, `.`, `?`, or an operator -error: expected one of `)`, `att_syntax`, or `raw`, found `FOO` +error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `FOO` --> $DIR/parse-error.rs:102:25 | LL | global_asm!("", options(FOO)); - | ^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` -error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` +error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `nomem` --> $DIR/parse-error.rs:104:25 | LL | global_asm!("", options(nomem FOO)); - | ^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` -error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` +error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `nomem` --> $DIR/parse-error.rs:106:25 | LL | global_asm!("", options(nomem, FOO)); - | ^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` error: arguments are not allowed after options --> $DIR/parse-error.rs:108:30 diff --git a/src/test/ui/feature-gates/feature-gate-asm_unwind.rs b/src/test/ui/feature-gates/feature-gate-asm_unwind.rs new file mode 100644 index 00000000000..c9957ff91d5 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-asm_unwind.rs @@ -0,0 +1,10 @@ +// only-x86_64 + +#![feature(asm)] + +fn main() { + unsafe { + asm!("", options(may_unwind)); + //~^ ERROR the `may_unwind` option is unstable + } +} diff --git a/src/test/ui/feature-gates/feature-gate-asm_unwind.stderr b/src/test/ui/feature-gates/feature-gate-asm_unwind.stderr new file mode 100644 index 00000000000..6b5bf286e7b --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-asm_unwind.stderr @@ -0,0 +1,12 @@ +error[E0658]: the `may_unwind` option is unstable + --> $DIR/feature-gate-asm_unwind.rs:7:9 + | +LL | asm!("", options(may_unwind)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #72016 <https://github.com/rust-lang/rust/issues/72016> for more information + = help: add `#![feature(asm_unwind)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. |
