]> git.proxmox.com Git - rustc.git/blob - tests/codegen/unwind-abis/thiscall-unwind-abi.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / codegen / unwind-abis / thiscall-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, abi_thiscall)]
5 #[lang="sized"]
6 trait Sized { }
7
8 // Test that `nounwind` attributes are correctly applied to exported `thiscall` and
9 // `thiscall-unwind` extern functions. `thiscall-unwind` functions MUST NOT have this attribute. We
10 // disable 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 "thiscall" fn rust_item_that_cannot_unwind() {
15 }
16
17 // CHECK: @rust_item_that_can_unwind() unnamed_addr #1 {
18 #[no_mangle]
19 pub extern "thiscall-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: }