[gcc r12-6044] coroutines, c++: Add test for PR 96517.

Iain D Sandoe iains@gcc.gnu.org
Fri Dec 17 16:55:02 GMT 2021


https://gcc.gnu.org/g:39d2ec41509e3b0d130215a65d7aacbd064b5532

commit r12-6044-g39d2ec41509e3b0d130215a65d7aacbd064b5532
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Fri Oct 15 09:42:25 2021 +0100

    coroutines, c++: Add test for PR 96517.
    
    This PR was fixed by r12-5255-gdaa9c6b015, this adds
    the testcase.
    
    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
    
    gcc/testsuite/ChangeLog:
    
            PR c++/96517
            * g++.dg/coroutines/pr96517.C: New test.

Diff:
---
 gcc/testsuite/g++.dg/coroutines/pr96517.C | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/gcc/testsuite/g++.dg/coroutines/pr96517.C b/gcc/testsuite/g++.dg/coroutines/pr96517.C
new file mode 100644
index 00000000000..9cbac3ebc0d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/coroutines/pr96517.C
@@ -0,0 +1,29 @@
+// { dg-additional-options " -O1 " }
+#include <coroutine>
+
+struct coroutine {
+    struct promise_type {
+        coroutine get_return_object() { return {}; }
+        void return_void() {}
+        void unhandled_exception() {}
+        auto initial_suspend() noexcept { return std::suspend_never{}; }
+        auto final_suspend() noexcept { return std::suspend_never{}; }
+    };
+};
+
+struct data {
+    constexpr int get() { return 5; }
+};
+
+struct test {
+    data _data;
+
+    void foo() {
+        [this]() -> coroutine {
+            _data.get();
+            co_return;
+        };
+    }
+};
+
+int main() {}


More information about the Gcc-cvs mailing list