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