6 #![feature(naked_functions)]
7 #![feature(asm_const, asm_sym, asm_unwind)]
19 pub unsafe extern "C" fn patterns(
21 //~^ ERROR patterns not allowed in naked function parameters
23 //~^ ERROR patterns not allowed in naked function parameters
24 (None | Some(_)): Option<std::ptr::NonNull<u8>>,
25 //~^ ERROR patterns not allowed in naked function parameters
27 //~^ ERROR patterns not allowed in naked function parameters
29 asm!("", options(noreturn))
33 pub unsafe extern "C" fn inc(a: u32) -> u32 {
34 //~^ ERROR naked functions must contain a single asm block
36 //~^ ERROR referencing function parameters is not allowed in naked functions
40 pub unsafe extern "C" fn inc_asm(a: u32) -> u32 {
41 asm!("/* {0} */", in(reg) a, options(noreturn));
42 //~^ ERROR referencing function parameters is not allowed in naked functions
43 //~| ERROR only `const` and `sym` operands are supported in naked functions
47 pub unsafe extern "C" fn inc_closure(a: u32) -> u32 {
48 //~^ ERROR naked functions must contain a single asm block
53 pub unsafe extern "C" fn unsupported_operands() {
54 //~^ ERROR naked functions must contain a single asm block
60 const F: usize = 0usize;
61 static G: usize = 0usize;
62 asm!("/* {0} {1} {2} {3} {4} {5} {6} */",
63 //~^ ERROR asm in naked functions must use `noreturn` option
65 //~^ ERROR only `const` and `sym` operands are supported in naked functions
76 pub extern "C" fn missing_assembly() {
77 //~^ ERROR naked functions must contain a single asm block
81 pub extern "C" fn too_many_asm_blocks() {
82 //~^ ERROR naked functions must contain a single asm block
84 //~^ ERROR asm in naked functions must use `noreturn` option
86 //~^ ERROR asm in naked functions must use `noreturn` option
88 //~^ ERROR asm in naked functions must use `noreturn` option
89 asm!("", options(noreturn));
92 pub fn outer(x: u32) -> extern "C" fn(usize) -> usize {
94 pub extern "C" fn inner(y: usize) -> usize {
95 //~^ ERROR naked functions must contain a single asm block
97 //~^ ERROR referencing function parameters is not allowed in naked functions
103 unsafe extern "C" fn invalid_options() {
104 asm!("", options(nomem, preserves_flags, noreturn));
105 //~^ ERROR asm options unsupported in naked functions: `nomem`, `preserves_flags`
109 unsafe extern "C" fn invalid_options_continued() {
110 asm!("", options(readonly, nostack), options(pure));
111 //~^ ERROR asm with the `pure` option must have at least one output
112 //~| ERROR asm options unsupported in naked functions: `nostack`, `pure`, `readonly`
113 //~| ERROR asm in naked functions must use `noreturn` option
117 unsafe extern "C" fn invalid_may_unwind() {
118 asm!("", options(noreturn, may_unwind));
119 //~^ ERROR asm options unsupported in naked functions: `may_unwind`
123 pub unsafe fn default_abi() {
124 //~^ WARN Rust ABI is unsupported in naked functions
125 asm!("", options(noreturn));
129 pub unsafe fn rust_abi() {
130 //~^ WARN Rust ABI is unsupported in naked functions
131 asm!("", options(noreturn));
135 pub extern "C" fn valid_a<T>() -> T {
137 asm!("", options(noreturn));
142 pub extern "C" fn valid_b() {
146 asm!("", options(noreturn));
153 pub unsafe extern "C" fn valid_c() {
154 asm!("", options(noreturn));
157 #[cfg(target_arch = "x86_64")]
159 pub unsafe extern "C" fn valid_att_syntax() {
160 asm!("", options(noreturn, att_syntax));
164 pub unsafe extern "C" fn inline_none() {
165 asm!("", options(noreturn));
170 //~^ ERROR naked functions cannot be inlined
171 pub unsafe extern "C" fn inline_hint() {
172 asm!("", options(noreturn));
177 //~^ ERROR naked functions cannot be inlined
178 pub unsafe extern "C" fn inline_always() {
179 asm!("", options(noreturn));
184 //~^ ERROR naked functions cannot be inlined
185 pub unsafe extern "C" fn inline_never() {
186 asm!("", options(noreturn));
191 //~^ ERROR naked functions cannot be inlined
193 //~^ ERROR naked functions cannot be inlined
195 //~^ ERROR naked functions cannot be inlined
196 pub unsafe extern "C" fn inline_all() {
197 asm!("", options(noreturn));