1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Test that the compiler will catch passing invalid values to inline assembly
29 asm!("" :: "r"("")); //~ ERROR E0669
33 let target = MyPtr(0);
34 asm!("ret" : : "{rdi}"(target)); //~ ERROR E0669
39 let hello: &str = "hello";
40 // this should fail...
41 unsafe { asm!("" :: "i"(hello)) }; //~ ERROR E0669
42 // but this should succeed.
43 unsafe { asm!("" :: "r"(hello.as_ptr())) };
47 let arr: [u8; 1] = [0; 1];
49 asm!("movups $1, %xmm0"::"m"(arr)); //~ ERROR E0669
54 let addr: Option<u32> = Some(123);
56 asm!("mov sp, $0"::"r"(addr)); //~ ERROR E0669
60 fn multiple_errors() {
61 let addr: (u32, u32) = (1, 2);
63 asm!("mov sp, $0"::"r"(addr), //~ ERROR E0669
64 "r"("hello e0669")); //~ ERROR E0669