]> git.proxmox.com Git - rustc.git/blob - tests/run-make-fulldeps/foreign-double-unwind/foo.cpp
New upstream version 1.69.0+dfsg1
[rustc.git] / tests / run-make-fulldeps / foreign-double-unwind / foo.cpp
1 #include <cstdio>
2 #include <exception>
3
4 void println(const char* s) {
5 puts(s);
6 fflush(stdout);
7 }
8
9 struct outer_exception {};
10 struct inner_exception {};
11
12 extern "C" {
13 void throw_cxx_exception() {
14 if (std::uncaught_exception()) {
15 println("throwing inner C++ exception");
16 throw inner_exception();
17 } else {
18 println("throwing outer C++ exception");
19 throw outer_exception();
20 }
21 }
22
23 void cxx_catch_callback(void (*cb)()) {
24 try {
25 cb();
26 println("unreachable: callback returns");
27 } catch (outer_exception) {
28 println("unreachable: caught outer exception in catch (...)");
29 } catch (inner_exception) {
30 println("unreachable: caught inner exception in catch (...)");
31 }
32 }
33 }