Don't issue spurious diagnostic with Obj-C fast enumeration.

(radar 7409165).

llvm-svn: 89400
This commit is contained in:
Fariborz Jahanian 2009-11-19 22:12:37 +00:00
parent f94c02600f
commit e774fa6412
5 changed files with 15 additions and 1 deletions

View File

@ -668,6 +668,9 @@ public:
return StmtEmpty();
}
virtual void ActOnForEachDeclStmt(DeclGroupPtrTy Decl) {
}
virtual OwningStmtResult ActOnExprStmt(FullExprArg Expr) {
return OwningStmtResult(*this, Expr->release());
}

View File

@ -944,6 +944,7 @@ Parser::OwningStmtResult Parser::ParseForStatement() {
if (Tok.is(tok::semi)) { // for (int x = 4;
ConsumeToken();
} else if ((ForEach = isTokIdentifier_in())) {
Actions.ActOnForEachDeclStmt(DG);
// ObjC: for (id x in expr)
ConsumeToken(); // consume 'in'
SecondPart = ParseExpression();

View File

@ -1260,6 +1260,7 @@ public:
virtual OwningStmtResult ActOnDeclStmt(DeclGroupPtrTy Decl,
SourceLocation StartLoc,
SourceLocation EndLoc);
virtual void ActOnForEachDeclStmt(DeclGroupPtrTy Decl);
virtual OwningStmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprArg LHSVal,
SourceLocation DotDotDotLoc, ExprArg RHSVal,
SourceLocation ColonLoc);

View File

@ -59,6 +59,15 @@ Sema::OwningStmtResult Sema::ActOnDeclStmt(DeclGroupPtrTy dg,
return Owned(new (Context) DeclStmt(DG, StartLoc, EndLoc));
}
void Sema::ActOnForEachDeclStmt(DeclGroupPtrTy dg) {
DeclGroupRef DG = dg.getAsVal<DeclGroupRef>();
// If we have an invalid decl, just return.
if (DG.isNull() || !DG.isSingleDecl()) return;
// suppress any potential 'unused variable' warning.
DG.getSingleDecl()->setUsed();
}
void Sema::DiagnoseUnusedExprResult(const Stmt *S) {
const Expr *E = dyn_cast_or_null<Expr>(S);
if (!E)

View File

@ -1,4 +1,4 @@
/* RUN: clang-cc -fsyntax-only -verify -std=c89 -pedantic %s
/* RUN: clang-cc -Wall -fsyntax-only -verify -std=c89 -pedantic %s
*/
@class NSArray;