[libcxx] r304124 - Fix multiple bugs in coroutine tests.
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Sun May 28 22:00:25 PDT 2017
Author: ericwf
Date: Mon May 29 00:00:24 2017
New Revision: 304124
URL: http://llvm.org/viewvc/llvm-project?rev=304124&view=rev
Log:
Fix multiple bugs in coroutine tests.
Modified:
libcxx/trunk/include/experimental/coroutine
libcxx/trunk/test/libcxx/experimental/language.support/support.coroutines/dialect_support.sh.cpp
Modified: libcxx/trunk/include/experimental/coroutine
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/coroutine?rev=304124&r1=304123&r2=304124&view=diff
==============================================================================
--- libcxx/trunk/include/experimental/coroutine (original)
+++ libcxx/trunk/include/experimental/coroutine Mon May 29 00:00:24 2017
@@ -212,6 +212,9 @@ public:
return __tmp;
}
+ // from_address cannot be used with the coroutines promise type.
+ static coroutine_handle from_address(_Promise*) = delete;
+
_LIBCPP_ALWAYS_INLINE
static coroutine_handle from_promise(_Promise& __promise) _NOEXCEPT {
coroutine_handle __tmp;
Modified: libcxx/trunk/test/libcxx/experimental/language.support/support.coroutines/dialect_support.sh.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/language.support/support.coroutines/dialect_support.sh.cpp?rev=304124&r1=304123&r2=304124&view=diff
==============================================================================
--- libcxx/trunk/test/libcxx/experimental/language.support/support.coroutines/dialect_support.sh.cpp (original)
+++ libcxx/trunk/test/libcxx/experimental/language.support/support.coroutines/dialect_support.sh.cpp Mon May 29 00:00:24 2017
@@ -27,11 +27,11 @@ coro::suspend_never sn;
struct MyFuture {
struct promise_type {
typedef coro::coroutine_handle<promise_type> HandleT;
- coro::suspend_always initial_suspend() { return sa; }
- coro::suspend_never final_suspend() { return sn; }
+ coro::suspend_never initial_suspend() { return sn; }
+ coro::suspend_always final_suspend() { return sa; }
coro::suspend_never yield_value(int) { return sn; }
MyFuture get_return_object() {
- MyFuture f(HandleT::from_address(this));
+ MyFuture f(HandleT::from_promise(*this));
return f;
}
void return_void() {}
@@ -41,7 +41,6 @@ struct MyFuture {
MyFuture() : p() {}
MyFuture(HandleT h) : p(h) {}
-private:
coro::coroutine_handle<promise_type> p;
};
@@ -54,4 +53,7 @@ MyFuture test_coro() {
int main()
{
MyFuture f = test_coro();
+ while (!f.p.done())
+ f.p.resume();
+ f.p.destroy();
}
More information about the cfe-commits
mailing list