diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
commit | 1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch) | |
tree | 3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /tests/run-make-fulldeps/foreign-exceptions/foo.cpp | |
parent | Releasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/run-make-fulldeps/foreign-exceptions/foo.cpp')
-rw-r--r-- | tests/run-make-fulldeps/foreign-exceptions/foo.cpp | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/tests/run-make-fulldeps/foreign-exceptions/foo.cpp b/tests/run-make-fulldeps/foreign-exceptions/foo.cpp deleted file mode 100644 index 8182021a2..000000000 --- a/tests/run-make-fulldeps/foreign-exceptions/foo.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include <assert.h> -#include <stddef.h> -#include <stdio.h> - -void println(const char* s) { - puts(s); - fflush(stdout); -} - -struct exception {}; -struct rust_panic {}; - -struct drop_check { - bool* ok; - ~drop_check() { - println("~drop_check"); - - if (ok) - *ok = true; - } -}; - -extern "C" { - void rust_catch_callback(void (*cb)(), bool* rust_ok); - - void throw_cxx_exception() { - println("throwing C++ exception"); - throw exception(); - } - - void test_cxx_exception() { - bool rust_ok = false; - try { - rust_catch_callback(throw_cxx_exception, &rust_ok); - assert(false && "unreachable"); - } catch (exception e) { - println("caught C++ exception"); - assert(rust_ok); - return; - } - assert(false && "did not catch thrown C++ exception"); - } - - void cxx_catch_callback(void (*cb)(), bool* cxx_ok) { - drop_check x; - x.ok = NULL; - try { - cb(); - } catch (rust_panic e) { - assert(false && "shouldn't be able to catch a rust panic"); - } catch (...) { - println("caught foreign exception in catch (...)"); - // Foreign exceptions are caught by catch (...). We only set the ok - // flag if we successfully caught the panic. The destructor of - // drop_check will then set the flag to true if it is executed. - x.ok = cxx_ok; - throw; - } - } -} |