https://gcc.gnu.org/g:2492bab503f57f2cf6e08e5c104f7a1d31d34047

commit r16-2149-g2492bab503f57f2cf6e08e5c104f7a1d31d34047
Author: Jason Merrill <ja...@redhat.com>
Date:   Wed Jul 9 11:13:19 2025 -0400

    c++: add passing testcases [PR120243]
    
    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.

Diff:
---
 .../coroutines/torture/pr120243-unhandled-1.C      | 33 +++++++++++++++++++++
 .../coroutines/torture/pr120243-unhandled-2.C      | 34 ++++++++++++++++++++++
 2 files changed, 67 insertions(+)

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 000000000000..16bfef16fd8a
--- /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 000000000000..614c4ec9be66
--- /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");
+    }
+}

Reply via email to