[cfe-dev] Obj-C false positive warning with deprecation and instancetype?
Sean McBride
sean at rogue-research.com
Wed Jan 11 08:10:32 PST 2012
Hi all,
Using clang r147866 on Mac OS X 10.7, the code below causes this warning:
$ clang -fsyntax-only test.m
test.m:18:11: warning: 'initWithContentsOfURL:' is deprecated [-Wdeprecated-declarations]
return [[[self alloc] initWithContentsOfURL:inURL] autorelease];
^
NSString has a deprecated method initWithContentsOfURL:, but in my own class it's not deprecated. I would have thought that between my own use of instancetype and clang's special casing of alloc that this should not warn. Is it a false positive bug?
-----------
#import <Foundation/Foundation.h>
@interface Awesome : NSObject { }
- (instancetype)initWithContentsOfURL:(NSURL*)inURL; // designated initializer
+ (instancetype)awsomeWithContentsOfURL:(NSURL*)inURL;
@end
@implementation Awesome
- (instancetype)initWithContentsOfURL:(NSURL*)inURL
{
self = [super init];
return self;
}
+ (instancetype)awsomeWithContentsOfURL:(NSURL*)inURL
{
return [[[self alloc] initWithContentsOfURL:inURL] autorelease];
}
@end
int main (int argc, char *argv[])
{
(void)argc; (void)argv;
return 0;
}
-----------
Thanks,
Sean
More information about the cfe-dev
mailing list