diff options
author | Chris Lattner <sabre@nondot.org> | 2009-03-29 17:27:48 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-03-29 17:27:48 +0000 |
commit | cd1477562e7cf03279850885583d615e1f631dd4 (patch) | |
tree | d7b054d0c3d9742f9e491932046397d92f558651 /lib/Parse/ParseStmt.cpp | |
parent | 23c4b1883b13dc17484b7214091b73f3ba29096e (diff) |
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
Diffstat (limited to 'lib/Parse/ParseStmt.cpp')
-rw-r--r-- | lib/Parse/ParseStmt.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index b1a32decff..3ca2f02b52 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -912,12 +912,18 @@ Parser::OwningStmtResult Parser::ParseForStatement() { Diag(Tok, diag::ext_c99_variable_decl_in_for_loop); SourceLocation DeclStart = Tok.getLocation(); - DeclGroupPtrTy VarDecls = ParseSimpleDeclaration(Declarator::ForContext); - // FIXME: Pass in the right location for the end of the declstmt. - FirstPart = Actions.ActOnDeclStmt(VarDecls, DeclStart, DeclStart); - if ((ForEach = isTokIdentifier_in())) { + DeclGroupPtrTy DG = ParseSimpleDeclaration(Declarator::ForContext, false); + FirstPart = Actions.ActOnDeclStmt(DG, DeclStart, Tok.getLocation()); + + if (Tok.is(tok::semi)) { // for (int x = 4; + ConsumeToken(); + } else if ((ForEach = isTokIdentifier_in())) { + // ObjC: for (id x in expr) ConsumeToken(); // consume 'in' SecondPart = ParseExpression(); + } else { + Diag(Tok, diag::err_expected_semi_for); + SkipUntil(tok::semi); } } else { Value = ParseExpression(); |