]>
Commit | Line | Data |
---|---|---|
ff7c6d11 XL |
1 | // ignore-s390x |
2 | // ignore-emscripten | |
3 | // ignore-powerpc | |
94b46f34 XL |
4 | // ignore-powerpc64 |
5 | // ignore-powerpc64le | |
f035d41b | 6 | // ignore-riscv64 |
ff7c6d11 | 7 | // ignore-sparc |
94b46f34 | 8 | // ignore-sparc64 |
ff7c6d11 | 9 | |
ba9703b0 | 10 | #![feature(llvm_asm)] |
94222f64 | 11 | #![allow(deprecated)] // llvm_asm! |
ff7c6d11 XL |
12 | |
13 | #[cfg(any(target_arch = "x86", | |
14 | target_arch = "x86_64", | |
15 | target_arch = "arm", | |
0531ce1d XL |
16 | target_arch = "aarch64", |
17 | target_arch = "mips", | |
18 | target_arch = "mips64"))] | |
ff7c6d11 XL |
19 | mod test_cases { |
20 | fn is_move() { | |
21 | let y: &mut isize; | |
22 | let x = &mut 0isize; | |
23 | unsafe { | |
ba9703b0 | 24 | llvm_asm!("nop" : : "r"(x)); |
ff7c6d11 | 25 | } |
48663c56 | 26 | let z = x; //~ ERROR use of moved value: `x` |
ff7c6d11 XL |
27 | } |
28 | ||
29 | fn in_is_read() { | |
30 | let mut x = 3; | |
31 | let y = &mut x; | |
32 | unsafe { | |
ba9703b0 | 33 | llvm_asm!("nop" : : "r"(x)); //~ ERROR cannot use |
ff7c6d11 XL |
34 | } |
35 | let z = y; | |
36 | } | |
37 | ||
38 | fn out_is_assign() { | |
39 | let x = 3; | |
40 | unsafe { | |
ba9703b0 | 41 | llvm_asm!("nop" : "=r"(x)); //~ ERROR cannot assign twice |
ff7c6d11 XL |
42 | } |
43 | let mut a = &mut 3; | |
44 | let b = &*a; | |
45 | unsafe { | |
ba9703b0 | 46 | llvm_asm!("nop" : "=r"(a)); // OK, Shallow write to `a` |
ff7c6d11 XL |
47 | } |
48 | let c = b; | |
49 | let d = *a; | |
50 | } | |
51 | ||
52 | fn rw_is_assign() { | |
53 | let x = 3; | |
54 | unsafe { | |
ba9703b0 | 55 | llvm_asm!("nop" : "+r"(x)); //~ ERROR cannot assign twice |
ff7c6d11 XL |
56 | } |
57 | } | |
58 | ||
59 | fn indirect_is_not_init() { | |
60 | let x: i32; | |
61 | unsafe { | |
ba9703b0 | 62 | llvm_asm!("nop" : "=*r"(x)); //~ ERROR use of possibly-uninitialized variable |
ff7c6d11 XL |
63 | } |
64 | } | |
65 | ||
66 | fn rw_is_read() { | |
67 | let mut x = &mut 3; | |
68 | let y = &*x; | |
69 | unsafe { | |
ba9703b0 | 70 | llvm_asm!("nop" : "+r"(x)); //~ ERROR cannot assign to `x` because it is borrowed |
ff7c6d11 XL |
71 | } |
72 | let z = y; | |
73 | } | |
74 | ||
75 | fn two_moves() { | |
76 | let x = &mut 2; | |
77 | unsafe { | |
ba9703b0 | 78 | llvm_asm!("nop" : : "r"(x), "r"(x) ); //~ ERROR use of moved value |
ff7c6d11 XL |
79 | } |
80 | } | |
81 | } | |
82 | ||
83 | fn main() {} |