+2020-01-21 Iain Sandoe <iain@sandoe.co.uk>
+ Bin Cheng <bin.cheng@linux.alibaba.com>
+
+ * coroutines.cc (coro_promise_type_found_p): Check for NULL return
+ from complete_type_or_else.
+ (register_param_uses): Likewise.
+ (build_co_await): Do not try to use complete_type_or_else for void
+ types, otherwise for incomplete types, check for NULL return from
+ complete_type_or_else.
+
2020-01-21 Jason Merrill <jason@redhat.com>
PR c++/91476 - anon-namespace reference temp clash between TUs.
/* Complete this, we're going to use it. */
coro_info->handle_type = complete_type_or_else (handle_type, fndecl);
+
/* Diagnostic would be emitted by complete_type_or_else. */
- if (coro_info->handle_type == error_mark_node)
+ if (!coro_info->handle_type)
return false;
/* Build a proxy for a handle to "self" as the param to
else
o = a; /* This is most likely about to fail anyway. */
- tree o_type = complete_type_or_else (TREE_TYPE (o), o);
+ tree o_type = TREE_TYPE (o);
+ if (o_type && !VOID_TYPE_P (o_type))
+ o_type = complete_type_or_else (o_type, o);
+
+ if (!o_type)
+ return error_mark_node;
+
if (TREE_CODE (o_type) != RECORD_TYPE)
{
error_at (loc, "awaitable type %qT is not a structure",
if (!COMPLETE_TYPE_P (actual_type))
actual_type = complete_type_or_else (actual_type, *stmt);
+ if (actual_type == NULL_TREE)
+ /* Diagnostic emitted by complete_type_or_else. */
+ actual_type = error_mark_node;
+
if (TREE_CODE (actual_type) == REFERENCE_TYPE)
actual_type = build_pointer_type (TREE_TYPE (actual_type));
+2020-01-21 Bin Cheng <bin.linux@linux.alibaba.com>
+
+ * g++.dg/coroutines/co-await-void_type.C: New test.
+
2020-01-21 Jakub Jelinek <jakub@redhat.com>
PR target/93333
--- /dev/null
+// { dg-additional-options "-std=c++17 -fsyntax-only -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 yield_value(int v) { value_ = v; }
+ 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; // { dg-error "awaitable type 'void' is not a structure" }
+}
+