Tested x86_64-pc-linux-gnu, applying to trunk.

-- 8< --

These pass now; the first was fixed by r16-1507.

        PR c++/120243

gcc/testsuite/ChangeLog:

        * g++.dg/coroutines/torture/pr120243-unhandled-1.C: New test.
        * g++.dg/coroutines/torture/pr120243-unhandled-2.C: New test.
---
 .../coroutines/torture/pr120243-unhandled-1.C | 33 ++++++++++++++++++
 .../coroutines/torture/pr120243-unhandled-2.C | 34 +++++++++++++++++++
 2 files changed, 67 insertions(+)
 create mode 100644 
gcc/testsuite/g++.dg/coroutines/torture/pr120243-unhandled-1.C
 create mode 100644 
gcc/testsuite/g++.dg/coroutines/torture/pr120243-unhandled-2.C

diff --git a/gcc/testsuite/g++.dg/coroutines/torture/pr120243-unhandled-1.C 
b/gcc/testsuite/g++.dg/coroutines/torture/pr120243-unhandled-1.C
new file mode 100644
index 00000000000..16bfef16fd8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/coroutines/torture/pr120243-unhandled-1.C
@@ -0,0 +1,33 @@
+// PR c++/120243
+// { dg-do run }
+
+#include <coroutine>
+
+struct coro {
+     struct promise_type {
+        promise_type() = default;
+
+        std::suspend_never initial_suspend() const noexcept { return {}; }
+        std::suspend_never final_suspend() const noexcept { return {}; }
+
+        void unhandled_exception() { throw; }
+
+        coro get_return_object() { return {}; }
+        void return_void() {}
+
+    };
+};
+
+int main() {
+    auto c = []() -> coro {
+        throw "hello";
+        __builtin_abort();
+        co_return;
+    };
+    try {
+        c();
+    }
+    catch(...) {
+        __builtin_printf("Caught!\n");
+    }
+}
diff --git a/gcc/testsuite/g++.dg/coroutines/torture/pr120243-unhandled-2.C 
b/gcc/testsuite/g++.dg/coroutines/torture/pr120243-unhandled-2.C
new file mode 100644
index 00000000000..614c4ec9be6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/coroutines/torture/pr120243-unhandled-2.C
@@ -0,0 +1,34 @@
+// PR c++/120243
+// { dg-do run }
+
+#include <coroutine>
+
+struct coro {
+     struct promise_type {
+        promise_type() = default;
+
+        std::suspend_always initial_suspend() const noexcept { return {}; }
+        std::suspend_always final_suspend() const noexcept { return {}; }
+
+        void unhandled_exception() { throw; }
+
+        coro get_return_object() { return 
{std::coroutine_handle<promise_type>::from_promise(*this)}; }
+        void return_void() {}
+    };
+
+    std::coroutine_handle<promise_type> h;
+};
+
+int main() {
+    auto c = []() -> coro {
+        throw "hello";
+        __builtin_abort();
+        co_return;
+    };
+    try {
+        c().h.resume();
+    }
+    catch(...) {
+        __builtin_printf("Caught!\n");
+    }
+}

base-commit: d1c92ea10d30e4cf359faa8bbe3782ed6173d8a9
-- 
2.49.0

Reply via email to