forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#130195 - folkertdev:naked-asm-outside-naked-f…
…n, r=<try> disallow `naked_asm!` outside of `#[naked]` functions tracking issue: rust-lang#90957 parent PR: rust-lang#128651 I split this out from the parent PR because it's self-contained and because the analysis has to search through all functions and there might be performance regressions. r? `@Amanieu`
- Loading branch information
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 | ||
|