about summary refs log tree commit diff
path: root/tests/codegen
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-02-08 21:11:17 +0000
committerbors <bors@rust-lang.org>2025-02-08 21:11:17 +0000
commit43ca9d18e333797f0aa3b525501a7cec8d61a96b (patch)
tree9ddd9f6cedb817b31bb6b0b19e17f8f1a5526b10 /tests/codegen
parent73bf7947e9ab731bf2764db219cd9cda216a3aed (diff)
parent45771e43babdecb3b6a74776c8ebdc30e0f31d1c (diff)
downloadrust-43ca9d18e333797f0aa3b525501a7cec8d61a96b.tar.gz
rust-43ca9d18e333797f0aa3b525501a7cec8d61a96b.zip
Auto merge of #136747 - matthiaskrgr:rollup-qfiiv4n, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #135696 (std: move `io` module out of `pal`, get rid of `sys_common::io`)
 - #136099 (Optimize `Rc::<str>::default()` implementation)
 - #136200 (Generate correct terminate block under Wasm EH)
 - #136626 (create `initial_rustdoc` field in `Build`)
 - #136657 (Make empty-line-after an early clippy lint)
 - #136679 (ci: Use largedisk for loongarch)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'tests/codegen')
-rw-r--r--tests/codegen/terminating-catchpad.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/codegen/terminating-catchpad.rs b/tests/codegen/terminating-catchpad.rs
new file mode 100644
index 00000000000..17d88796300
--- /dev/null
+++ b/tests/codegen/terminating-catchpad.rs
@@ -0,0 +1,37 @@
+//@ revisions: emscripten wasi seh
+//@[emscripten] compile-flags: --target wasm32-unknown-emscripten -Z emscripten-wasm-eh
+//@[wasi] compile-flags: --target wasm32-wasip1 -C panic=unwind
+//@[seh] compile-flags: --target x86_64-pc-windows-msvc
+//@[emscripten] needs-llvm-components: webassembly
+//@[wasi] needs-llvm-components: webassembly
+//@[seh] needs-llvm-components: x86
+
+// Ensure a catch-all generates:
+// - `catchpad ... [ptr null]` on Wasm (otherwise LLVM gets confused)
+// - `catchpad ... [ptr null, i32 64, ptr null]` on Windows (otherwise we catch SEH exceptions)
+
+#![feature(no_core, lang_items, rustc_attrs)]
+#![crate_type = "lib"]
+#![no_std]
+#![no_core]
+
+#[lang = "sized"]
+trait Sized {}
+
+unsafe extern "C-unwind" {
+    safe fn unwinds();
+}
+
+#[lang = "panic_cannot_unwind"]
+fn panic_cannot_unwind() -> ! {
+    loop {}
+}
+
+#[no_mangle]
+#[rustc_nounwind]
+pub fn doesnt_unwind() {
+    // emscripten: %catchpad = catchpad within %catchswitch [ptr null]
+    // wasi: %catchpad = catchpad within %catchswitch [ptr null]
+    // seh: %catchpad = catchpad within %catchswitch [ptr null, i32 64, ptr null]
+    unwinds();
+}