http://llvm.org/bugs/show_bug.cgi?id=16958
Bug ID: 16958
Summary: -Wshadow-ivar fires at point of use
Product: clang
Version: unspecified
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
The warning controlled by -Wshadow-ivar (declaration shadows instance variable)
for Objective-C is issued at every instance where such the shadowing variable
is used, rather than at the point of the shadowing declaration. For example:
@interface A : NSObject
@end
@implementation A
{
NSString * __weak _str;
}
- (void)doSomethingHere
{
_Pragma("clang diagnostic push");
_Pragma("clang diagnostic ignored \"-Wshadow\"");
_Pragma("clang diagnostic ignored \"-Wshadow-ivar\"");
NSString * __strong _str = _str; // -Wshadow-ivar does not fire here
_Pragma("clang diagnostic pop");
NSLog(@"%@", _str); // -Wshadow-ivar DOES fire here
[self doSomethingElseWith:_str]; // -Wshadow-ivar fires again here
}
@end
This makes it impractical to deliberately shadow instance variables. A common
use case is temporarily taking a strong reference to a weak ivar, as in the
example given.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs