]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
coroutines, c++: Add test for PR 96517.
authorIain Sandoe <iain@sandoe.co.uk>
Fri, 15 Oct 2021 08:42:25 +0000 (09:42 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Fri, 17 Dec 2021 16:54:35 +0000 (16:54 +0000)
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.

gcc/testsuite/g++.dg/coroutines/pr96517.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/coroutines/pr96517.C b/gcc/testsuite/g++.dg/coroutines/pr96517.C
new file mode 100644 (file)
index 0000000..9cbac3e
--- /dev/null
@@ -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() {}