]> git.lizzy.rs Git - rust.git/blob - tests/codegen/unwind-abis/cdecl-unwind-abi.rs
Rollup merge of #106797 - FawazTirmizi:dev/issues/104284, r=bjorn3
[rust.git] / tests / codegen / unwind-abis / cdecl-unwind-abi.rs
1 // compile-flags: -C opt-level=0
2
3 // Test that `nounwind` attributes are correctly applied to exported `cdecl` and
4 // `cdecl-unwind` extern functions. `cdecl-unwind` functions MUST NOT have this attribute. We
5 // disable optimizations above to prevent LLVM from inferring the attribute.
6
7 #![crate_type = "lib"]
8 #![feature(c_unwind)]
9
10 // CHECK: @rust_item_that_cannot_unwind() unnamed_addr #0 {
11 #[no_mangle]
12 pub extern "cdecl" fn rust_item_that_cannot_unwind() {
13 }
14
15 // CHECK: @rust_item_that_can_unwind() unnamed_addr #1 {
16 #[no_mangle]
17 pub extern "cdecl-unwind" fn rust_item_that_can_unwind() {
18 }
19
20 // Now, make some assertions that the LLVM attributes for these functions are correct.  First, make
21 // sure that the first item is correctly marked with the `nounwind` attribute:
22 //
23 // CHECK: attributes #0 = { {{.*}}nounwind{{.*}} }
24 //
25 // Next, let's assert that the second item, which CAN unwind, does not have this attribute.
26 //
27 // CHECK: attributes #1 = {
28 // CHECK-NOT: nounwind
29 // CHECK: }