]> git.proxmox.com Git - rustc.git/blob - src/test/ui/asm/naked-invalid-attr.rs
New upstream version 1.53.0+dfsg1
[rustc.git] / src / test / ui / asm / naked-invalid-attr.rs
1 // Checks that #[naked] attribute can be placed on function definitions only.
2 //
3 // needs-asm-support
4 #![feature(asm)]
5 #![feature(naked_functions)]
6 #![naked] //~ ERROR should be applied to a function definition
7
8 extern "C" {
9 #[naked] //~ ERROR should be applied to a function definition
10 fn f();
11 }
12
13 #[naked] //~ ERROR should be applied to a function definition
14 #[repr(C)]
15 struct S {
16 a: u32,
17 b: u32,
18 }
19
20 trait Invoke {
21 #[naked] //~ ERROR should be applied to a function definition
22 extern "C" fn invoke(&self);
23 }
24
25 impl Invoke for S {
26 #[naked]
27 extern "C" fn invoke(&self) {
28 unsafe { asm!("", options(noreturn)) }
29 }
30 }
31
32 #[naked]
33 extern "C" fn ok() {
34 unsafe { asm!("", options(noreturn)) }
35 }
36
37 impl S {
38 #[naked]
39 extern "C" fn g() {
40 unsafe { asm!("", options(noreturn)) }
41 }
42
43 #[naked]
44 extern "C" fn h(&self) {
45 unsafe { asm!("", options(noreturn)) }
46 }
47 }
48
49 fn main() {
50 #[naked] || {}; //~ ERROR should be applied to a function definition
51 }