about summary refs log tree commit diff
path: root/tests/ui/asm/cfg-parse-error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/asm/cfg-parse-error.rs')
-rw-r--r--tests/ui/asm/cfg-parse-error.rs56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/ui/asm/cfg-parse-error.rs b/tests/ui/asm/cfg-parse-error.rs
new file mode 100644
index 00000000000..c66a627ca94
--- /dev/null
+++ b/tests/ui/asm/cfg-parse-error.rs
@@ -0,0 +1,56 @@
+//@ needs-asm-support
+#![feature(asm_cfg)]
+
+use std::arch::asm;
+
+fn main() {
+    unsafe {
+        asm!(
+            "",
+            #[cfg(false)]
+            clobber_abi("C"),
+            #[cfg(false)]
+            options(att_syntax),
+            #[cfg(false)]
+            a = out(reg) x,
+            "",
+            //~^ ERROR expected one of `clobber_abi`, `const`
+        );
+        asm!(
+            #[cfg(false)]
+            "",
+            #[cfg(false)]
+            const {
+                5
+            },
+            "", //~ ERROR expected one of `clobber_abi`, `const`
+        );
+
+        asm!(
+            #[cfg_attr(true, cfg(false))]
+            const {
+                5
+            },
+            "",
+        );
+
+        // This is not accepted because `a = out(reg) x` is not a valid expression.
+        asm!(
+            #[cfg(false)]
+            a = out(reg) x, //~ ERROR expected token: `,`
+            "",
+        );
+
+        // For now, any non-cfg attributes are rejected
+        asm!(
+            #[rustfmt::skip] //~ ERROR this attribute is not supported on assembly
+            "",
+        );
+
+        // For now, any non-cfg attributes are rejected
+        asm!(
+            #![rustfmt::skip] //~ ERROR an inner attribute is not permitted in this context
+            "",
+        );
+    }
+}