}
return NULL_TREE; /* Done. */
}
- break;
+ break;
+ case HANDLER:
+ {
+ /* [expr.await] An await-expression shall appear only in a
+ potentially-evaluated expression within the compound-statement
+ of a function-body outside of a handler. */
+ tree *await_ptr;
+ hash_set<tree> visited;
+ if (!(cp_walk_tree (&HANDLER_BODY (expr), find_any_await,
+ &await_ptr, &visited)))
+ return NULL_TREE; /* All OK. */
+ location_t loc = EXPR_LOCATION (*await_ptr);
+ error_at (loc, "await expressions are not permitted in handlers");
+ return NULL_TREE; /* This is going to fail later anyway. */
+ }
+ break;
}
else if (EXPR_P (expr))
{
--- /dev/null
+#include <coroutine>
+
+struct task {
+ struct promise_type {
+ std::suspend_always initial_suspend();
+ std::suspend_always final_suspend() noexcept;
+ task get_return_object();
+ void return_void();
+ void unhandled_exception();
+ };
+};
+
+task
+my_coro ()
+{
+ try
+ { }
+ catch (...)
+ {
+ // [expr.await] An await-expression shall appear only in a potentially-
+ // evaluated expression within the compound-statement of a function-body
+ // outside of a handler
+ co_await std::suspend_always{}; // { dg-error "await expressions are not permitted in handlers" }
+ }
+}