From: Fariborz Jahanian Date: Sat, 6 Jul 2013 18:04:13 +0000 (+0000) Subject: Objective-C: Warn when fast enumeration variable isn't used. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bdf3d9ad85ef09544d14db0e848a01c7df9cb028;p=clang Objective-C: Warn when fast enumeration variable isn't used. // rdar://14182680. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185762 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 45162744b1..3a67997ea4 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -93,9 +93,6 @@ void Sema::ActOnForEachDeclStmt(DeclGroupPtrTy dg) { return; } - // suppress any potential 'unused variable' warning. - var->setUsed(); - // foreach variables are never actually initialized in the way that // the parser came up with. var->setInit(0); diff --git a/test/SemaObjC/foreach.m b/test/SemaObjC/foreach.m index d0e0f7b9e2..91ea2ec4e0 100644 --- a/test/SemaObjC/foreach.m +++ b/test/SemaObjC/foreach.m @@ -13,8 +13,8 @@ void f(NSArray *a) { * and no diagnostics even in pedantic mode should happen. * rdar://6814674 */ - for (id thisKey in keys); - for (id thisKey in keys); + for (id thisKey in keys); /* expected-warning {{unused variable 'thisKey'}} */ + for (id thisKey in keys); /* expected-warning {{unused variable 'thisKey'}} */ } /* // rdar://9072298 */ @@ -41,7 +41,7 @@ typedef struct { int main () { NSObject* collection = ((void*)0); - for (id thing in collection) { } + for (id thing in collection) { } /* expected-warning {{unused variable 'thing'}} */ return 0; }