]> granicus.if.org Git - clang/commitdiff
ParseCompoundStatementBody expects to only be called with { as the current
authorChris Lattner <sabre@nondot.org>
Thu, 14 Feb 2008 19:27:54 +0000 (19:27 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 14 Feb 2008 19:27:54 +0000 (19:27 +0000)
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

Parse/ParseObjc.cpp

index 01b2abffb081c018f85b7e7117f9fe2637226a43..24d6309905a0205e815acab44c46c7533572ab8c 100644 (file)
@@ -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,