diff options
-rw-r--r-- | Parse/ParseDecl.cpp | 3 | ||||
-rw-r--r-- | Parse/ParseStmt.cpp | 20 |
2 files changed, 13 insertions, 10 deletions
diff --git a/Parse/ParseDecl.cpp b/Parse/ParseDecl.cpp index dccc00e671..99be5caf3f 100644 --- a/Parse/ParseDecl.cpp +++ b/Parse/ParseDecl.cpp @@ -296,6 +296,9 @@ ParseInitDeclaratorListAfterFirstDeclarator(Declarator &D) { ConsumeToken(); return Actions.FinalizeDeclaratorGroup(CurScope, LastDeclInGroup); } + // 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 (D.getContext() == Declarator::ForContext && isTokIdentifier_in()) { return Actions.FinalizeDeclaratorGroup(CurScope, LastDeclInGroup); } diff --git a/Parse/ParseStmt.cpp b/Parse/ParseStmt.cpp index e55c3f905d..8cccf23888 100644 --- a/Parse/ParseStmt.cpp +++ b/Parse/ParseStmt.cpp @@ -746,7 +746,7 @@ Parser::StmtResult Parser::ParseForStatement() { StmtTy *FirstPart = 0; ExprTy *SecondPart = 0; StmtTy *ThirdPart = 0; - bool foreach = false; + bool ForEach = false; // Parse the first part of the for specifier. if (Tok.is(tok::semi)) { // for (; @@ -759,7 +759,7 @@ Parser::StmtResult Parser::ParseForStatement() { DeclTy *aBlockVarDecl = ParseDeclaration(Declarator::ForContext); StmtResult stmtResult = Actions.ActOnDeclStmt(aBlockVarDecl); FirstPart = stmtResult.isInvalid ? 0 : stmtResult.Val; - if ((foreach = isTokIdentifier_in())) { + if ((ForEach = isTokIdentifier_in())) { ConsumeToken(); // consume 'in' Value = ParseExpression(); if (!Value.isInvalid) @@ -778,7 +778,7 @@ Parser::StmtResult Parser::ParseForStatement() { if (Tok.is(tok::semi)) { ConsumeToken(); } - else if ((foreach = isTokIdentifier_in())) { + else if ((ForEach = isTokIdentifier_in())) { ConsumeToken(); // consume 'in' Value = ParseExpression(); if (!Value.isInvalid) @@ -789,7 +789,7 @@ Parser::StmtResult Parser::ParseForStatement() { SkipUntil(tok::semi); } } - if (!foreach) { + if (!ForEach) { // Parse the second part of the for specifier. if (Tok.is(tok::semi)) { // for (...;; // no second part. @@ -842,12 +842,12 @@ Parser::StmtResult Parser::ParseForStatement() { if (Body.isInvalid) return Body; - return !foreach ? Actions.ActOnForStmt(ForLoc, LParenLoc, FirstPart, - SecondPart, ThirdPart, RParenLoc, - Body.Val) - : Actions.ActOnObjcForCollectionStmt(ForLoc, LParenLoc, - FirstPart, SecondPart, - RParenLoc, Body.Val); + if (!ForEach) + return Actions.ActOnForStmt(ForLoc, LParenLoc, FirstPart, + SecondPart, ThirdPart, RParenLoc, Body.Val); + else + return Actions.ActOnObjcForCollectionStmt(ForLoc, LParenLoc, FirstPart, + SecondPart, RParenLoc, Body.Val); } /// ParseGotoStatement |