ParseCompoundStatementBody expects to only be called with { as the current
token. Diagnose when the { is missing in objc @try blocks instead of aborting.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47130 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Parse/ParseObjc.cpp b/Parse/ParseObjc.cpp
index 01b2abf..24d6309 100644
--- a/Parse/ParseObjc.cpp
+++ b/Parse/ParseObjc.cpp
@@ -1186,7 +1186,12 @@
} else
ConsumeToken(); // consume '...'
SourceLocation RParenLoc = ConsumeParen();
- StmtResult CatchBody = ParseCompoundStatementBody();
+
+ StmtResult CatchBody(true);
+ if (Tok.is(tok::l_brace))
+ CatchBody = ParseCompoundStatementBody();
+ else
+ Diag(Tok, diag::err_expected_lbrace);
if (CatchBody.isInvalid)
CatchBody = Actions.ActOnNullStmt(Tok.getLocation());
CatchStmts = Actions.ActOnObjCAtCatchStmt(AtCatchFinallyLoc, RParenLoc,
@@ -1200,7 +1205,12 @@
catch_or_finally_seen = true;
} else if (Tok.isObjCAtKeyword(tok::objc_finally)) {
ConsumeToken(); // consume finally
- StmtResult FinallyBody = ParseCompoundStatementBody();
+
+ StmtResult FinallyBody(true);
+ if (Tok.is(tok::l_brace))
+ FinallyBody = ParseCompoundStatementBody();
+ else
+ Diag(Tok, diag::err_expected_lbrace);
if (FinallyBody.isInvalid)
FinallyBody = Actions.ActOnNullStmt(Tok.getLocation());
FinallyStmt = Actions.ActOnObjCAtFinallyStmt(AtCatchFinallyLoc,