summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Sema/SemaCoroutine.cpp36
-rw-r--r--clang/test/SemaCXX/coroutines.cpp15
2 files changed, 45 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp
index 471fab90e80..8d91e43f41e 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -209,6 +209,12 @@ static ReadySuspendResumeResult buildCoawaitCalls(Sema &S, SourceLocation Loc,
}
ExprResult Sema::ActOnCoawaitExpr(Scope *S, SourceLocation Loc, Expr *E) {
+ if (E->getType()->isPlaceholderType()) {
+ ExprResult R = CheckPlaceholderExpr(E);
+ if (R.isInvalid()) return ExprError();
+ E = R.get();
+ }
+
ExprResult Awaitable = buildOperatorCoawaitCall(*this, S, Loc, E);
if (Awaitable.isInvalid())
return ExprError();
@@ -219,18 +225,18 @@ ExprResult Sema::BuildCoawaitExpr(SourceLocation Loc, Expr *E) {
if (!Coroutine)
return ExprError();
- if (E->getType()->isDependentType()) {
- Expr *Res = new (Context) CoawaitExpr(Loc, Context.DependentTy, E);
- Coroutine->CoroutineStmts.push_back(Res);
- return Res;
- }
-
if (E->getType()->isPlaceholderType()) {
ExprResult R = CheckPlaceholderExpr(E);
if (R.isInvalid()) return ExprError();
E = R.get();
}
+ if (E->getType()->isDependentType()) {
+ Expr *Res = new (Context) CoawaitExpr(Loc, Context.DependentTy, E);
+ Coroutine->CoroutineStmts.push_back(Res);
+ return Res;
+ }
+
// FIXME: If E is a prvalue, create a temporary.
// FIXME: If E is an xvalue, convert to lvalue.
@@ -261,6 +267,12 @@ static ExprResult buildYieldValueCall(Sema &S, FunctionScopeInfo *Coroutine,
}
ExprResult Sema::ActOnCoyieldExpr(Scope *S, SourceLocation Loc, Expr *E) {
+ if (E->getType()->isPlaceholderType()) {
+ ExprResult R = CheckPlaceholderExpr(E);
+ if (R.isInvalid()) return ExprError();
+ E = R.get();
+ }
+
auto *Coroutine = checkCoroutineContext(*this, Loc, "co_yield");
if (!Coroutine)
return ExprError();
@@ -282,6 +294,12 @@ ExprResult Sema::BuildCoyieldExpr(SourceLocation Loc, Expr *E) {
if (!Coroutine)
return ExprError();
+ if (E->getType()->isPlaceholderType()) {
+ ExprResult R = CheckPlaceholderExpr(E);
+ if (R.isInvalid()) return ExprError();
+ E = R.get();
+ }
+
// FIXME: Build await_* calls.
Expr *Res = new (Context) CoyieldExpr(Loc, Context.VoidTy, E);
Coroutine->CoroutineStmts.push_back(Res);
@@ -292,6 +310,12 @@ StmtResult Sema::ActOnCoreturnStmt(SourceLocation Loc, Expr *E) {
return BuildCoreturnStmt(Loc, E);
}
StmtResult Sema::BuildCoreturnStmt(SourceLocation Loc, Expr *E) {
+ if (E && E->getType()->isPlaceholderType()) {
+ ExprResult R = CheckPlaceholderExpr(E);
+ if (R.isInvalid()) return StmtError();
+ E = R.get();
+ }
+
auto *Coroutine = checkCoroutineContext(*this, Loc, "co_return");
if (!Coroutine)
return StmtError();
diff --git a/clang/test/SemaCXX/coroutines.cpp b/clang/test/SemaCXX/coroutines.cpp
index 15536d83074..53226f7af21 100644
--- a/clang/test/SemaCXX/coroutines.cpp
+++ b/clang/test/SemaCXX/coroutines.cpp
@@ -140,3 +140,18 @@ namespace dependent_operator_co_await_lookup {
template void await_template(outer); // expected-note {{instantiation}}
template void await_template_2(outer);
}
+
+namespace placeholder {
+ awaitable f(), f(int); // expected-note 2{{possible target}}
+ int g(), g(int); // expected-note 4{{possible target}}
+ void x() {
+ co_await f; // expected-error {{reference to overloaded function}}
+ }
+ void y() {
+ co_yield g; // expected-error {{reference to overloaded function}}
+ }
+ void z() {
+ co_await a;
+ co_return g; // expected-error {{reference to overloaded function}}
+ }
+}
OpenPOWER on IntegriCloud