hoist some code for handling objc foreach construct out of Declaration processing
into ParseForStatement.  Merge two tests into one.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68010 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index 5de4dd4..f80afe3 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -257,7 +257,11 @@
 ///         declaration-specifiers init-declarator-list[opt] ';'
 ///[C90/C++]init-declarator-list ';'                             [TODO]
 /// [OMP]   threadprivate-directive                              [TODO]
-Parser::DeclGroupPtrTy Parser::ParseSimpleDeclaration(unsigned Context) {
+///
+/// If RequireSemi is false, this does not check for a ';' at the end of the
+/// declaration.
+Parser::DeclGroupPtrTy Parser::ParseSimpleDeclaration(unsigned Context,
+                                                      bool RequireSemi) {
   // Parse the common declaration-specifiers piece.
   DeclSpec DS;
   ParseDeclarationSpecifiers(DS);
@@ -275,22 +279,16 @@
   
   DeclGroupPtrTy DG =
     ParseInitDeclaratorListAfterFirstDeclarator(DeclaratorInfo);
+
+  // If the client wants to check what comes after the declaration, just return
+  // immediately without checking anything!
+  if (!RequireSemi) return DG;
   
   if (Tok.is(tok::semi)) {
     ConsumeToken();
-    // for(is key; in keys) is error.
-    if (Context == Declarator::ForContext && isTokIdentifier_in())
-      Diag(Tok, diag::err_parse_error);
-    
     return DG;
   }
   
-  // If this is an ObjC2 for-each loop, this is a successful declarator
-  // parse.  The syntax for these looks like:
-  // 'for' '(' declaration 'in' expr ')' statement
-  if (Context == Declarator::ForContext && isTokIdentifier_in())
-    return DG;
-  
   Diag(Tok, diag::err_expected_semi_declation);
   // Skip to end of block or statement
   SkipUntil(tok::r_brace, true, true);