about summary refs log tree commit diff
path: root/src/test/ui/llvm-asm/llvm-asm-out-assign-imm.rs
blob: 7f51b50f2586f096574014cc9a9beece033d0622 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// ignore-s390x
// ignore-emscripten
// ignore-powerpc
// ignore-powerpc64
// ignore-powerpc64le
// ignore-riscv64
// ignore-sparc
// ignore-sparc64
// ignore-mips
// ignore-mips64

#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!

fn foo(x: isize) { println!("{}", x); }

#[cfg(any(target_arch = "x86",
          target_arch = "x86_64",
          target_arch = "arm",
          target_arch = "aarch64"))]
pub fn main() {
    let x: isize;
    x = 1;
    foo(x);
    unsafe {
        llvm_asm!("mov $1, $0" : "=r"(x) : "r"(5));
        //~^ ERROR cannot assign twice to immutable variable `x`
    }
    foo(x);
}

#[cfg(not(any(target_arch = "x86",
              target_arch = "x86_64",
              target_arch = "arm",
              target_arch = "aarch64")))]
pub fn main() {}