]> git.lizzy.rs Git - rust.git/blob - tests/codegen/unwind-abis/c-unwind-abi.rs
Rollup merge of #106664 - chenyukang:yukang/fix-106597-remove-lseek, r=cuviper
[rust.git] / tests / codegen / unwind-abis / c-unwind-abi.rs
1 // compile-flags: -C opt-level=0
2
3 // Test that `nounwind` attributes are correctly applied to exported `C` and `C-unwind` extern
4 // functions. `C-unwind` functions MUST NOT have this attribute. We disable optimizations above
5 // 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 "C" fn rust_item_that_cannot_unwind() {
13 }
14
15 // CHECK: @rust_item_that_can_unwind() unnamed_addr #1 {
16 #[no_mangle]
17 pub extern "C-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: }