http://llvm.org/bugs/show_bug.cgi?id=15324
Bug ID: 15324
Summary: Add -Wobjc-self-assignment for "cannot assign to
'self'" warnings
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
cat >test.m <<EOF
#import <Foundation/Foundation.h>
@interface A : NSObject
+(void)classmethod;
-(void)instancemethod;
@end
@implementation A
+(void) classmethod {
self = nil;
}
-(void) instancemethod {
self = nil;
}
@end
EOF
clang -fobjc-arc -c test.m
test.m:9:10: error: cannot assign to 'self' in a class method
self = nil;
~~~~ ^
test.m:12:10: error: cannot assign to 'self' outside of a method in the
init family
self = nil;
~~~~ ^
2 errors generated.
clang -Weverything -c test.m
(no diagnostics produced)
I suggested over at bug 9824 that warning on dead writes could suffice to
diagnose this problematic code in non-ARC mode. (There's a motivating example
over there as well.) However, it was suggested that I also file a new issue for
this potentially simpler fix.
I propose that Clang add a flag named something like "-Wobjc-self-assignment",
place both of the existing ARC diagnostics under that flag, and allow the user
to enable the flag in non-ARC mode (possibly, but not necessarily, combined
with -Werror).
--
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