]> git.lizzy.rs Git - rust.git/blob - src/test/ui/asm/bad-template.rs
Auto merge of #100845 - timvermeulen:iter_compare, r=scottmcm
[rust.git] / src / test / ui / asm / bad-template.rs
1 // revisions: x86_64_mirunsafeck aarch64_mirunsafeck x86_64_thirunsafeck aarch64_thirunsafeck
2
3 // [x86_64_thirunsafeck] compile-flags: -Z thir-unsafeck --target x86_64-unknown-linux-gnu
4 // [aarch64_thirunsafeck] compile-flags: -Z thir-unsafeck --target aarch64-unknown-linux-gnu
5 // [x86_64_mirunsafeck] compile-flags: --target x86_64-unknown-linux-gnu
6 // [aarch64_mirunsafeck] compile-flags: --target aarch64-unknown-linux-gnu
7
8 // [x86_64_thirunsafeck] needs-llvm-components: x86
9 // [x86_64_mirunsafeck] needs-llvm-components: x86
10 // [aarch64_thirunsafeck] needs-llvm-components: aarch64
11 // [aarch64_mirunsafeck] needs-llvm-components: aarch64
12
13 #![feature(no_core, lang_items, rustc_attrs, asm_const)]
14 #![no_core]
15
16 #[rustc_builtin_macro]
17 macro_rules! asm {
18     () => {};
19 }
20 #[rustc_builtin_macro]
21 macro_rules! global_asm {
22     () => {};
23 }
24
25 #[lang = "sized"]
26 trait Sized {}
27
28 fn main() {
29     let mut foo = 0;
30     unsafe {
31         asm!("{}");
32         //~^ ERROR invalid reference to argument at index 0
33         asm!("{1}", in(reg) foo);
34         //~^ ERROR invalid reference to argument at index 1
35         //~^^ ERROR argument never used
36         asm!("{a}");
37         //~^ ERROR there is no argument named `a`
38         asm!("{}", a = in(reg) foo);
39         //~^ ERROR invalid reference to argument at index 0
40         //~^^ ERROR argument never used
41         asm!("{1}", a = in(reg) foo);
42         //~^ ERROR invalid reference to argument at index 1
43         //~^^ ERROR named argument never used
44         #[cfg(any(x86_64_thirunsafeck, x86_64_mirunsafeck))]
45         asm!("{}", in("eax") foo);
46         //[x86_64_thirunsafeck,x86_64_mirunsafeck]~^ ERROR invalid reference to argument at index 0
47         #[cfg(any(aarch64_thirunsafeck, aarch64_mirunsafeck))]
48         asm!("{}", in("x0") foo);
49         //[aarch64_thirunsafeck,aarch64_mirunsafeck]~^ ERROR invalid reference to argument at index 0
50         asm!("{:foo}", in(reg) foo);
51         //~^ ERROR asm template modifier must be a single character
52         //~| WARN formatting may not be suitable for sub-register argument [asm_sub_register]
53         asm!("", in(reg) 0, in(reg) 1);
54         //~^ ERROR multiple unused asm arguments
55     }
56 }
57
58 const FOO: i32 = 1;
59 global_asm!("{}");
60 //~^ ERROR invalid reference to argument at index 0
61 global_asm!("{1}", const FOO);
62 //~^ ERROR invalid reference to argument at index 1
63 //~^^ ERROR argument never used
64 global_asm!("{a}");
65 //~^ ERROR there is no argument named `a`
66 global_asm!("{}", a = const FOO);
67 //~^ ERROR invalid reference to argument at index 0
68 //~^^ ERROR argument never used
69 global_asm!("{1}", a = const FOO);
70 //~^ ERROR invalid reference to argument at index 1
71 //~^^ ERROR named argument never used
72 global_asm!("{:foo}", const FOO);
73 //~^ ERROR asm template modifier must be a single character
74 global_asm!("", const FOO, const FOO);
75 //~^ ERROR multiple unused asm arguments