7 #![feature(naked_functions)]
8 #![feature(or_patterns)]
9 #![feature(asm_const, asm_sym)]
10 #![crate_type = "lib"]
11 #![allow(deprecated)] // llvm_asm!
22 pub unsafe extern "C" fn patterns(
24 //~^ ERROR patterns not allowed in naked function parameters
26 //~^ ERROR patterns not allowed in naked function parameters
27 (None | Some(_)): Option<std::ptr::NonNull<u8>>,
28 //~^ ERROR patterns not allowed in naked function parameters
30 //~^ ERROR patterns not allowed in naked function parameters
32 asm!("", options(noreturn))
36 pub unsafe extern "C" fn inc(a: u32) -> u32 {
37 //~^ WARN naked functions must contain a single asm block
38 //~| WARN this was previously accepted
40 //~^ ERROR referencing function parameters is not allowed in naked functions
44 pub unsafe extern "C" fn inc_asm(a: u32) -> u32 {
45 asm!("/* {0} */", in(reg) a, options(noreturn));
46 //~^ ERROR referencing function parameters is not allowed in naked functions
47 //~| WARN only `const` and `sym` operands are supported in naked functions
48 //~| WARN this was previously accepted
52 pub unsafe extern "C" fn inc_closure(a: u32) -> u32 {
53 //~^ WARN naked functions must contain a single asm block
54 //~| WARN this was previously accepted
59 pub unsafe extern "C" fn unsupported_operands() {
60 //~^ WARN naked functions must contain a single asm block
61 //~| WARN this was previously accepted
67 const F: usize = 0usize;
68 static G: usize = 0usize;
69 asm!("/* {0} {1} {2} {3} {4} {5} {6} */",
70 //~^ WARN asm in naked functions must use `noreturn` option
71 //~| WARN this was previously accepted
73 //~^ WARN only `const` and `sym` operands are supported in naked functions
74 //~| WARN this was previously accepted
85 pub extern "C" fn missing_assembly() {
86 //~^ WARN naked functions must contain a single asm block
87 //~| WARN this was previously accepted
91 pub extern "C" fn too_many_asm_blocks() {
92 //~^ WARN naked functions must contain a single asm block
93 //~| WARN this was previously accepted
95 //~^ WARN asm in naked functions must use `noreturn` option
96 //~| WARN this was previously accepted
98 //~^ WARN asm in naked functions must use `noreturn` option
99 //~| WARN this was previously accepted
101 //~^ WARN asm in naked functions must use `noreturn` option
102 //~| WARN this was previously accepted
103 asm!("", options(noreturn));
106 pub fn outer(x: u32) -> extern "C" fn(usize) -> usize {
108 pub extern "C" fn inner(y: usize) -> usize {
109 //~^ WARN naked functions must contain a single asm block
110 //~| WARN this was previously accepted
112 //~^ ERROR referencing function parameters is not allowed in naked functions
118 unsafe extern "C" fn llvm() -> ! {
119 //~^ WARN naked functions must contain a single asm block
120 //~| WARN this was previously accepted
122 //~^ WARN LLVM-style inline assembly is unsupported in naked functions
123 //~| WARN this was previously accepted
124 core::hint::unreachable_unchecked();
128 unsafe extern "C" fn invalid_options() {
129 asm!("", options(nomem, preserves_flags, noreturn));
130 //~^ WARN asm options unsupported in naked functions: `nomem`, `preserves_flags`
131 //~| WARN this was previously accepted
135 unsafe extern "C" fn invalid_options_continued() {
136 asm!("", options(readonly, nostack), options(pure));
137 //~^ ERROR asm with the `pure` option must have at least one output
138 //~| WARN asm options unsupported in naked functions: `nostack`, `pure`, `readonly`
139 //~| WARN this was previously accepted
140 //~| WARN asm in naked functions must use `noreturn` option
141 //~| WARN this was previously accepted
145 pub unsafe fn default_abi() {
146 //~^ WARN Rust ABI is unsupported in naked functions
147 asm!("", options(noreturn));
151 pub unsafe fn rust_abi() {
152 //~^ WARN Rust ABI is unsupported in naked functions
153 asm!("", options(noreturn));
157 pub extern "C" fn valid_a<T>() -> T {
159 asm!("", options(noreturn));
164 pub extern "C" fn valid_b() {
168 asm!("", options(noreturn));
175 pub unsafe extern "C" fn valid_c() {
176 asm!("", options(noreturn));
179 #[cfg(target_arch = "x86_64")]
181 pub unsafe extern "C" fn valid_att_syntax() {
182 asm!("", options(noreturn, att_syntax));
186 pub unsafe extern "C" fn inline_none() {
187 asm!("", options(noreturn));
192 //~^ WARN naked functions cannot be inlined
193 //~| WARN this was previously accepted
194 pub unsafe extern "C" fn inline_hint() {
195 asm!("", options(noreturn));
200 //~^ WARN naked functions cannot be inlined
201 //~| WARN this was previously accepted
202 pub unsafe extern "C" fn inline_always() {
203 asm!("", options(noreturn));
208 //~^ WARN naked functions cannot be inlined
209 //~| WARN this was previously accepted
210 pub unsafe extern "C" fn inline_never() {
211 asm!("", options(noreturn));
216 //~^ WARN naked functions cannot be inlined
217 //~| WARN this was previously accepted
219 //~^ WARN naked functions cannot be inlined
220 //~| WARN this was previously accepted
222 //~^ WARN naked functions cannot be inlined
223 //~| WARN this was previously accepted
224 pub unsafe extern "C" fn inline_all() {
225 asm!("", options(noreturn));