+2020-02-04 Iain Sandoe <iain@sandoe.co.uk>
+
+ * coroutines.cc (find_promise_type): Delete unused forward
+ declaration.
+ (struct coroutine_info): Add a bool for no promise type error.
+ (coro_promise_type_found_p): Only emit the error for a missing
+ promise once in each affected coroutine.
+
2020-02-03 Jason Merrill <jason@redhat.com>
PR c++/66477
#include "gcc-rich-location.h"
#include "hash-map.h"
-static tree find_promise_type (tree);
static bool coro_promise_type_found_p (tree, location_t);
/* GCC C++ coroutines implementation.
function into a coroutine. */
/* Flags to avoid repeated errors for per-function issues. */
bool coro_ret_type_error_emitted;
+ bool coro_promise_error_emitted;
};
struct coroutine_info_hasher : ggc_ptr_hash<coroutine_info>
/* If we don't find it, punt on the rest. */
if (coro_info->promise_type == NULL_TREE)
{
- error_at (loc, "unable to find the promise type for this coroutine");
+ if (!coro_info->coro_promise_error_emitted)
+ error_at (loc, "unable to find the promise type for"
+ " this coroutine");
+ coro_info->coro_promise_error_emitted = true;
return false;
}
+2020-02-04 Iain Sandoe <iain@sandoe.co.uk>
+
+ * g++.dg/coroutines/coro-missing-promise.C: New test.
+
2020-02-04 Richard Biener <rguenther@suse.de>
PR tree-optimization/91123
--- /dev/null
+// { dg-additional-options "-fsyntax-only -w" }
+
+#include "coro.h"
+
+// Diagnose completely missing promise.
+
+// { dg-error {no type named 'promise_type' in 'struct NoPromiseHere'} "" { target *-*-* } 0 }
+
+struct NoPromiseHere {
+ coro::coroutine_handle<> handle;
+ NoPromiseHere () : handle (nullptr) {}
+ NoPromiseHere (coro::coroutine_handle<> handle) : handle (handle) {}
+};
+
+NoPromiseHere
+bar ()
+{
+ co_yield 22; // { dg-error {unable to find the promise type for this coroutine} }
+ co_return 0;
+}