Objective-C: Warn when fast enumeration variable isn't used.

// rdar://14182680.

llvm-svn: 185762
This commit is contained in:
Fariborz Jahanian 2013-07-06 18:04:13 +00:00
parent c947ad2a2d
commit ae26bb67f8
2 changed files with 3 additions and 6 deletions

View File

@ -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);

View File

@ -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<NSFastEnumeration>* collection = ((void*)0);
for (id thing in collection) { }
for (id thing in collection) { } /* expected-warning {{unused variable 'thing'}} */
return 0;
}