summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseStmt.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-29 17:27:48 +0000
committerChris Lattner <sabre@nondot.org>2009-03-29 17:27:48 +0000
commit32dc41c4454372306e63c3c204071aa6f51ef6bf (patch)
tree59fc202e7750e32c14bf0240e488c62a0fb4a167 /clang/lib/Parse/ParseStmt.cpp
parentefb0f111f1a803990602f67ea16ac14c5a43f671 (diff)
downloadbcm5719-llvm-32dc41c4454372306e63c3c204071aa6f51ef6bf.tar.gz
bcm5719-llvm-32dc41c4454372306e63c3c204071aa6f51ef6bf.zip
hoist some code for handling objc foreach construct out of Declaration processing
into ParseForStatement. Merge two tests into one. llvm-svn: 68010
Diffstat (limited to 'clang/lib/Parse/ParseStmt.cpp')
-rw-r--r--clang/lib/Parse/ParseStmt.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index b1a32decffc..3ca2f02b52b 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/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();
OpenPOWER on IntegriCloud