+2020-01-21 Bin Cheng <bin.cheng@linux.alibaba.com>
+
+ * coroutines.cc (finish_co_await_expr): Set return value flag.
+ (finish_co_yield_expr, morph_fn_to_coro): Ditto.
+
2020-01-19 Jason Merrill <jason@redhat.com>
PR c++/33799 - destroy return value, take 2.
if (processing_template_decl)
{
+ current_function_returns_value = 1;
+
if (check_for_bare_parameter_packs (expr))
return error_mark_node;
if (processing_template_decl)
{
+ current_function_returns_value = 1;
+
if (check_for_bare_parameter_packs (expr))
return error_mark_node;
if (!coro_function_valid_p (orig))
return false;
+ /* The ramp function does return a value. */
+ current_function_returns_value = 1;
+
/* We can't validly get here with an empty statement list, since there's no
way for the FE to decide it's a coroutine in the absence of any code. */
tree fnbody = pop_stmt_list (DECL_SAVED_TREE (orig));
+2020-01-20 Bin Cheng <bin.cheng@linux.alibaba.com>
+
+ * g++.dg/coroutines/co-return-warning-1.C: New test.
+
2020-01-21 Kito Cheng <kito.cheng@sifive.com>
PR target/93304
--- /dev/null
+// { dg-additional-options "-std=c++17 -w" }
+
+#include <coroutine>
+
+class resumable {
+public:
+ struct promise_type;
+ using coro_handle = std::coroutine_handle<promise_type>;
+ resumable(coro_handle handle) : handle_(handle) {}
+ resumable(resumable&) = delete;
+ resumable(resumable&&) = delete;
+ bool resume() {
+ if (not handle_.done())
+ handle_.resume();
+ return not handle_.done();
+ }
+ int recent_val();
+ ~resumable() { handle_.destroy(); }
+private:
+ coro_handle handle_;
+};
+
+struct resumable::promise_type {
+ int value_;
+
+ using coro_handle = std::coroutine_handle<promise_type>;
+ auto get_return_object() {
+ return coro_handle::from_promise(*this);
+ }
+ auto initial_suspend() { return std::suspend_always(); }
+ auto final_suspend() { return std::suspend_always(); }
+ void return_value(int v) { value_ = v; }
+ std::suspend_always yield_value(int v) {
+ value_ = v;
+ return std::suspend_always();
+ }
+ void unhandled_exception() {}
+};
+
+int resumable::recent_val(){return handle_.promise().value_;}
+
+resumable foo(int n){
+ int x = 1;
+ co_await std::suspend_always();
+ int y = 2;
+ co_yield n + x + y;
+}
+