]> git.lizzy.rs Git - rust.git/blob - src/test/ui/asm/aarch64/parse-error.rs
Rollup merge of #87910 - iago-lito:mark_unsafe_nonzero_arithmetics_as_const, r=joshtr...
[rust.git] / src / test / ui / asm / aarch64 / parse-error.rs
1 // only-aarch64
2
3 #![feature(asm, global_asm)]
4
5 fn main() {
6     let mut foo = 0;
7     let mut bar = 0;
8     unsafe {
9         asm!();
10         //~^ ERROR requires at least a template string argument
11         asm!(foo);
12         //~^ ERROR asm template must be a string literal
13         asm!("{}" foo);
14         //~^ ERROR expected token: `,`
15         asm!("{}", foo);
16         //~^ ERROR expected operand, clobber_abi, options, or additional template string
17         asm!("{}", in foo);
18         //~^ ERROR expected `(`, found `foo`
19         asm!("{}", in(reg foo));
20         //~^ ERROR expected `)`, found `foo`
21         asm!("{}", in(reg));
22         //~^ ERROR expected expression, found end of macro arguments
23         asm!("{}", inout(=) foo => bar);
24         //~^ ERROR expected register class or explicit register
25         asm!("{}", inout(reg) foo =>);
26         //~^ ERROR expected expression, found end of macro arguments
27         asm!("{}", in(reg) foo => bar);
28         //~^ ERROR expected one of `!`, `,`, `.`, `::`, `?`, `{`, or an operator, found `=>`
29         asm!("{}", sym foo + bar);
30         //~^ ERROR argument to `sym` must be a path expression
31         asm!("", options(foo));
32         //~^ ERROR expected one of
33         asm!("", options(nomem foo));
34         //~^ ERROR expected one of
35         asm!("", options(nomem, foo));
36         //~^ ERROR expected one of
37         asm!("{}", options(), const foo);
38         //~^ ERROR arguments are not allowed after options
39         //~^^ ERROR attempt to use a non-constant value in a constant
40         asm!("", clobber_abi(foo));
41         //~^ ERROR expected string literal
42         asm!("", clobber_abi("C" foo));
43         //~^ ERROR expected `)`, found `foo`
44         asm!("", clobber_abi("C", foo));
45         //~^ ERROR expected `)`, found `,`
46         asm!("{}", clobber_abi("C"), const foo);
47         //~^ ERROR arguments are not allowed after clobber_abi
48         //~^^ ERROR attempt to use a non-constant value in a constant
49         asm!("", options(), clobber_abi("C"));
50         //~^ ERROR clobber_abi is not allowed after options
51         asm!("{}", options(), clobber_abi("C"), const foo);
52         //~^ ERROR clobber_abi is not allowed after options
53         asm!("", clobber_abi("C"), clobber_abi("C"));
54         //~^ ERROR clobber_abi specified multiple times
55         asm!("{a}", a = const foo, a = const bar);
56         //~^ ERROR duplicate argument named `a`
57         //~^^ ERROR argument never used
58         //~^^^ ERROR attempt to use a non-constant value in a constant
59         //~^^^^ ERROR attempt to use a non-constant value in a constant
60         asm!("", a = in("x0") foo);
61         //~^ ERROR explicit register arguments cannot have names
62         asm!("{a}", in("x0") foo, a = const bar);
63         //~^ ERROR named arguments cannot follow explicit register arguments
64         //~^^ ERROR attempt to use a non-constant value in a constant
65         asm!("{a}", in("x0") foo, a = const bar);
66         //~^ ERROR named arguments cannot follow explicit register arguments
67         //~^^ ERROR attempt to use a non-constant value in a constant
68         asm!("{1}", in("x0") foo, const bar);
69         //~^ ERROR positional arguments cannot follow named arguments or explicit register arguments
70         //~^^ ERROR attempt to use a non-constant value in a constant
71         asm!("", options(), "");
72         //~^ ERROR expected one of
73         asm!("{}", in(reg) foo, "{}", out(reg) foo);
74         //~^ ERROR expected one of
75         asm!(format!("{{{}}}", 0), in(reg) foo);
76         //~^ ERROR asm template must be a string literal
77         asm!("{1}", format!("{{{}}}", 0), in(reg) foo, out(reg) bar);
78         //~^ ERROR asm template must be a string literal
79         asm!("{}", in(reg) _);
80         //~^ ERROR _ cannot be used for input operands
81         asm!("{}", inout(reg) _);
82         //~^ ERROR _ cannot be used for input operands
83         asm!("{}", inlateout(reg) _);
84         //~^ ERROR _ cannot be used for input operands
85     }
86 }
87
88 const FOO: i32 = 1;
89 const BAR: i32 = 2;
90 global_asm!();
91 //~^ ERROR requires at least a template string argument
92 global_asm!(FOO);
93 //~^ ERROR asm template must be a string literal
94 global_asm!("{}" FOO);
95 //~^ ERROR expected token: `,`
96 global_asm!("{}", FOO);
97 //~^ ERROR expected operand, options, or additional template string
98 global_asm!("{}", const);
99 //~^ ERROR expected expression, found end of macro arguments
100 global_asm!("{}", const(reg) FOO);
101 //~^ ERROR expected one of
102 global_asm!("", options(FOO));
103 //~^ ERROR expected one of
104 global_asm!("", options(nomem FOO));
105 //~^ ERROR expected one of
106 global_asm!("", options(nomem, FOO));
107 //~^ ERROR expected one of
108 global_asm!("{}", options(), const FOO);
109 //~^ ERROR arguments are not allowed after options
110 global_asm!("", clobber_abi(FOO));
111 //~^ ERROR expected string literal
112 global_asm!("", clobber_abi("C" FOO));
113 //~^ ERROR expected `)`, found `FOO`
114 global_asm!("", clobber_abi("C", FOO));
115 //~^ ERROR expected `)`, found `,`
116 global_asm!("{}", clobber_abi("C"), const FOO);
117 //~^ ERROR arguments are not allowed after clobber_abi
118 //~^^ ERROR `clobber_abi` cannot be used with `global_asm!`
119 global_asm!("", options(), clobber_abi("C"));
120 //~^ ERROR clobber_abi is not allowed after options
121 global_asm!("{}", options(), clobber_abi("C"), const FOO);
122 //~^ ERROR clobber_abi is not allowed after options
123 global_asm!("", clobber_abi("C"), clobber_abi("C"));
124 //~^ ERROR clobber_abi specified multiple times
125 global_asm!("{a}", a = const FOO, a = const BAR);
126 //~^ ERROR duplicate argument named `a`
127 //~^^ ERROR argument never used
128 global_asm!("", options(), "");
129 //~^ ERROR expected one of
130 global_asm!("{}", const FOO, "{}", const FOO);
131 //~^ ERROR expected one of
132 global_asm!(format!("{{{}}}", 0), const FOO);
133 //~^ ERROR asm template must be a string literal
134 global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR);
135 //~^ ERROR asm template must be a string literal