]> git.proxmox.com Git - rustc.git/blob - src/test/ui/asm/x86_64/parse-error.rs
New upstream version 1.62.1+dfsg1
[rustc.git] / src / test / ui / asm / x86_64 / parse-error.rs
1 // only-x86_64
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());
43 //~^ ERROR at least one abi must be provided
44 asm!("", clobber_abi(foo));
45 //~^ ERROR expected string literal
46 asm!("", clobber_abi("C" foo));
47 //~^ ERROR expected one of `)` or `,`, found `foo`
48 asm!("", clobber_abi("C", foo));
49 //~^ ERROR expected string literal
50 asm!("{}", clobber_abi("C"), const foo);
51 //~^ ERROR arguments are not allowed after clobber_abi
52 //~^^ ERROR attempt to use a non-constant value in a constant
53 asm!("", options(), clobber_abi("C"));
54 //~^ ERROR clobber_abi is not allowed after options
55 asm!("{}", options(), clobber_abi("C"), const foo);
56 //~^ ERROR clobber_abi is not allowed after options
57 asm!("{a}", a = const foo, a = const bar);
58 //~^ ERROR duplicate argument named `a`
59 //~^^ ERROR argument never used
60 //~^^^ ERROR attempt to use a non-constant value in a constant
61 //~^^^^ ERROR attempt to use a non-constant value in a constant
62 asm!("", a = in("eax") foo);
63 //~^ ERROR explicit register arguments cannot have names
64 asm!("{a}", in("eax") foo, a = const bar);
65 //~^ ERROR named arguments cannot follow explicit register arguments
66 //~^^ ERROR attempt to use a non-constant value in a constant
67 asm!("{a}", in("eax") foo, a = const bar);
68 //~^ ERROR named arguments cannot follow explicit register arguments
69 //~^^ ERROR attempt to use a non-constant value in a constant
70 asm!("{1}", in("eax") foo, const bar);
71 //~^ ERROR positional arguments cannot follow named arguments or explicit register arguments
72 //~^^ ERROR attempt to use a non-constant value in a constant
73 asm!("", options(), "");
74 //~^ ERROR expected one of
75 asm!("{}", in(reg) foo, "{}", out(reg) foo);
76 //~^ ERROR expected one of
77 asm!(format!("{{{}}}", 0), in(reg) foo);
78 //~^ ERROR asm template must be a string literal
79 asm!("{1}", format!("{{{}}}", 0), in(reg) foo, out(reg) bar);
80 //~^ ERROR asm template must be a string literal
81 asm!("{}", in(reg) _);
82 //~^ ERROR _ cannot be used for input operands
83 asm!("{}", inout(reg) _);
84 //~^ ERROR _ cannot be used for input operands
85 asm!("{}", inlateout(reg) _);
86 //~^ ERROR _ cannot be used for input operands
87 }
88 }
89
90 const FOO: i32 = 1;
91 const BAR: i32 = 2;
92 global_asm!();
93 //~^ ERROR requires at least a template string argument
94 global_asm!(FOO);
95 //~^ ERROR asm template must be a string literal
96 global_asm!("{}" FOO);
97 //~^ ERROR expected token: `,`
98 global_asm!("{}", FOO);
99 //~^ ERROR expected operand, options, or additional template string
100 global_asm!("{}", const);
101 //~^ ERROR expected expression, found end of macro arguments
102 global_asm!("{}", const(reg) FOO);
103 //~^ ERROR expected one of
104 global_asm!("", options(FOO));
105 //~^ ERROR expected one of
106 global_asm!("", options(nomem FOO));
107 //~^ ERROR expected one of
108 global_asm!("", options(nomem, FOO));
109 //~^ ERROR expected one of
110 global_asm!("{}", options(), const FOO);
111 //~^ ERROR arguments are not allowed after options
112 global_asm!("", clobber_abi(FOO));
113 //~^ ERROR expected string literal
114 global_asm!("", clobber_abi("C" FOO));
115 //~^ ERROR expected one of `)` or `,`, found `FOO`
116 global_asm!("", clobber_abi("C", FOO));
117 //~^ ERROR expected string literal
118 global_asm!("{}", clobber_abi("C"), const FOO);
119 //~^ ERROR arguments are not allowed after clobber_abi
120 //~^^ ERROR `clobber_abi` cannot be used with `global_asm!`
121 global_asm!("", options(), clobber_abi("C"));
122 //~^ ERROR clobber_abi is not allowed after options
123 global_asm!("{}", options(), clobber_abi("C"), const FOO);
124 //~^ ERROR clobber_abi is not allowed after options
125 global_asm!("", clobber_abi("C"), clobber_abi("C"));
126 //~^ ERROR `clobber_abi` cannot be used with `global_asm!`
127 global_asm!("{a}", a = const FOO, a = const BAR);
128 //~^ ERROR duplicate argument named `a`
129 //~^^ ERROR argument never used
130 global_asm!("", options(), "");
131 //~^ ERROR expected one of
132 global_asm!("{}", const FOO, "{}", const FOO);
133 //~^ ERROR expected one of
134 global_asm!(format!("{{{}}}", 0), const FOO);
135 //~^ ERROR asm template must be a string literal
136 global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR);
137 //~^ ERROR asm template must be a string literal