4 #![feature(naked_functions)]
5 #![feature(or_patterns)]
9 pub struct P { x: u8, y: u16 }
12 pub unsafe extern "C" fn patterns(
14 //~^ ERROR patterns not allowed in naked function parameters
16 //~^ ERROR patterns not allowed in naked function parameters
17 (None | Some(_)): Option<std::ptr::NonNull<u8>>,
18 //~^ ERROR patterns not allowed in naked function parameters
20 //~^ ERROR patterns not allowed in naked function parameters
22 asm!("", options(noreturn))
26 pub unsafe extern "C" fn inc(a: u32) -> u32 {
27 //~^ WARN naked functions must contain a single asm block
28 //~| WARN this was previously accepted
30 //~^ ERROR referencing function parameters is not allowed in naked functions
34 pub unsafe extern "C" fn inc_asm(a: u32) -> u32 {
35 asm!("/* {0} */", in(reg) a, options(noreturn));
36 //~^ ERROR referencing function parameters is not allowed in naked functions
37 //~| WARN only `const` and `sym` operands are supported in naked functions
38 //~| WARN this was previously accepted
42 pub unsafe extern "C" fn inc_closure(a: u32) -> u32 {
43 //~^ WARN naked functions must contain a single asm block
44 //~| WARN this was previously accepted
49 pub unsafe extern "C" fn unsupported_operands() {
50 //~^ WARN naked functions must contain a single asm block
51 //~| WARN this was previously accepted
57 const F: usize = 0usize;
58 static G: usize = 0usize;
59 asm!("/* {0} {1} {2} {3} {4} {5} {6} */",
60 //~^ WARN asm in naked functions must use `noreturn` option
61 //~| WARN this was previously accepted
63 //~^ WARN only `const` and `sym` operands are supported in naked functions
64 //~| WARN this was previously accepted
75 pub extern "C" fn missing_assembly() {
76 //~^ WARN naked functions must contain a single asm block
77 //~| WARN this was previously accepted
81 pub extern "C" fn too_many_asm_blocks() {
82 //~^ WARN naked functions must contain a single asm block
83 //~| WARN this was previously accepted
85 //~^ WARN asm in naked functions must use `noreturn` option
86 //~| WARN this was previously accepted
88 //~^ WARN asm in naked functions must use `noreturn` option
89 //~| WARN this was previously accepted
91 //~^ WARN asm in naked functions must use `noreturn` option
92 //~| WARN this was previously accepted
93 asm!("", options(noreturn));
96 pub fn outer(x: u32) -> extern "C" fn(usize) -> usize {
98 pub extern "C" fn inner(y: usize) -> usize {
99 //~^ WARN naked functions must contain a single asm block
100 //~| WARN this was previously accepted
102 //~^ ERROR referencing function parameters is not allowed in naked functions
108 unsafe extern "C" fn llvm() -> ! {
109 //~^ WARN naked functions must contain a single asm block
110 //~| WARN this was previously accepted
112 //~^ WARN LLVM-style inline assembly is unsupported in naked functions
113 //~| WARN this was previously accepted
114 core::hint::unreachable_unchecked();
118 unsafe extern "C" fn invalid_options() {
119 asm!("", options(nomem, preserves_flags, noreturn));
120 //~^ WARN asm options unsupported in naked functions: `nomem`, `preserves_flags`
121 //~| WARN this was previously accepted
125 unsafe extern "C" fn invalid_options_continued() {
126 asm!("", options(readonly, nostack), options(pure));
127 //~^ ERROR asm with `pure` option must have at least one output
128 //~| WARN asm options unsupported in naked functions: `nostack`, `pure`, `readonly`
129 //~| WARN this was previously accepted
130 //~| WARN asm in naked functions must use `noreturn` option
131 //~| WARN this was previously accepted
135 pub unsafe fn default_abi() {
136 //~^ WARN Rust ABI is unsupported in naked functions
137 //~| WARN this was previously accepted
138 asm!("", options(noreturn));
142 pub unsafe extern "Rust" fn rust_abi() {
143 //~^ WARN Rust ABI is unsupported in naked functions
144 //~| WARN this was previously accepted
145 asm!("", options(noreturn));
149 pub extern "C" fn valid_a<T>() -> T {
150 unsafe { asm!("", options(noreturn)); }
154 pub extern "C" fn valid_b() {
156 asm!("", options(noreturn)); ; ; ;
161 pub unsafe extern "C" fn valid_c() {
162 asm!("", options(noreturn));
165 #[cfg(target_arch = "x86_64")]
167 pub unsafe extern "C" fn valid_att_syntax() {
168 asm!("", options(noreturn, att_syntax));