]> git.lizzy.rs Git - rust.git/blob - src/test/ui/asm/naked-invalid-attr.rs
Auto merge of #98471 - wesleywiser:update_measureme, r=Mark-Simulacrum
[rust.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(naked_functions)]
5 #![naked] //~ ERROR should be applied to a function definition
6
7 use std::arch::asm;
8
9 extern "C" {
10     #[naked] //~ ERROR should be applied to a function definition
11     fn f();
12 }
13
14 #[naked] //~ ERROR should be applied to a function definition
15 #[repr(C)]
16 struct S {
17     a: u32,
18     b: u32,
19 }
20
21 trait Invoke {
22     #[naked] //~ ERROR should be applied to a function definition
23     extern "C" fn invoke(&self);
24 }
25
26 impl Invoke for S {
27     #[naked]
28     extern "C" fn invoke(&self) {
29         unsafe { asm!("", options(noreturn)) }
30     }
31 }
32
33 #[naked]
34 extern "C" fn ok() {
35     unsafe { asm!("", options(noreturn)) }
36 }
37
38 impl S {
39     #[naked]
40     extern "C" fn g() {
41         unsafe { asm!("", options(noreturn)) }
42     }
43
44     #[naked]
45     extern "C" fn h(&self) {
46         unsafe { asm!("", options(noreturn)) }
47     }
48 }
49
50 fn main() {
51     #[naked] || {}; //~ ERROR should be applied to a function definition
52 }