disallow naked_asm!
outside of #[naked]
functions
This commit is contained in:
parent
26b2b8d162
commit
6ca5ec7b4e
11 changed files with 132 additions and 16 deletions
35
tests/ui/asm/naked-asm-outside-naked-fn.rs
Normal file
35
tests/ui/asm/naked-asm-outside-naked-fn.rs
Normal file
|
@ -0,0 +1,35 @@
|
|||
//@ edition: 2021
|
||||
//@ needs-asm-support
|
||||
//@ ignore-nvptx64
|
||||
//@ ignore-spirv
|
||||
|
||||
#![feature(naked_functions)]
|
||||
#![crate_type = "lib"]
|
||||
|
||||
use std::arch::naked_asm;
|
||||
|
||||
fn main() {
|
||||
test1();
|
||||
}
|
||||
|
||||
#[naked]
|
||||
extern "C" fn test1() {
|
||||
unsafe { naked_asm!("") }
|
||||
}
|
||||
|
||||
extern "C" fn test2() {
|
||||
unsafe { naked_asm!("") }
|
||||
//~^ ERROR the `naked_asm!` macro can only be used in functions marked with `#[naked]`
|
||||
}
|
||||
|
||||
extern "C" fn test3() {
|
||||
unsafe { (|| naked_asm!(""))() }
|
||||
//~^ ERROR the `naked_asm!` macro can only be used in functions marked with `#[naked]`
|
||||
}
|
||||
|
||||
fn test4() {
|
||||
async move {
|
||||
unsafe { naked_asm!("") } ;
|
||||
//~^ ERROR the `naked_asm!` macro can only be used in functions marked with `#[naked]`
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue