Skip to content

Commit 315874c

Browse files
authored
Rollup merge of #141242 - folkertdev:aarch64-asm-parse-errors, r=Amanieu
in `tests/ui/asm/aarch64/parse-error.rs`, only test cases specific to that target this is more in line with the x86 parse error tests at https://github.com/rust-lang/rust/blob/master/tests/ui/asm/x86_64/x86_64_parse_error.rs. We could at this point use minicore so that these tests run no matter the host target? `tests/ui/asm/aarch64/parse-error.rs` was mostly a copy of https://github.com/rust-lang/rust/blob/master/tests/ui/asm/parse-error.rs, though a bit out of date. The only aarch64-specific tests are those that talk about register names. Here is a diff between those two files: ```diff --- <unnamed> +++ <unnamed> `@@` -1,4 +1,4 `@@` -//@ needs-asm-support +//@ only-aarch64 use std::arch::{asm, global_asm}; `@@` -36,36 +36,12 `@@` //~^ ERROR expected one of asm!("{}", options(), const foo); //~^ ERROR attempt to use a non-constant value in a constant - - // test that asm!'s clobber_abi doesn't accept non-string literals - // see also #112635 - asm!("", clobber_abi()); - //~^ ERROR at least one abi must be provided asm!("", clobber_abi(foo)); //~^ ERROR expected string literal asm!("", clobber_abi("C" foo)); //~^ ERROR expected one of `)` or `,`, found `foo` asm!("", clobber_abi("C", foo)); //~^ ERROR expected string literal - asm!("", clobber_abi(1)); - //~^ ERROR expected string literal - asm!("", clobber_abi(())); - //~^ ERROR expected string literal - asm!("", clobber_abi(uwu)); - //~^ ERROR expected string literal - asm!("", clobber_abi({})); - //~^ ERROR expected string literal - asm!("", clobber_abi(loop {})); - //~^ ERROR expected string literal - asm!("", clobber_abi(if)); - //~^ ERROR expected string literal - asm!("", clobber_abi(do)); - //~^ ERROR expected string literal - asm!("", clobber_abi(<)); - //~^ ERROR expected string literal - asm!("", clobber_abi(.)); - //~^ ERROR expected string literal - asm!("{}", clobber_abi("C"), const foo); //~^ ERROR attempt to use a non-constant value in a constant asm!("", options(), clobber_abi("C")); `@@` -76,7 +52,15 `@@` //~^^ ERROR argument never used //~^^^ ERROR attempt to use a non-constant value in a constant //~^^^^ ERROR attempt to use a non-constant value in a constant - + asm!("", a = in("x0") foo); + //~^ ERROR explicit register arguments cannot have names + asm!("{a}", in("x0") foo, a = const bar); + //~^ ERROR attempt to use a non-constant value in a constant + asm!("{a}", in("x0") foo, a = const bar); + //~^ ERROR attempt to use a non-constant value in a constant + asm!("{1}", in("x0") foo, const bar); + //~^ ERROR positional arguments cannot follow named arguments or explicit register arguments + //~^^ ERROR attempt to use a non-constant value in a constant asm!("", options(), ""); //~^ ERROR expected one of asm!("{}", in(reg) foo, "{}", out(reg) foo); `@@` -109,13 +93,11 `@@` global_asm!("{}", const(reg) FOO); //~^ ERROR expected one of global_asm!("", options(FOO)); -//~^ ERROR expected one of `)`, `att_syntax`, or `raw`, found `FOO` -global_asm!("", options(FOO,)); -//~^ ERROR expected one of `)`, `att_syntax`, or `raw`, found `FOO` +//~^ ERROR expected one of global_asm!("", options(nomem FOO)); -//~^ ERROR expected one of `)` or `,`, found `FOO` +//~^ ERROR expected one of global_asm!("", options(nomem, FOO)); -//~^ ERROR expected one of `)`, `att_syntax`, or `raw`, found `FOO` +//~^ ERROR expected one of global_asm!("{}", options(), const FOO); global_asm!("", clobber_abi(FOO)); //~^ ERROR expected string literal `@@` -129,8 +111,6 `@@` //~^ ERROR `clobber_abi` cannot be used with `global_asm!` global_asm!("{}", options(), clobber_abi("C"), const FOO); //~^ ERROR `clobber_abi` cannot be used with `global_asm!` -global_asm!("", clobber_abi("C"), clobber_abi("C")); -//~^ ERROR `clobber_abi` cannot be used with `global_asm!` global_asm!("{a}", a = const FOO, a = const BAR); //~^ ERROR duplicate argument named `a` //~^^ ERROR argument never used `@@` -142,16 +122,3 `@@` //~^ ERROR asm template must be a string literal global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR); //~^ ERROR asm template must be a string literal - -global_asm!("{}", in(reg)); -//~^ ERROR the `in` operand cannot be used with `global_asm!` -global_asm!("{}", out(reg)); -//~^ ERROR the `out` operand cannot be used with `global_asm!` -global_asm!("{}", lateout(reg)); -//~^ ERROR the `lateout` operand cannot be used with `global_asm!` -global_asm!("{}", inout(reg)); -//~^ ERROR the `inout` operand cannot be used with `global_asm!` -global_asm!("{}", inlateout(reg)); -//~^ ERROR the `inlateout` operand cannot be used with `global_asm!` -global_asm!("{}", label(reg)); -//~^ ERROR the `label` operand cannot be used with `global_asm!` ```
2 parents b86de53 + 85f9dce commit 315874c

