From: Chris Lattner Date: Thu, 14 Feb 2008 19:27:54 +0000 (+0000) Subject: ParseCompoundStatementBody expects to only be called with { as the current X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c1b3ba5ae08316fe43e541c4fb02921fc3e80b21;p=clang 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 01b2abffb0..24d6309905 100644 --- a/Parse/ParseObjc.cpp +++ b/Parse/ParseObjc.cpp @@ -1186,7 +1186,12 @@ Parser::StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc, } 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 @@ Parser::StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc, 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,