disallow asm! in #[naked] functions
also disallow the `noreturn` option, and infer `naked_asm!` as `!`
This commit is contained in:
@@ -2278,7 +2278,7 @@ impl InlineAsmOptions {
|
||||
pub const COUNT: usize = Self::all().bits().count_ones() as usize;
|
||||
|
||||
pub const GLOBAL_OPTIONS: Self = Self::ATT_SYNTAX.union(Self::RAW);
|
||||
pub const NAKED_OPTIONS: Self = Self::ATT_SYNTAX.union(Self::RAW).union(Self::NORETURN);
|
||||
pub const NAKED_OPTIONS: Self = Self::ATT_SYNTAX.union(Self::RAW);
|
||||
|
||||
pub fn human_readable_names(&self) -> Vec<&'static str> {
|
||||
let mut options = vec![];
|
||||
@@ -2434,6 +2434,24 @@ pub enum AsmMacro {
|
||||
NakedAsm,
|
||||
}
|
||||
|
||||
impl AsmMacro {
|
||||
pub const fn macro_name(&self) -> &'static str {
|
||||
match self {
|
||||
AsmMacro::Asm => "asm",
|
||||
AsmMacro::GlobalAsm => "global_asm",
|
||||
AsmMacro::NakedAsm => "naked_asm",
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn is_supported_option(&self, option: InlineAsmOptions) -> bool {
|
||||
match self {
|
||||
AsmMacro::Asm => true,
|
||||
AsmMacro::GlobalAsm => InlineAsmOptions::GLOBAL_OPTIONS.contains(option),
|
||||
AsmMacro::NakedAsm => InlineAsmOptions::NAKED_OPTIONS.contains(option),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Inline assembly.
|
||||
///
|
||||
/// E.g., `asm!("NOP");`.
|
||||
|
||||
Reference in New Issue
Block a user