Rollup merge of #82270 - asquared31415:asm-syntax-directive-errors, r=nagisa
Emit error when trying to use assembler syntax directives in `asm!` The `.intel_syntax` and `.att_syntax` assembler directives should not be used, in favor of not specifying a syntax for intel, and in favor of the explicit `att_syntax` option using the inline assembly options. Closes #79869
This commit is contained in:
commit
16f6583f2d
5 changed files with 181 additions and 1 deletions
14
src/test/ui/asm/inline-syntax.arm.stderr
Normal file
14
src/test/ui/asm/inline-syntax.arm.stderr
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
error: att syntax is the default syntax on this target, and trying to use this directive may cause issues
|
||||
--> $DIR/inline-syntax.rs:22:15
|
||||
|
|
||||
LL | asm!(".att_syntax noprefix", "nop");
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive
|
||||
|
||||
error: att syntax is the default syntax on this target, and trying to use this directive may cause issues
|
||||
--> $DIR/inline-syntax.rs:25:15
|
||||
|
|
||||
LL | asm!(".att_syntax bbb noprefix", "nop");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
38
src/test/ui/asm/inline-syntax.rs
Normal file
38
src/test/ui/asm/inline-syntax.rs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
// revisions: x86_64 arm
|
||||
//[x86_64] compile-flags: --target x86_64-unknown-linux-gnu
|
||||
//[arm] compile-flags: --target armv7-unknown-linux-gnueabihf
|
||||
|
||||
#![feature(no_core, lang_items, rustc_attrs)]
|
||||
#![no_core]
|
||||
|
||||
#[rustc_builtin_macro]
|
||||
macro_rules! asm {
|
||||
() => {};
|
||||
}
|
||||
|
||||
#[lang = "sized"]
|
||||
trait Sized {}
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
asm!(".intel_syntax noprefix", "nop");
|
||||
//[x86_64]~^ ERROR intel syntax is the default syntax on this target
|
||||
asm!(".intel_syntax aaa noprefix", "nop");
|
||||
//[x86_64]~^ ERROR intel syntax is the default syntax on this target
|
||||
asm!(".att_syntax noprefix", "nop");
|
||||
//[x86_64]~^ ERROR using the .att_syntax directive may cause issues
|
||||
//[arm]~^^ att syntax is the default syntax on this target
|
||||
asm!(".att_syntax bbb noprefix", "nop");
|
||||
//[x86_64]~^ ERROR using the .att_syntax directive may cause issues
|
||||
//[arm]~^^ att syntax is the default syntax on this target
|
||||
asm!(".intel_syntax noprefix; nop");
|
||||
//[x86_64]~^ ERROR intel syntax is the default syntax on this target
|
||||
|
||||
asm!(
|
||||
r"
|
||||
.intel_syntax noprefix
|
||||
nop"
|
||||
);
|
||||
//[x86_64]~^^^ ERROR intel syntax is the default syntax on this target
|
||||
}
|
||||
}
|
||||
50
src/test/ui/asm/inline-syntax.x86_64.stderr
Normal file
50
src/test/ui/asm/inline-syntax.x86_64.stderr
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
error: intel syntax is the default syntax on this target, and trying to use this directive may cause issues
|
||||
--> $DIR/inline-syntax.rs:18:15
|
||||
|
|
||||
LL | asm!(".intel_syntax noprefix", "nop");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive
|
||||
|
||||
error: intel syntax is the default syntax on this target, and trying to use this directive may cause issues
|
||||
--> $DIR/inline-syntax.rs:20:15
|
||||
|
|
||||
LL | asm!(".intel_syntax aaa noprefix", "nop");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive
|
||||
|
||||
error: using the .att_syntax directive may cause issues, use the att_syntax option instead
|
||||
--> $DIR/inline-syntax.rs:22:15
|
||||
|
|
||||
LL | asm!(".att_syntax noprefix", "nop");
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: remove the assembler directive and replace it with options(att_syntax)
|
||||
|
|
||||
LL | asm!("", "nop", options(att_syntax));
|
||||
| -- ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: using the .att_syntax directive may cause issues, use the att_syntax option instead
|
||||
--> $DIR/inline-syntax.rs:25:15
|
||||
|
|
||||
LL | asm!(".att_syntax bbb noprefix", "nop");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: remove the assembler directive and replace it with options(att_syntax)
|
||||
|
|
||||
LL | asm!("", "nop", options(att_syntax));
|
||||
| -- ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: intel syntax is the default syntax on this target, and trying to use this directive may cause issues
|
||||
--> $DIR/inline-syntax.rs:28:15
|
||||
|
|
||||
LL | asm!(".intel_syntax noprefix; nop");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive
|
||||
|
||||
error: intel syntax is the default syntax on this target, and trying to use this directive may cause issues
|
||||
--> $DIR/inline-syntax.rs:33:14
|
||||
|
|
||||
LL | .intel_syntax noprefix
|
||||
| ______________^
|
||||
LL | | nop"
|
||||
| |_ help: remove this assembler directive
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue