Forbid asm unwind to work with labels
This commit is contained in:
parent
5e4e3d790b
commit
31f078ea99
3 changed files with 16 additions and 0 deletions
|
@ -19,6 +19,8 @@ builtin_macros_asm_expected_other = expected operand, {$is_global_asm ->
|
||||||
|
|
||||||
builtin_macros_asm_explicit_register_name = explicit register arguments cannot have names
|
builtin_macros_asm_explicit_register_name = explicit register arguments cannot have names
|
||||||
|
|
||||||
|
builtin_macros_asm_mayunwind = asm labels are not allowed with the `may_unwind` option
|
||||||
|
|
||||||
builtin_macros_asm_modifier_invalid = asm template modifier must be a single character
|
builtin_macros_asm_modifier_invalid = asm template modifier must be a single character
|
||||||
|
|
||||||
builtin_macros_asm_mutually_exclusive = the `{$opt1}` and `{$opt2}` options are mutually exclusive
|
builtin_macros_asm_mutually_exclusive = the `{$opt1}` and `{$opt2}` options are mutually exclusive
|
||||||
|
|
|
@ -245,6 +245,7 @@ pub fn parse_asm_args<'a>(
|
||||||
let mut have_real_output = false;
|
let mut have_real_output = false;
|
||||||
let mut outputs_sp = vec![];
|
let mut outputs_sp = vec![];
|
||||||
let mut regclass_outputs = vec![];
|
let mut regclass_outputs = vec![];
|
||||||
|
let mut labels_sp = vec![];
|
||||||
for (op, op_sp) in &args.operands {
|
for (op, op_sp) in &args.operands {
|
||||||
match op {
|
match op {
|
||||||
ast::InlineAsmOperand::Out { reg, expr, .. }
|
ast::InlineAsmOperand::Out { reg, expr, .. }
|
||||||
|
@ -262,6 +263,9 @@ pub fn parse_asm_args<'a>(
|
||||||
regclass_outputs.push(*op_sp);
|
regclass_outputs.push(*op_sp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ast::InlineAsmOperand::Label { .. } => {
|
||||||
|
labels_sp.push(*op_sp);
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -273,6 +277,9 @@ pub fn parse_asm_args<'a>(
|
||||||
// Bail out now since this is likely to confuse MIR
|
// Bail out now since this is likely to confuse MIR
|
||||||
return Err(err);
|
return Err(err);
|
||||||
}
|
}
|
||||||
|
if args.options.contains(ast::InlineAsmOptions::MAY_UNWIND) && !labels_sp.is_empty() {
|
||||||
|
dcx.emit_err(errors::AsmMayUnwind { labels_sp });
|
||||||
|
}
|
||||||
|
|
||||||
if args.clobber_abis.len() > 0 {
|
if args.clobber_abis.len() > 0 {
|
||||||
if is_global_asm {
|
if is_global_asm {
|
||||||
|
|
|
@ -787,6 +787,13 @@ pub(crate) struct AsmNoReturn {
|
||||||
pub(crate) outputs_sp: Vec<Span>,
|
pub(crate) outputs_sp: Vec<Span>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(builtin_macros_asm_mayunwind)]
|
||||||
|
pub(crate) struct AsmMayUnwind {
|
||||||
|
#[primary_span]
|
||||||
|
pub(crate) labels_sp: Vec<Span>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(builtin_macros_global_asm_clobber_abi)]
|
#[diag(builtin_macros_global_asm_clobber_abi)]
|
||||||
pub(crate) struct GlobalAsmClobberAbi {
|
pub(crate) struct GlobalAsmClobberAbi {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue