]> git.lizzy.rs Git - rust.git/blob - src/test/ui/asm/aarch64/parse-error.rs
Auto merge of #98471 - wesleywiser:update_measureme, r=Mark-Simulacrum
[rust.git] / src / test / ui / asm / aarch64 / parse-error.rs
1 // only-aarch64
2
3 #![feature(asm_const)]
4
5 use std::arch::{asm, global_asm};
6
7 fn main() {
8     let mut foo = 0;
9     let mut bar = 0;
10     unsafe {
11         asm!();
12         //~^ ERROR requires at least a template string argument
13         asm!(foo);
14         //~^ ERROR asm template must be a string literal
15         asm!("{}" foo);
16         //~^ ERROR expected token: `,`
17         asm!("{}", foo);
18         //~^ ERROR expected operand, clobber_abi, options, or additional template string
19         asm!("{}", in foo);
20         //~^ ERROR expected `(`, found `foo`
21         asm!("{}", in(reg foo));
22         //~^ ERROR expected `)`, found `foo`
23         asm!("{}", in(reg));
24         //~^ ERROR expected expression, found end of macro arguments
25         asm!("{}", inout(=) foo => bar);
26         //~^ ERROR expected register class or explicit register
27         asm!("{}", inout(reg) foo =>);
28         //~^ ERROR expected expression, found end of macro arguments
29         asm!("{}", in(reg) foo => bar);
30         //~^ ERROR expected one of `!`, `,`, `.`, `::`, `?`, `{`, or an operator, found `=>`
31         asm!("{}", sym foo + bar);
32         //~^ ERROR expected a path for argument to `sym`
33         asm!("", options(foo));
34         //~^ ERROR expected one of
35         asm!("", options(nomem foo));
36         //~^ ERROR expected one of
37         asm!("", options(nomem, foo));
38         //~^ ERROR expected one of
39         asm!("{}", options(), const foo);
40         //~^ ERROR arguments are not allowed after options
41         //~^^ ERROR attempt to use a non-constant value in a constant
42         asm!("", clobber_abi(foo));
43         //~^ ERROR expected string literal
44         asm!("", clobber_abi("C" foo));
45         //~^ ERROR expected one of `)` or `,`, found `foo`
46         asm!("", clobber_abi("C", foo));
47         //~^ ERROR expected string literal
48         asm!("{}", clobber_abi("C"), const foo);
49         //~^ ERROR arguments are not allowed after clobber_abi
50         //~^^ ERROR attempt to use a non-constant value in a constant
51         asm!("", options(), clobber_abi("C"));
52         //~^ ERROR clobber_abi is not allowed after options
53         asm!("{}", options(), clobber_abi("C"), const foo);
54         //~^ ERROR clobber_abi is not allowed after options
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 one of `)` or `,`, found `FOO`
114 global_asm!("", clobber_abi("C", FOO));
115 //~^ ERROR expected string literal
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!("{a}", a = const FOO, a = const BAR);
124 //~^ ERROR duplicate argument named `a`
125 //~^^ ERROR argument never used
126 global_asm!("", options(), "");
127 //~^ ERROR expected one of
128 global_asm!("{}", const FOO, "{}", const FOO);
129 //~^ ERROR expected one of
130 global_asm!(format!("{{{}}}", 0), const FOO);
131 //~^ ERROR asm template must be a string literal
132 global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR);
133 //~^ ERROR asm template must be a string literal