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
31 asm!("" :: "r"("")); //~ ERROR E0669
35 let target = MyPtr(0);
36 asm!("ret" : : "{rdi}"(target)); //~ ERROR E0669
41 let hello: &str = "hello";
42 // this should fail...
43 unsafe { asm!("" :: "i"(hello)) }; //~ ERROR E0669
44 // but this should succeed.
45 unsafe { asm!("" :: "r"(hello.as_ptr())) };
49 let arr: [u8; 1] = [0; 1];
51 asm!("movups $1, %xmm0"::"m"(arr)); //~ ERROR E0669
56 let addr: Option<u32> = Some(123);
58 asm!("mov sp, $0"::"r"(addr)); //~ ERROR E0669
62 fn multiple_errors() {
63 let addr: (u32, u32) = (1, 2);
65 asm!("mov sp, $0"::"r"(addr), //~ ERROR E0669
66 "r"("hello e0669")); //~ ERROR E0669