diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-02-15 18:34:13 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-02-15 18:34:13 +0000 |
commit | 820b23dc924a4ae7af07d5a75d6b1d781c267d57 (patch) | |
tree | 41ebf4f1191d15987c38300b22c8d3d526f28fba /lib/Sema/SemaStmt.cpp | |
parent | b130a54940171a95422a20a07ee8fdfe009806a5 (diff) |
When a statement is dropped from the AST because it was invalid, make sure
we don't do the scope checks otherwise we are going to hit assertion checks
since a label may not have been actually added.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175281 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index fd3ee0d9f5..dcb86b780b 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -406,6 +406,13 @@ StmtResult Sema::ActOnIfStmt(SourceLocation IfLoc, FullExprArg CondVal, Decl *CondVar, Stmt *thenStmt, SourceLocation ElseLoc, Stmt *elseStmt) { + // If the condition was invalid, discard the if statement. We could recover + // better by replacing it with a valid expr, but don't do that yet. + if (!CondVal.get() && !CondVar) { + getCurFunction()->setHasDroppedStmt(); + return StmtError(); + } + ExprResult CondResult(CondVal.release()); VarDecl *ConditionVar = 0; |