diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-11-19 22:12:37 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-11-19 22:12:37 +0000 |
commit | a7cf23a72b0846fc5aacf3f38bb8c8f9e76784cf (patch) | |
tree | e01fa9aeac13c433fceb7efd292392d29434a886 /lib | |
parent | e24568725c04acaa4b7ff3db283e6098ad947847 (diff) |
Don't issue spurious diagnostic with Obj-C fast enumeration.
(radar 7409165).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89400 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Parse/ParseStmt.cpp | 1 | ||||
-rw-r--r-- | lib/Sema/Sema.h | 1 | ||||
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 9 |
3 files changed, 11 insertions, 0 deletions
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index 7637382ac0..ff08ebbe87 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -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(); diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index ad4c90bdc2..72039e2756 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -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); diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index d0f214fbd8..9960565877 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -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) |