Fix parser bug/FIXME with @catch.

<rdar://problem/5980846> clang on xcode: error: declarator requires an identifier (for @catch)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51895 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp
index 6a07503..933a7a6 100644
--- a/lib/Parse/ParseObjc.cpp
+++ b/lib/Parse/ParseObjc.cpp
@@ -1193,15 +1193,19 @@
         if (Tok.isNot(tok::ellipsis)) {
           DeclSpec DS;
           ParseDeclarationSpecifiers(DS);
-          // FIXME: Is BlockContext right?
-          Declarator DeclaratorInfo(DS, Declarator::BlockContext);
+          // For some odd reason, the name of the exception variable is 
+          // optional. As a result, we need to use PrototypeContext.
+          Declarator DeclaratorInfo(DS, Declarator::PrototypeContext);
           ParseDeclarator(DeclaratorInfo);
-          DeclTy *aBlockVarDecl = Actions.ActOnDeclarator(CurScope, 
+          if (DeclaratorInfo.getIdentifier()) {
+            DeclTy *aBlockVarDecl = Actions.ActOnDeclarator(CurScope, 
                                                           DeclaratorInfo, 0);
-          StmtResult stmtResult =
-            Actions.ActOnDeclStmt(aBlockVarDecl, DS.getSourceRange().getBegin(),
-                                  DeclaratorInfo.getSourceRange().getEnd());
-          FirstPart = stmtResult.isInvalid ? 0 : stmtResult.Val;
+            StmtResult stmtResult =
+              Actions.ActOnDeclStmt(aBlockVarDecl, 
+                                    DS.getSourceRange().getBegin(),
+                                    DeclaratorInfo.getSourceRange().getEnd());
+            FirstPart = stmtResult.isInvalid ? 0 : stmtResult.Val;
+          }
         } else
           ConsumeToken(); // consume '...'
         SourceLocation RParenLoc = ConsumeParen();