aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseStmt.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-03-31 00:37:59 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-03-31 00:37:59 +0000
commitb57c757a80532a610d949c2eeb9d9e05c76f543f (patch)
treea0b1e5c2b472eb1806833bdafac0b24e7405afb7 /lib/Parse/ParseStmt.cpp
parent031b37140d0864c741618960b5220245a2a086ae (diff)
Don't skip past the '}' if an expression has error and is not followed by ';'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99972 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseStmt.cpp')
-rw-r--r--lib/Parse/ParseStmt.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index 9fd145dc26..b752b48cfd 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -125,10 +125,12 @@ Parser::ParseStatementOrDeclaration(bool OnlyStatement) {
// expression[opt] ';'
OwningExprResult Expr(ParseExpression());
if (Expr.isInvalid()) {
- // If the expression is invalid, skip ahead to the next semicolon. Not
- // doing this opens us up to the possibility of infinite loops if
+ // If the expression is invalid, skip ahead to the next semicolon or '}'.
+ // Not doing this opens us up to the possibility of infinite loops if
// ParseExpression does not consume any tokens.
- SkipUntil(tok::semi);
+ SkipUntil(tok::r_brace, /*StopAtSemi=*/true, /*DontConsume=*/true);
+ if (Tok.is(tok::semi))
+ ConsumeToken();
return StmtError();
}
// Otherwise, eat the semicolon.