summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard@metafoo.co.uk>2020-03-03 15:19:13 -0800
committerHans Wennborg <hans@chromium.org>2020-03-04 09:20:30 +0100
commit3a843031a5ad83a00d2603f623881cb2b2bf719d (patch)
treee41bf3bd9709fcde6adac546c900fa1752755d61 /clang/lib/Sema/SemaExpr.cpp
parentbca373f73fc82728a8335e7d6cd164e8747139ec (diff)
downloadbcm5719-llvm-3a843031a5ad83a00d2603f623881cb2b2bf719d.tar.gz
bcm5719-llvm-3a843031a5ad83a00d2603f623881cb2b2bf719d.zip
PR45083: Mark statement expressions as being dependent if they appear in
dependent contexts. We previously assumed they were neither value- nor instantiation-dependent under any circumstances, which would lead to crashes and other misbehavior. (cherry picked from commit bdad0a1b79273733df9acc1be4e992fa5d70ec56)
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 29562615e58..63d8d7506d0 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -13908,9 +13908,8 @@ void Sema::ActOnStmtExprError() {
PopExpressionEvaluationContext();
}
-ExprResult
-Sema::ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
- SourceLocation RPLoc) { // "({..})"
+ExprResult Sema::ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt,
+ SourceLocation RPLoc) { // "({..})"
assert(SubStmt && isa<CompoundStmt>(SubStmt) && "Invalid action invocation!");
CompoundStmt *Compound = cast<CompoundStmt>(SubStmt);
@@ -13939,9 +13938,18 @@ Sema::ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
}
}
+ bool IsDependentContext = false;
+ if (S)
+ IsDependentContext = S->getTemplateParamParent() != nullptr;
+ else
+ // FIXME: This is not correct when substituting inside a templated
+ // context that isn't a DeclContext (such as a variable template).
+ IsDependentContext = CurContext->isDependentContext();
+
// FIXME: Check that expression type is complete/non-abstract; statement
// expressions are not lvalues.
- Expr *ResStmtExpr = new (Context) StmtExpr(Compound, Ty, LPLoc, RPLoc);
+ Expr *ResStmtExpr =
+ new (Context) StmtExpr(Compound, Ty, LPLoc, RPLoc, IsDependentContext);
if (StmtExprMayBindToTemp)
return MaybeBindToTemporary(ResStmtExpr);
return ResStmtExpr;
OpenPOWER on IntegriCloud