]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/asm/naked-functions.rs
8 #![feature(naked_functions)]
9 #![feature(or_patterns)]
10 #![feature(asm_const, asm_sym)]
11 #![crate_type = "lib"]
12 #![allow(deprecated)] // llvm_asm!
21 pub unsafe extern "C" fn patterns(
23 //~^ ERROR patterns not allowed in naked function parameters
25 //~^ ERROR patterns not allowed in naked function parameters
26 (None
| Some(_
)): Option
<std
::ptr
::NonNull
<u8>>,
27 //~^ ERROR patterns not allowed in naked function parameters
29 //~^ ERROR patterns not allowed in naked function parameters
31 asm
!("", options(noreturn
))
35 pub unsafe extern "C" fn inc(a
: u32) -> u32 {
36 //~^ WARN naked functions must contain a single asm block
37 //~| WARN this was previously accepted
39 //~^ ERROR referencing function parameters is not allowed in naked functions
43 pub unsafe extern "C" fn inc_asm(a
: u32) -> u32 {
44 asm
!("/* {0} */", in(reg
) a
, options(noreturn
));
45 //~^ ERROR referencing function parameters is not allowed in naked functions
46 //~| WARN only `const` and `sym` operands are supported in naked functions
47 //~| WARN this was previously accepted
51 pub unsafe extern "C" fn inc_closure(a
: u32) -> u32 {
52 //~^ WARN naked functions must contain a single asm block
53 //~| WARN this was previously accepted
58 pub unsafe extern "C" fn unsupported_operands() {
59 //~^ WARN naked functions must contain a single asm block
60 //~| WARN this was previously accepted
66 const F
: usize = 0usize
;
67 static G
: usize = 0usize
;
68 asm
!("/* {0} {1} {2} {3} {4} {5} {6} */",
69 //~^ WARN asm in naked functions must use `noreturn` option
70 //~| WARN this was previously accepted
72 //~^ WARN only `const` and `sym` operands are supported in naked functions
73 //~| WARN this was previously accepted
84 pub extern "C" fn missing_assembly() {
85 //~^ WARN naked functions must contain a single asm block
86 //~| WARN this was previously accepted
90 pub extern "C" fn too_many_asm_blocks() {
91 //~^ WARN naked functions must contain a single asm block
92 //~| WARN this was previously accepted
94 //~^ WARN asm in naked functions must use `noreturn` option
95 //~| WARN this was previously accepted
97 //~^ WARN asm in naked functions must use `noreturn` option
98 //~| WARN this was previously accepted
100 //~^ WARN asm in naked functions must use `noreturn` option
101 //~| WARN this was previously accepted
102 asm
!("", options(noreturn
));
105 pub fn outer(x
: u32) -> extern "C" fn(usize) -> usize {
107 pub extern "C" fn inner(y
: usize) -> usize {
108 //~^ WARN naked functions must contain a single asm block
109 //~| WARN this was previously accepted
111 //~^ ERROR referencing function parameters is not allowed in naked functions
117 unsafe extern "C" fn llvm() -> ! {
118 //~^ WARN naked functions must contain a single asm block
119 //~| WARN this was previously accepted
121 //~^ WARN LLVM-style inline assembly is unsupported in naked functions
122 //~| WARN this was previously accepted
123 core
::hint
::unreachable_unchecked();
127 unsafe extern "C" fn invalid_options() {
128 asm
!("", options(nomem
, preserves_flags
, noreturn
));
129 //~^ WARN asm options unsupported in naked functions: `nomem`, `preserves_flags`
130 //~| WARN this was previously accepted
134 unsafe extern "C" fn invalid_options_continued() {
135 asm
!("", options(readonly
, nostack
), options(pure));
136 //~^ ERROR asm with the `pure` option must have at least one output
137 //~| WARN asm options unsupported in naked functions: `nostack`, `pure`, `readonly`
138 //~| WARN this was previously accepted
139 //~| WARN asm in naked functions must use `noreturn` option
140 //~| WARN this was previously accepted
144 pub unsafe fn default_abi() {
145 //~^ WARN Rust ABI is unsupported in naked functions
146 asm
!("", options(noreturn
));
150 pub unsafe fn rust_abi() {
151 //~^ WARN Rust ABI is unsupported in naked functions
152 asm
!("", options(noreturn
));
156 pub extern "C" fn valid_a
<T
>() -> T
{
158 asm
!("", options(noreturn
));
163 pub extern "C" fn valid_b() {
167 asm
!("", options(noreturn
));
174 pub unsafe extern "C" fn valid_c() {
175 asm
!("", options(noreturn
));
178 #[cfg(target_arch = "x86_64")]
180 pub unsafe extern "C" fn valid_att_syntax() {
181 asm
!("", options(noreturn
, att_syntax
));
185 pub unsafe extern "C" fn inline_none() {
186 asm
!("", options(noreturn
));
191 //~^ WARN naked functions cannot be inlined
192 //~| WARN this was previously accepted
193 pub unsafe extern "C" fn inline_hint() {
194 asm
!("", options(noreturn
));
199 //~^ WARN naked functions cannot be inlined
200 //~| WARN this was previously accepted
201 pub unsafe extern "C" fn inline_always() {
202 asm
!("", options(noreturn
));
207 //~^ WARN naked functions cannot be inlined
208 //~| WARN this was previously accepted
209 pub unsafe extern "C" fn inline_never() {
210 asm
!("", options(noreturn
));
215 //~^ WARN naked functions cannot be inlined
216 //~| WARN this was previously accepted
218 //~^ WARN naked functions cannot be inlined
219 //~| WARN this was previously accepted
221 //~^ WARN naked functions cannot be inlined
222 //~| WARN this was previously accepted
223 pub unsafe extern "C" fn inline_all() {
224 asm
!("", options(noreturn
));