diff options
author | John McCall <rjmccall@apple.com> | 2012-04-04 01:27:53 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2012-04-04 01:27:53 +0000 |
commit | 3abee49d1c06f86761944375c112fcf55f59a261 (patch) | |
tree | 3d8291594d37d3f153f0cbd2650ab82d4895e67c /clang/lib/Sema | |
parent | 34b4546c06564e6a9d32370e65231494ed1f5abb (diff) | |
download | bcm5719-llvm-3abee49d1c06f86761944375c112fcf55f59a261.tar.gz bcm5719-llvm-3abee49d1c06f86761944375c112fcf55f59a261.zip |
Enter an expression evaluation context when parsing
statement-expressions. Prevents cleanups and such from being
claimed by the first full-expression in the block.
llvm-svn: 153989
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index d424f388f63..9339c04c513 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -8546,12 +8546,26 @@ static Expr *maybeRebuildARCConsumingStmt(Stmt *Statement) { return cleanups; } +void Sema::ActOnStartStmtExpr() { + PushExpressionEvaluationContext(ExprEvalContexts.back().Context); +} + +void Sema::ActOnStmtExprError() { + DiscardCleanupsInEvaluationContext(); + PopExpressionEvaluationContext(); +} + ExprResult Sema::ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc) { // "({..})" assert(SubStmt && isa<CompoundStmt>(SubStmt) && "Invalid action invocation!"); CompoundStmt *Compound = cast<CompoundStmt>(SubStmt); + if (hasAnyUnrecoverableErrorsInThisFunction()) + DiscardCleanupsInEvaluationContext(); + assert(!ExprNeedsCleanups && "cleanups within StmtExpr not correctly bound!"); + PopExpressionEvaluationContext(); + bool isFileScope = (getCurFunctionOrMethodDecl() == 0) && (getCurBlock() == 0); if (isFileScope) |