1
Fork 0

disallow naked_asm! outside of #[naked] functions

This commit is contained in:
Folkert de Vries 2024-09-10 14:42:17 +02:00
parent 26b2b8d162
commit 6ca5ec7b4e
11 changed files with 132 additions and 16 deletions

View 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]`
};
}