6 #![feature(naked_functions)]
7 #![feature(asm_const, 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 #[allow(asm_sub_register)]
41 pub unsafe extern "C" fn inc_asm(a: u32) -> u32 {
42 asm!("/* {0} */", in(reg) a, options(noreturn));
43 //~^ ERROR referencing function parameters is not allowed in naked functions
44 //~| ERROR only `const` and `sym` operands are supported in naked functions
48 pub unsafe extern "C" fn inc_closure(a: u32) -> u32 {
49 //~^ ERROR naked functions must contain a single asm block
54 pub unsafe extern "C" fn unsupported_operands() {
55 //~^ ERROR naked functions must contain a single asm block
61 const F: usize = 0usize;
62 static G: usize = 0usize;
63 asm!("/* {0} {1} {2} {3} {4} {5} {6} */",
64 //~^ ERROR asm in naked functions must use `noreturn` option
66 //~^ ERROR only `const` and `sym` operands are supported in naked functions
77 pub extern "C" fn missing_assembly() {
78 //~^ ERROR naked functions must contain a single asm block
82 pub extern "C" fn too_many_asm_blocks() {
83 //~^ ERROR naked functions must contain a single asm block
85 //~^ ERROR asm in naked functions must use `noreturn` option
87 //~^ ERROR asm in naked functions must use `noreturn` option
89 //~^ ERROR asm in naked functions must use `noreturn` option
90 asm!("", options(noreturn));
93 pub fn outer(x: u32) -> extern "C" fn(usize) -> usize {
95 pub extern "C" fn inner(y: usize) -> usize {
96 //~^ ERROR naked functions must contain a single asm block
98 //~^ ERROR referencing function parameters is not allowed in naked functions
104 unsafe extern "C" fn invalid_options() {
105 asm!("", options(nomem, preserves_flags, noreturn));
106 //~^ ERROR asm options unsupported in naked functions: `nomem`, `preserves_flags`
110 unsafe extern "C" fn invalid_options_continued() {
111 asm!("", options(readonly, nostack), options(pure));
112 //~^ ERROR asm with the `pure` option must have at least one output
113 //~| ERROR asm options unsupported in naked functions: `nostack`, `pure`, `readonly`
114 //~| ERROR asm in naked functions must use `noreturn` option
118 unsafe extern "C" fn invalid_may_unwind() {
119 asm!("", options(noreturn, may_unwind));
120 //~^ ERROR asm options unsupported in naked functions: `may_unwind`
124 pub unsafe fn default_abi() {
125 //~^ WARN Rust ABI is unsupported in naked functions
126 asm!("", options(noreturn));
130 pub unsafe fn rust_abi() {
131 //~^ WARN Rust ABI is unsupported in naked functions
132 asm!("", options(noreturn));
136 pub extern "C" fn valid_a<T>() -> T {
138 asm!("", options(noreturn));
143 pub extern "C" fn valid_b() {
147 asm!("", options(noreturn));
154 pub unsafe extern "C" fn valid_c() {
155 asm!("", options(noreturn));
158 #[cfg(target_arch = "x86_64")]
160 pub unsafe extern "C" fn valid_att_syntax() {
161 asm!("", options(noreturn, att_syntax));
165 pub unsafe extern "C" fn inline_none() {
166 asm!("", options(noreturn));
171 //~^ ERROR naked functions cannot be inlined
172 pub unsafe extern "C" fn inline_hint() {
173 asm!("", options(noreturn));
178 //~^ ERROR naked functions cannot be inlined
179 pub unsafe extern "C" fn inline_always() {
180 asm!("", options(noreturn));
185 //~^ ERROR naked functions cannot be inlined
186 pub unsafe extern "C" fn inline_never() {
187 asm!("", options(noreturn));
192 //~^ ERROR naked functions cannot be inlined
194 //~^ ERROR naked functions cannot be inlined
196 //~^ ERROR naked functions cannot be inlined
197 pub unsafe extern "C" fn inline_all() {
198 asm!("", options(noreturn));
202 pub unsafe extern "C" fn allow_compile_error(a: u32) -> u32 {
203 compile_error!("this is a user specified error")
204 //~^ ERROR this is a user specified error
208 pub unsafe extern "C" fn allow_compile_error_and_asm(a: u32) -> u32 {
209 compile_error!("this is a user specified error");
210 //~^ ERROR this is a user specified error
211 asm!("", options(noreturn))
215 pub unsafe extern "C" fn invalid_asm_syntax(a: u32) -> u32 {
217 //~^ ERROR asm template must be a string literal