]> git.proxmox.com Git - rustc.git/blob - src/test/ui/llvm-asm/llvm-asm-out-assign.rs
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / src / test / ui / llvm-asm / llvm-asm-out-assign.rs
1 // run-pass
2
3 #![feature(llvm_asm)]
4 #![allow(deprecated)] // llvm_asm!s
5
6 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
7 pub fn main() {
8 let x: isize;
9 unsafe {
10 // Treat the output as initialization.
11 llvm_asm!("mov $1, $0" : "=r"(x) : "r"(5_usize));
12 }
13 assert_eq!(x, 5);
14
15 let mut x = x + 1;
16 assert_eq!(x, 6);
17
18 unsafe {
19 // Assignment to mutable.
20 llvm_asm!("mov $1, $0" : "=r"(x) : "r"(x + 7));
21 }
22 assert_eq!(x, 13);
23 }
24
25 #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
26 pub fn main() {}