about summary refs log tree commit diff
path: root/src/test/ui/asm/inline-syntax.rs
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2021-03-18 00:28:06 +0100
committerGitHub <noreply@github.com>2021-03-18 00:28:06 +0100
commit16f6583f2d95b53610ee10073752e883dbfa24ea (patch)
treec1fef8dfd813219bdb24cf68103623a9b9a5e110 /src/test/ui/asm/inline-syntax.rs
parent90797ef008a2004e70ff0106c756f24ea63ab236 (diff)
parent4b13b8120e67e2b3173c8f6ce0d175847b745085 (diff)
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
Diffstat (limited to 'src/test/ui/asm/inline-syntax.rs')
-rw-r--r--src/test/ui/asm/inline-syntax.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/test/ui/asm/inline-syntax.rs b/src/test/ui/asm/inline-syntax.rs
new file mode 100644
index 00000000000..9e9c7badfca
--- /dev/null
+++ b/src/test/ui/asm/inline-syntax.rs
@@ -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
+    }
+}