about summary refs log tree commit diff
path: root/src/test/ui/asm/parse-error.rs
diff options
context:
space:
mode:
authorAmanieu d'Antras <amanieu@gmail.com>2020-02-20 09:19:48 +0000
committerAmanieu d'Antras <amanieu@gmail.com>2020-05-18 14:41:32 +0100
commit8ab0f2d3c5a85563b98c4896116e3d53154fff9c (patch)
tree9e4ac5efac12844c17ec1a89ff05bcb539a0d6c0 /src/test/ui/asm/parse-error.rs
parentabed45ff9fa3e68f2a32ca12e012f95b9153f4df (diff)
downloadrust-8ab0f2d3c5a85563b98c4896116e3d53154fff9c.tar.gz
rust-8ab0f2d3c5a85563b98c4896116e3d53154fff9c.zip
Add tests for asm!
Diffstat (limited to 'src/test/ui/asm/parse-error.rs')
-rw-r--r--src/test/ui/asm/parse-error.rs53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/test/ui/asm/parse-error.rs b/src/test/ui/asm/parse-error.rs
new file mode 100644
index 00000000000..e6566866b22
--- /dev/null
+++ b/src/test/ui/asm/parse-error.rs
@@ -0,0 +1,53 @@
+// only-x86_64
+
+#![feature(asm)]
+
+fn main() {
+    let mut foo = 0;
+    let mut bar = 0;
+    unsafe {
+        asm!();
+        //~^ ERROR requires at least a template string argument
+        asm!(foo);
+        //~^ ERROR asm template must be a string literal
+        asm!("{}" foo);
+        //~^ ERROR expected token: `,`
+        asm!("{}", foo);
+        //~^ ERROR expected one of
+        asm!("{}", in foo);
+        //~^ ERROR expected `(`, found `foo`
+        asm!("{}", in(reg foo));
+        //~^ ERROR expected `)`, found `foo`
+        asm!("{}", in(reg));
+        //~^ ERROR expected expression, found end of macro arguments
+        asm!("{}", inout(=) foo => bar);
+        //~^ ERROR expected register class or explicit register
+        asm!("{}", inout(reg) foo =>);
+        //~^ ERROR expected expression, found end of macro arguments
+        asm!("{}", in(reg) foo => bar);
+        //~^ ERROR expected one of `!`, `,`, `.`, `::`, `?`, `{`, or an operator, found `=>`
+        asm!("{}", sym foo + bar);
+        //~^ ERROR argument to `sym` must be a path expression
+        asm!("", options(foo));
+        //~^ ERROR expected one of
+        asm!("", options(nomem foo));
+        //~^ ERROR expected one of
+        asm!("", options(nomem, foo));
+        //~^ ERROR expected one of
+        asm!("", options(), options());
+        //~^ ERROR asm options cannot be specified twice
+        asm!("{}", options(), const foo);
+        //~^ ERROR arguments are not allowed after options
+        asm!("{a}", a = const foo, a = const bar);
+        //~^ ERROR duplicate argument named `a`
+        //~^^ ERROR argument never used
+        asm!("", a = in("eax") foo);
+        //~^ ERROR explicit register arguments cannot have names
+        asm!("{a}", in("eax") foo, a = const bar);
+        //~^ ERROR named arguments cannot follow explicit register arguments
+        asm!("{a}", in("eax") foo, a = const bar);
+        //~^ ERROR named arguments cannot follow explicit register arguments
+        asm!("{1}", in("eax") foo, const bar);
+        //~^ ERROR positional arguments cannot follow named arguments or explicit register arguments
+    }
+}