summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-11-20 02:54:01 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-11-20 02:54:01 +0000
commit744b224bb5115f88ef301ccd6e850dff2ef567de (patch)
tree8cdfb515269079e1b884641515839455cf2c68b0 /clang/lib/Sema
parent2dfc3b8be56dfc35b429cf8811e35f8b4e715446 (diff)
downloadbcm5719-llvm-744b224bb5115f88ef301ccd6e850dff2ef567de.tar.gz
bcm5719-llvm-744b224bb5115f88ef301ccd6e850dff2ef567de.zip
[coroutines] Per latest wording paper, co_* are no longer permitted in any
unevaluated operands. llvm-svn: 253641
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaCoroutine.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp
index 210f30e2a4e..b4ba6e385b1 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -99,10 +99,11 @@ static QualType lookupPromiseType(Sema &S, const FunctionProtoType *FnType,
/// Check that this is a context in which a coroutine suspension can appear.
static FunctionScopeInfo *
checkCoroutineContext(Sema &S, SourceLocation Loc, StringRef Keyword) {
- // 'co_await' and 'co_yield' are permitted in unevaluated operands.
- // FIXME: Not in 'noexcept'.
- if (S.isUnevaluatedContext())
+ // 'co_await' and 'co_yield' are not permitted in unevaluated operands.
+ if (S.isUnevaluatedContext()) {
+ S.Diag(Loc, diag::err_coroutine_unevaluated_context) << Keyword;
return nullptr;
+ }
// Any other usage must be within a function.
auto *FD = dyn_cast<FunctionDecl>(S.CurContext);
@@ -206,11 +207,12 @@ ExprResult Sema::ActOnCoawaitExpr(Scope *S, SourceLocation Loc, Expr *E) {
}
ExprResult Sema::BuildCoawaitExpr(SourceLocation Loc, Expr *E) {
auto *Coroutine = checkCoroutineContext(*this, Loc, "co_await");
+ if (!Coroutine)
+ return ExprError();
if (E->getType()->isDependentType()) {
Expr *Res = new (Context) CoawaitExpr(Loc, Context.DependentTy, E);
- if (Coroutine)
- Coroutine->CoroutineStmts.push_back(Res);
+ Coroutine->CoroutineStmts.push_back(Res);
return Res;
}
@@ -230,8 +232,7 @@ ExprResult Sema::BuildCoawaitExpr(SourceLocation Loc, Expr *E) {
Expr *Res = new (Context) CoawaitExpr(Loc, E, RSS.Results[0], RSS.Results[1],
RSS.Results[2]);
- if (Coroutine)
- Coroutine->CoroutineStmts.push_back(Res);
+ Coroutine->CoroutineStmts.push_back(Res);
return Res;
}
@@ -244,11 +245,12 @@ ExprResult Sema::ActOnCoyieldExpr(Scope *S, SourceLocation Loc, Expr *E) {
}
ExprResult Sema::BuildCoyieldExpr(SourceLocation Loc, Expr *E) {
auto *Coroutine = checkCoroutineContext(*this, Loc, "co_yield");
+ if (!Coroutine)
+ return ExprError();
// FIXME: Build await_* calls.
Expr *Res = new (Context) CoyieldExpr(Loc, Context.VoidTy, E);
- if (Coroutine)
- Coroutine->CoroutineStmts.push_back(Res);
+ Coroutine->CoroutineStmts.push_back(Res);
return Res;
}
@@ -257,11 +259,12 @@ StmtResult Sema::ActOnCoreturnStmt(SourceLocation Loc, Expr *E) {
}
StmtResult Sema::BuildCoreturnStmt(SourceLocation Loc, Expr *E) {
auto *Coroutine = checkCoroutineContext(*this, Loc, "co_return");
+ if (!Coroutine)
+ return StmtError();
// FIXME: Build return_* calls.
Stmt *Res = new (Context) CoreturnStmt(Loc, E);
- if (Coroutine)
- Coroutine->CoroutineStmts.push_back(Res);
+ Coroutine->CoroutineStmts.push_back(Res);
return Res;
}
OpenPOWER on IntegriCloud