[cfe-commits] r47130 - /cfe/trunk/Parse/ParseObjc.cpp

Chris Lattner sabre at nondot.org
Thu Feb 14 11:27:54 PST 2008


Author: lattner
Date: Thu Feb 14 13:27:54 2008
New Revision: 47130

URL: http://llvm.org/viewvc/llvm-project?rev=47130&view=rev
Log:
ParseCompoundStatementBody expects to only be called with { as the current
token.  Diagnose when the { is missing in objc @try blocks instead of aborting.

Modified:
    cfe/trunk/Parse/ParseObjc.cpp

Modified: cfe/trunk/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=47130&r1=47129&r2=47130&view=diff

==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Thu Feb 14 13:27:54 2008
@@ -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, 





More information about the cfe-commits mailing list