Skip to content

Commit ef89962

Browse files
committed
Fix handling of Objective-C for...in statements
Without this change, we parse as though the initial declaration is an uninitialized variable. With this change, we behave the same as we do for range-based for loops in C++, which is not handled as an uninitialized variable. Note, ParseDeclGroup (which is what is eventually called as a result of this change) was already expecting to be able to handle for...in loops, so this appears to be fixing an oversight.
1 parent 6773ce9 commit ef89962

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

clang/lib/Parse/ParseStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2154,7 +2154,7 @@ StmtResult Parser::ParseForStatement(SourceLocation *TrailingElseLoc) {
21542154
FirstPart = Actions.ActOnDeclStmt(DG, DeclStart, Tok.getLocation());
21552155
} else {
21562156
// In C++0x, "for (T NS:a" might not be a typo for ::
2157-
bool MightBeForRangeStmt = getLangOpts().CPlusPlus;
2157+
bool MightBeForRangeStmt = getLangOpts().CPlusPlus || getLangOpts().ObjC;
21582158
ColonProtectionRAIIObject ColonProtection(*this, MightBeForRangeStmt);
21592159
ParsedAttributes DeclSpecAttrs(AttrFactory);
21602160
DG = ParseSimpleDeclaration(

0 commit comments

Comments
 (0)