forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
disallow
naked_asm!
outside of #[naked]
functions
- Loading branch information
1 parent
26b2b8d
commit 6ca5ec7
Showing
11 changed files
with
132 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]` | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
error: the `naked_asm!` macro can only be used in functions marked with `#[naked]` | ||
--> $DIR/naked-asm-outside-naked-fn.rs:21:14 | ||
| | ||
LL | unsafe { naked_asm!("") } | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: the `naked_asm!` macro can only be used in functions marked with `#[naked]` | ||
--> $DIR/naked-asm-outside-naked-fn.rs:26:18 | ||
| | ||
LL | unsafe { (|| naked_asm!(""))() } | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: the `naked_asm!` macro can only be used in functions marked with `#[naked]` | ||
--> $DIR/naked-asm-outside-naked-fn.rs:32:19 | ||
| | ||
LL | unsafe { naked_asm!("") } ; | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|