]> git.lizzy.rs Git - rust.git/blob - tests/codegen/unwind-abis/stdcall-unwind-abi.rs
Rollup merge of #107700 - jyn514:tools-builder, r=Mark-Simulacrum
[rust.git] / tests / codegen / unwind-abis / stdcall-unwind-abi.rs
1 // needs-llvm-components: x86
2 // compile-flags: --target=i686-pc-windows-msvc --crate-type=rlib -Cno-prepopulate-passes
3 #![no_core]
4 #![feature(no_core, lang_items, c_unwind)]
5 #[lang="sized"]
6 trait Sized { }
7
8 // Test that `nounwind` attributes are correctly applied to exported `stdcall` and `stdcall-unwind`
9 // extern functions. `stdcall-unwind` functions MUST NOT have this attribute. We disable
10 // optimizations above to prevent LLVM from inferring the attribute.
11
12 // CHECK: @rust_item_that_cannot_unwind() unnamed_addr #0 {
13 #[no_mangle]
14 pub extern "stdcall" fn rust_item_that_cannot_unwind() {
15 }
16
17 // CHECK: @rust_item_that_can_unwind() unnamed_addr #1 {
18 #[no_mangle]
19 pub extern "stdcall-unwind" fn rust_item_that_can_unwind() {
20 }
21
22 // Now, make some assertions that the LLVM attributes for these functions are correct.  First, make
23 // sure that the first item is correctly marked with the `nounwind` attribute:
24 //
25 // CHECK: attributes #0 = { {{.*}}nounwind{{.*}} }
26 //
27 // Next, let's assert that the second item, which CAN unwind, does not have this attribute.
28 //
29 // CHECK: attributes #1 = {
30 // CHECK-NOT: nounwind
31 // CHECK: }