}
ExprResult Sema::ActOnCoawaitExpr(Scope *S, SourceLocation Loc, Expr *E) {
+ auto *Coroutine = checkCoroutineContext(*this, Loc, "co_await");
+ if (!Coroutine) {
+ CorrectDelayedTyposInExpr(E);
+ return ExprError();
+ }
if (E->getType()->isPlaceholderType()) {
ExprResult R = CheckPlaceholderExpr(E);
if (R.isInvalid()) return ExprError();
ExprResult Awaitable = buildOperatorCoawaitCall(*this, S, Loc, E);
if (Awaitable.isInvalid())
return ExprError();
+
return BuildCoawaitExpr(Loc, Awaitable.get());
}
ExprResult Sema::BuildCoawaitExpr(SourceLocation Loc, Expr *E) {
ExprResult Sema::ActOnCoyieldExpr(Scope *S, SourceLocation Loc, Expr *E) {
auto *Coroutine = checkCoroutineContext(*this, Loc, "co_yield");
- if (!Coroutine)
+ if (!Coroutine) {
+ CorrectDelayedTyposInExpr(E);
return ExprError();
+ }
// Build yield_value call.
ExprResult Awaitable =
}
StmtResult Sema::ActOnCoreturnStmt(SourceLocation Loc, Expr *E) {
+ auto *Coroutine = checkCoroutineContext(*this, Loc, "co_return");
+ if (!Coroutine) {
+ CorrectDelayedTyposInExpr(E);
+ return StmtError();
+ }
return BuildCoreturnStmt(Loc, E);
}
StmtResult Sema::BuildCoreturnStmt(SourceLocation Loc, Expr *E) {
// RUN: %clang_cc1 -std=c++14 -fcoroutines -verify %s
+void no_coroutine_traits_bad_arg_await() {
+ co_await a; // expected-error {{include <coroutine>}}
+ // expected-error@-1 {{use of undeclared identifier 'a'}}
+}
+
+void no_coroutine_traits_bad_arg_yield() {
+ co_yield a; // expected-error {{include <coroutine>}}
+ // expected-error@-1 {{use of undeclared identifier 'a'}}
+}
+
+
+void no_coroutine_traits_bad_arg_return() {
+ co_return a; // expected-error {{include <coroutine>}}
+ // expected-error@-1 {{use of undeclared identifier 'a'}}
+}
+
+
struct awaitable {
bool await_ready();
void await_suspend(); // FIXME: coroutine_handle