Author: fjahanian
Date: Sat Jul 6 13:04:13 2013
New Revision: 185762
URL: http://llvm.org/viewvc/llvm-project?rev=185762&view=rev
Log:
Objective-C: Warn when fast enumeration variable isn't used.
// rdar://14182680.
Modified:
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/SemaObjC/foreach.m
Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=185762&r1=185761&r2=185762&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Sat Jul 6 13:04:13 2013
@@ -93,9 +93,6 @@ void Sema::ActOnForEachDeclStmt(DeclGrou
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);
Modified: cfe/trunk/test/SemaObjC/foreach.m
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/foreach.m?rev=185762&r1=185761&r2=185762&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/foreach.m (original)
+++ cfe/trunk/test/SemaObjC/foreach.m Sat Jul 6 13:04:13 2013
@@ -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;
}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits