summaryrefslogtreecommitdiffstats
path: root/clang/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2008-01-03 17:55:25 +0000
committerFariborz Jahanian <fjahanian@apple.com>2008-01-03 17:55:25 +0000
commit732b8c2dc5facdd529a7c6856a89b52fb3d2638d (patch)
treecf24f5567c5bd1a5c5f2958f01e3d08c5e71ad8a /clang/Sema/SemaStmt.cpp
parent9b92e93d360e97e3db6fb63a9326792ad1c30c9a (diff)
downloadbcm5719-llvm-732b8c2dc5facdd529a7c6856a89b52fb3d2638d.tar.gz
bcm5719-llvm-732b8c2dc5facdd529a7c6856a89b52fb3d2638d.zip
Patch to parse/build AST ObjC2's foreach statement.
llvm-svn: 45539
Diffstat (limited to 'clang/Sema/SemaStmt.cpp')
-rw-r--r--clang/Sema/SemaStmt.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/clang/Sema/SemaStmt.cpp b/clang/Sema/SemaStmt.cpp
index f83ff4b32de..cbb01bdb3c5 100644
--- a/clang/Sema/SemaStmt.cpp
+++ b/clang/Sema/SemaStmt.cpp
@@ -530,6 +530,39 @@ Sema::ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc,
return new ForStmt(First, Second, Third, Body, ForLoc);
}
+Action::StmtResult
+Sema::ActOnObjcForCollectionStmt(SourceLocation ForColLoc,
+ SourceLocation LParenLoc,
+ StmtTy *first, ExprTy *second,
+ SourceLocation RParenLoc, StmtTy *body) {
+ Stmt *First = static_cast<Stmt*>(first);
+ Expr *Second = static_cast<Expr*>(second);
+ Stmt *Body = static_cast<Stmt*>(body);
+
+ if (DeclStmt *DS = dyn_cast_or_null<DeclStmt>(First)) {
+ // C99 6.8.5p3: The declaration part of a 'for' statement shall only declare
+ // identifiers for objects having storage class 'auto' or 'register'.
+ for (ScopedDecl *D = DS->getDecl(); D; D = D->getNextDeclarator()) {
+ BlockVarDecl *BVD = dyn_cast<BlockVarDecl>(D);
+ if (BVD && !BVD->hasLocalStorage())
+ BVD = 0;
+ if (BVD == 0)
+ Diag(dyn_cast<ScopedDecl>(D)->getLocation(),
+ diag::err_non_variable_decl_in_for);
+ // FIXME: mark decl erroneous!
+ }
+ }
+ if (Second) {
+ DefaultFunctionArrayConversion(Second);
+ QualType SecondType = Second->getType();
+#if 0
+ if (!SecondType->isScalarType()) // C99 6.8.5p2
+ return Diag(ForColLoc, diag::err_typecheck_statement_requires_scalar,
+ SecondType.getAsString(), Second->getSourceRange());
+#endif
+ }
+ return new ObjcForCollectionStmt(First, Second, Body, ForColLoc);
+}
Action::StmtResult
Sema::ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
OpenPOWER on IntegriCloud