]> git.lizzy.rs Git - rust.git/blob - src/test/ui/inline-asm-bad-constraint.rs
Auto merge of #57108 - Mark-Simulacrum:license-remove, r=pietroalbini
[rust.git] / src / test / ui / inline-asm-bad-constraint.rs
1 // Test that the compiler will catch invalid inline assembly constraints.
2
3 // ignore-emscripten
4
5 #![feature(asm)]
6
7 extern "C" {
8     fn foo(a: usize);
9 }
10
11 fn main() {
12     bad_register_constraint();
13     bad_input();
14     wrong_size_output();
15 }
16
17 // Issue #54130
18 fn bad_register_constraint() {
19     let rax: u64;
20     unsafe {
21         asm!("" :"={rax"(rax)) //~ ERROR E0668
22     };
23     println!("Accumulator is: {}", rax);
24 }
25
26 // Issue #54376
27 fn bad_input() {
28     unsafe {
29         asm!("callq $0" : : "0"(foo)) //~ ERROR E0668
30     };
31 }
32
33 fn wrong_size_output() {
34     let rax: u64 = 0;
35     unsafe {
36         asm!("addb $1, $0" : "={rax}"((0i32, rax))); //~ ERROR E0668
37     }
38     println!("rax: {}", rax);
39 }