Skip to content

Commit 4332c2f

Browse files
committed
Update tests on aarch64
1 parent 6ba8da6 commit 4332c2f

10 files changed

+183
-127
lines changed

src/test/ui/asm/aarch64/bad-reg.rs

+2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ fn main() {
3636

3737
asm!("", in("p0") foo);
3838
//~^ ERROR register class `preg` can only be used as a clobber, not as an input or output
39+
//~| ERROR type `i32` cannot be used with this register class
3940
asm!("", out("p0") _);
4041
asm!("{}", in(preg) foo);
4142
//~^ ERROR register class `preg` can only be used as a clobber, not as an input or output
43+
//~| ERROR type `i32` cannot be used with this register class
4244
asm!("{}", out(preg) _);
4345
//~^ ERROR register class `preg` can only be used as a clobber, not as an input or output
4446

src/test/ui/asm/aarch64/bad-reg.stderr

+25-9
Original file line numberDiff line numberDiff line change
@@ -87,60 +87,76 @@ LL | asm!("", in("p0") foo);
8787
| ^^^^^^^^^^^^
8888

8989
error: register class `preg` can only be used as a clobber, not as an input or output
90-
--> $DIR/bad-reg.rs:40:20
90+
--> $DIR/bad-reg.rs:41:20
9191
|
9292
LL | asm!("{}", in(preg) foo);
9393
| ^^^^^^^^^^^^
9494

9595
error: register class `preg` can only be used as a clobber, not as an input or output
96-
--> $DIR/bad-reg.rs:42:20
96+
--> $DIR/bad-reg.rs:44:20
9797
|
9898
LL | asm!("{}", out(preg) _);
9999
| ^^^^^^^^^^^
100100

101101
error: register `x0` conflicts with register `x0`
102-
--> $DIR/bad-reg.rs:48:32
102+
--> $DIR/bad-reg.rs:50:32
103103
|
104104
LL | asm!("", in("x0") foo, in("w0") bar);
105105
| ------------ ^^^^^^^^^^^^ register `x0`
106106
| |
107107
| register `x0`
108108

109109
error: register `x0` conflicts with register `x0`
110-
--> $DIR/bad-reg.rs:50:32
110+
--> $DIR/bad-reg.rs:52:32
111111
|
112112
LL | asm!("", in("x0") foo, out("x0") bar);
113113
| ------------ ^^^^^^^^^^^^^ register `x0`
114114
| |
115115
| register `x0`
116116
|
117117
help: use `lateout` instead of `out` to avoid conflict
118-
--> $DIR/bad-reg.rs:50:18
118+
--> $DIR/bad-reg.rs:52:18
119119
|
120120
LL | asm!("", in("x0") foo, out("x0") bar);
121121
| ^^^^^^^^^^^^
122122

123123
error: register `v0` conflicts with register `v0`
124-
--> $DIR/bad-reg.rs:53:32
124+
--> $DIR/bad-reg.rs:55:32
125125
|
126126
LL | asm!("", in("v0") foo, in("q0") bar);
127127
| ------------ ^^^^^^^^^^^^ register `v0`
128128
| |
129129
| register `v0`
130130

131131
error: register `v0` conflicts with register `v0`
132-
--> $DIR/bad-reg.rs:55:32
132+
--> $DIR/bad-reg.rs:57:32
133133
|
134134
LL | asm!("", in("v0") foo, out("q0") bar);
135135
| ------------ ^^^^^^^^^^^^^ register `v0`
136136
| |
137137
| register `v0`
138138
|
139139
help: use `lateout` instead of `out` to avoid conflict
140-
--> $DIR/bad-reg.rs:55:18
140+
--> $DIR/bad-reg.rs:57:18
141141
|
142142
LL | asm!("", in("v0") foo, out("q0") bar);
143143
| ^^^^^^^^^^^^
144144

145-
error: aborting due to 18 previous errors
145+
error: type `i32` cannot be used with this register class
146+
--> $DIR/bad-reg.rs:37:27
147+
|
148+
LL | asm!("", in("p0") foo);
149+
| ^^^
150+
|
151+
= note: register class `preg` supports these types:
152+
153+
error: type `i32` cannot be used with this register class
154+
--> $DIR/bad-reg.rs:41:29
155+
|
156+
LL | asm!("{}", in(preg) foo);
157+
| ^^^
158+
|
159+
= note: register class `preg` supports these types:
160+
161+
error: aborting due to 20 previous errors
146162

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// only-aarch64
2+
3+
#![feature(repr_simd, never_type, asm_sym)]
4+
5+
use std::arch::{asm, global_asm};
6+
7+
#[repr(simd)]
8+
#[derive(Clone, Copy)]
9+
struct SimdType(f32, f32, f32, f32);
10+
11+
#[repr(simd)]
12+
struct SimdNonCopy(f32, f32, f32, f32);
13+
14+
fn main() {
15+
unsafe {
16+
// Inputs must be initialized
17+
18+
let x: u64;
19+
asm!("{}", in(reg) x);
20+
//~^ ERROR use of possibly-uninitialized variable: `x`
21+
let mut y: u64;
22+
asm!("{}", inout(reg) y);
23+
//~^ ERROR use of possibly-uninitialized variable: `y`
24+
let _ = y;
25+
26+
// Outputs require mutable places
27+
28+
let v: Vec<u64> = vec![0, 1, 2];
29+
asm!("{}", in(reg) v[0]);
30+
asm!("{}", out(reg) v[0]);
31+
//~^ ERROR cannot borrow `v` as mutable, as it is not declared as mutable
32+
asm!("{}", inout(reg) v[0]);
33+
//~^ ERROR cannot borrow `v` as mutable, as it is not declared as mutable
34+
35+
// Sym operands must point to a function or static
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
error[E0381]: use of possibly-uninitialized variable: `x`
2+
--> $DIR/type-check-2-2.rs:19:28
3+
|
4+
LL | asm!("{}", in(reg) x);
5+
| ^ use of possibly-uninitialized `x`
6+
7+
error[E0381]: use of possibly-uninitialized variable: `y`
8+
--> $DIR/type-check-2-2.rs:22:9
9+
|
10+
LL | asm!("{}", inout(reg) y);
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^ use of possibly-uninitialized `y`
12+
13+
error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable
14+
--> $DIR/type-check-2-2.rs:30:29
15+
|
16+
LL | let v: Vec<u64> = vec![0, 1, 2];
17+
| - help: consider changing this to be mutable: `mut v`
18+
LL | asm!("{}", in(reg) v[0]);
19+
LL | asm!("{}", out(reg) v[0]);
20+
| ^ cannot borrow as mutable
21+
22+
error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable
23+
--> $DIR/type-check-2-2.rs:32:31
24+
|
25+
LL | let v: Vec<u64> = vec![0, 1, 2];
26+
| - help: consider changing this to be mutable: `mut v`
27+
...
28+
LL | asm!("{}", inout(reg) v[0]);
29+
| ^ cannot borrow as mutable
30+
31+
error: aborting due to 4 previous errors
32+
33+
Some errors have detailed explanations: E0381, E0596.
34+
For more information about an error, try `rustc --explain E0381`.

src/test/ui/asm/aarch64/type-check-2.rs

-17
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,6 @@ fn main() {
1515
unsafe {
1616
// Inputs must be initialized
1717

18-
let x: u64;
19-
asm!("{}", in(reg) x);
20-
//~^ ERROR use of possibly-uninitialized variable: `x`
21-
let mut y: u64;
22-
asm!("{}", inout(reg) y);
23-
//~^ ERROR use of possibly-uninitialized variable: `y`
24-
let _ = y;
25-
26-
// Outputs require mutable places
27-
28-
let v: Vec<u64> = vec![0, 1, 2];
29-
asm!("{}", in(reg) v[0]);
30-
asm!("{}", out(reg) v[0]);
31-
//~^ ERROR cannot borrow `v` as mutable, as it is not declared as mutable
32-
asm!("{}", inout(reg) v[0]);
33-
//~^ ERROR cannot borrow `v` as mutable, as it is not declared as mutable
34-
3518
// Sym operands must point to a function or static
3619

3720
const C: i32 = 0;
+25-57
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,37 @@
1+
error: invalid `sym` operand
2+
--> $DIR/type-check-2.rs:75:19
3+
|
4+
LL | global_asm!("{}", sym C);
5+
| ^^^^^ is an `i32`
6+
|
7+
= help: `sym` operands must refer to either a function or a static
8+
9+
error: invalid `sym` operand
10+
--> $DIR/type-check-2.rs:24:20
11+
|
12+
LL | asm!("{}", sym C);
13+
| ^^^^^ is an `i32`
14+
|
15+
= help: `sym` operands must refer to either a function or a static
16+
117
error: arguments for inline assembly must be copyable
2-
--> $DIR/type-check-2.rs:46:31
18+
--> $DIR/type-check-2.rs:29:31
319
|
420
LL | asm!("{:v}", in(vreg) SimdNonCopy(0.0, 0.0, 0.0, 0.0));
521
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
622
|
723
= note: `SimdNonCopy` does not implement the Copy trait
824

9-
error: cannot use value of type `[closure@$DIR/type-check-2.rs:58:28: 58:38]` for inline assembly
10-
--> $DIR/type-check-2.rs:58:28
25+
error: cannot use value of type `[closure@$DIR/type-check-2.rs:41:28: 41:38]` for inline assembly
26+
--> $DIR/type-check-2.rs:41:28
1127
|
1228
LL | asm!("{}", in(reg) |x: i32| x);
1329
| ^^^^^^^^^^
1430
|
1531
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
1632

1733
error: cannot use value of type `Vec<i32>` for inline assembly
18-
--> $DIR/type-check-2.rs:60:28
34+
--> $DIR/type-check-2.rs:43:28
1935
|
2036
LL | asm!("{}", in(reg) vec![0]);
2137
| ^^^^^^^
@@ -24,84 +40,36 @@ LL | asm!("{}", in(reg) vec![0]);
2440
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
2541

2642
error: cannot use value of type `(i32, i32, i32)` for inline assembly
27-
--> $DIR/type-check-2.rs:62:28
43+
--> $DIR/type-check-2.rs:45:28
2844
|
2945
LL | asm!("{}", in(reg) (1, 2, 3));
3046
| ^^^^^^^^^
3147
|
3248
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
3349

3450
error: cannot use value of type `[i32; 3]` for inline assembly
35-
--> $DIR/type-check-2.rs:64:28
51+
--> $DIR/type-check-2.rs:47:28
3652
|
3753
LL | asm!("{}", in(reg) [1, 2, 3]);
3854
| ^^^^^^^^^
3955
|
4056
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
4157

4258
error: cannot use value of type `fn() {main}` for inline assembly
43-
--> $DIR/type-check-2.rs:72:31
59+
--> $DIR/type-check-2.rs:55:31
4460
|
4561
LL | asm!("{}", inout(reg) f);
4662
| ^
4763
|
4864
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
4965

5066
error: cannot use value of type `&mut i32` for inline assembly
51-
--> $DIR/type-check-2.rs:75:31
67+
--> $DIR/type-check-2.rs:58:31
5268
|
5369
LL | asm!("{}", inout(reg) r);
5470
| ^
5571
|
5672
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
5773

58-
error: invalid `sym` operand
59-
--> $DIR/type-check-2.rs:41:20
60-
|
61-
LL | asm!("{}", sym C);
62-
| ^^^^^ is an `i32`
63-
|
64-
= help: `sym` operands must refer to either a function or a static
65-
66-
error: invalid `sym` operand
67-
--> $DIR/type-check-2.rs:92:19
68-
|
69-
LL | global_asm!("{}", sym C);
70-
| ^^^^^ is an `i32`
71-
|
72-
= help: `sym` operands must refer to either a function or a static
73-
74-
error[E0381]: use of possibly-uninitialized variable: `x`
75-
--> $DIR/type-check-2.rs:19:28
76-
|
77-
LL | asm!("{}", in(reg) x);
78-
| ^ use of possibly-uninitialized `x`
79-
80-
error[E0381]: use of possibly-uninitialized variable: `y`
81-
--> $DIR/type-check-2.rs:22:9
82-
|
83-
LL | asm!("{}", inout(reg) y);
84-
| ^^^^^^^^^^^^^^^^^^^^^^^^ use of possibly-uninitialized `y`
85-
86-
error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable
87-
--> $DIR/type-check-2.rs:30:29
88-
|
89-
LL | let v: Vec<u64> = vec![0, 1, 2];
90-
| - help: consider changing this to be mutable: `mut v`
91-
LL | asm!("{}", in(reg) v[0]);
92-
LL | asm!("{}", out(reg) v[0]);
93-
| ^ cannot borrow as mutable
94-
95-
error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable
96-
--> $DIR/type-check-2.rs:32:31
97-
|
98-
LL | let v: Vec<u64> = vec![0, 1, 2];
99-
| - help: consider changing this to be mutable: `mut v`
100-
...
101-
LL | asm!("{}", inout(reg) v[0]);
102-
| ^ cannot borrow as mutable
103-
104-
error: aborting due to 13 previous errors
74+
error: aborting due to 9 previous errors
10575

106-
Some errors have detailed explanations: E0381, E0596.
107-
For more information about an error, try `rustc --explain E0381`.

src/test/ui/asm/aarch64/type-check-3.rs

-18
Original file line numberDiff line numberDiff line change
@@ -95,21 +95,3 @@ fn main() {
9595
asm!("{:x}", inout(reg) main => val_u64);
9696
}
9797
}
98-
99-
// Constants must be... constant
100-
101-
static S: i32 = 1;
102-
const fn const_foo(x: i32) -> i32 {
103-
x
104-
}
105-
const fn const_bar<T>(x: T) -> T {
106-
x
107-
}
108-
global_asm!("{}", const S);
109-
//~^ ERROR constants cannot refer to statics
110-
global_asm!("{}", const const_foo(0));
111-
global_asm!("{}", const const_foo(S));
112-
//~^ ERROR constants cannot refer to statics
113-
global_asm!("{}", const const_bar(0));
114-
global_asm!("{}", const const_bar(S));
115-
//~^ ERROR constants cannot refer to statics

src/test/ui/asm/aarch64/type-check-3.stderr

+1-26
Original file line numberDiff line numberDiff line change
@@ -143,30 +143,5 @@ LL | asm!("{:x}", inout(reg) main => val_u32);
143143
|
144144
= note: asm inout arguments must have the same type, unless they are both pointers or integers of the same size
145145

146-
error[E0013]: constants cannot refer to statics
147-
--> $DIR/type-check-3.rs:108:25
148-
|
149-
LL | global_asm!("{}", const S);
150-
| ^
151-
|
152-
= help: consider extracting the value of the `static` to a `const`, and referring to that
153-
154-
error[E0013]: constants cannot refer to statics
155-
--> $DIR/type-check-3.rs:111:35
156-
|
157-
LL | global_asm!("{}", const const_foo(S));
158-
| ^
159-
|
160-
= help: consider extracting the value of the `static` to a `const`, and referring to that
161-
162-
error[E0013]: constants cannot refer to statics
163-
--> $DIR/type-check-3.rs:114:35
164-
|
165-
LL | global_asm!("{}", const const_bar(S));
166-
| ^
167-
|
168-
= help: consider extracting the value of the `static` to a `const`, and referring to that
169-
170-
error: aborting due to 9 previous errors; 10 warnings emitted
146+
error: aborting due to 6 previous errors; 10 warnings emitted
171147

172-
For more information about this error, try `rustc --explain E0013`.

0 commit comments

Comments
 (0)