File tree

2 files changed

+7
-470
lines changed

2 files changed

+7
-470
lines changed

tests/ui/asm/aarch64/parse-error.rs

Lines changed: 1 addition & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,11 @@
11
//@ only-aarch64
22

3-
use std::arch::{asm, global_asm};
3+
use std::arch::asm;
44

55
fn main() {
66
let mut foo = 0;
77
let mut bar = 0;
88
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 expected a path for argument to `sym`
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 attempt to use a non-constant value in a constant
39-
asm!("", clobber_abi(foo));
40-
//~^ ERROR expected string literal
41-
asm!("", clobber_abi("C" foo));
42-
//~^ ERROR expected one of `)` or `,`, found `foo`
43-
asm!("", clobber_abi("C", foo));
44-
//~^ ERROR expected string literal
45-
asm!("{}", clobber_abi("C"), const foo);
46-
//~^ ERROR attempt to use a non-constant value in a constant
47-
asm!("", options(), clobber_abi("C"));
48-
asm!("{}", options(), clobber_abi("C"), const foo);
49-
//~^ ERROR attempt to use a non-constant value in a constant
50-
asm!("{a}", a = const foo, a = const bar);
51-
//~^ ERROR duplicate argument named `a`
52-
//~^^ ERROR argument never used
53-
//~^^^ ERROR attempt to use a non-constant value in a constant
54-
//~^^^^ ERROR attempt to use a non-constant value in a constant
559
asm!("", a = in("x0") foo);
5610
//~^ ERROR explicit register arguments cannot have names
5711
asm!("{a}", in("x0") foo, a = const bar);
@@ -61,64 +15,5 @@ fn main() {
6115
asm!("{1}", in("x0") foo, const bar);
6216
//~^ ERROR positional arguments cannot follow named arguments or explicit register arguments
6317
//~^^ ERROR attempt to use a non-constant value in a constant
64-
asm!("", options(), "");
65-
//~^ ERROR expected one of
66-
asm!("{}", in(reg) foo, "{}", out(reg) foo);
67-
//~^ ERROR expected one of
68-
asm!(format!("{{{}}}", 0), in(reg) foo);
69-
//~^ ERROR asm template must be a string literal
70-
asm!("{1}", format!("{{{}}}", 0), in(reg) foo, out(reg) bar);
71-
//~^ ERROR asm template must be a string literal
72-
asm!("{}", in(reg) _);
73-
//~^ ERROR _ cannot be used for input operands
74-
asm!("{}", inout(reg) _);
75-
//~^ ERROR _ cannot be used for input operands
76-
asm!("{}", inlateout(reg) _);
77-
//~^ ERROR _ cannot be used for input operands
7818
}
7919
}
80-
81-
const FOO: i32 = 1;
82-
const BAR: i32 = 2;
83-
global_asm!();
84-
//~^ ERROR requires at least a template string argument
85-
global_asm!(FOO);
86-
//~^ ERROR asm template must be a string literal
87-
global_asm!("{}" FOO);
88-
//~^ ERROR expected token: `,`
89-
global_asm!("{}", FOO);
90-
//~^ ERROR expected operand, options, or additional template string
91-
global_asm!("{}", const);
92-
//~^ ERROR expected expression, found end of macro arguments
93-
global_asm!("{}", const(reg) FOO);
94-
//~^ ERROR expected one of
95-
global_asm!("", options(FOO));
96-
//~^ ERROR expected one of
97-
global_asm!("", options(nomem FOO));
98-
//~^ ERROR expected one of
99-
global_asm!("", options(nomem, FOO));
100-
//~^ ERROR expected one of
101-
global_asm!("{}", options(), const FOO);
102-
global_asm!("", clobber_abi(FOO));
103-
//~^ ERROR expected string literal
104-
global_asm!("", clobber_abi("C" FOO));
105-
//~^ ERROR expected one of `)` or `,`, found `FOO`
106-
global_asm!("", clobber_abi("C", FOO));
107-
//~^ ERROR expected string literal
108-
global_asm!("{}", clobber_abi("C"), const FOO);
109-
//~^ ERROR `clobber_abi` cannot be used with `global_asm!`
110-
global_asm!("", options(), clobber_abi("C"));
111-
//~^ ERROR `clobber_abi` cannot be used with `global_asm!`
112-
global_asm!("{}", options(), clobber_abi("C"), const FOO);
113-
//~^ ERROR `clobber_abi` cannot be used with `global_asm!`
114-
global_asm!("{a}", a = const FOO, a = const BAR);
115-
//~^ ERROR duplicate argument named `a`
116-
//~^^ ERROR argument never used
117-
global_asm!("", options(), "");
118-
//~^ ERROR expected one of
119-
global_asm!("{}", const FOO, "{}", const FOO);
120-
//~^ ERROR expected one of
121-
global_asm!(format!("{{{}}}", 0), const FOO);
122-
//~^ ERROR asm template must be a string literal
123-
global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR);
124-
//~^ ERROR asm template must be a string literal

0 commit comments

Comments
 (0)