blob: 9e99c34d209253a47e7f0a05e19330bd3e756583 [file] [log] [blame]
Ted Kremenek1cd920a2008-09-19 04:56:32 +00001// RUN: clang -checker-cfref -verify %s
2
3typedef signed char BOOL;
4typedef int NSInteger;
5typedef struct _NSZone NSZone;
6@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
7@protocol NSObject - (BOOL)isEqual:(id)object; @end
8@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end
9@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
10@interface NSObject <NSObject> {} @end
11@class NSDictionary;
12@interface NSError : NSObject <NSCopying, NSCoding> {}
13+ (id)errorWithDomain:(NSString *)domain code:(NSInteger)code userInfo:(NSDictionary *)dict;
14@end
15extern NSString * const NSXMLParserErrorDomain ;
16
17@interface A
18- (void)myMethodWhichMayFail:(NSError **)error;
19- (BOOL)myMethodWhichMayFail2:(NSError **)error;
20@end
21
22@implementation A
23- (void)myMethodWhichMayFail:(NSError **)error { // expected-warning: {{Method accepting NSError** argument should have non-void return value to indicate that an error occurred.}}
24 *error = [NSError errorWithDomain:@"domain" code:1 userInfo:0]; // expected-warning: {{Potential null dereference.}}
25}
26
27- (BOOL)myMethodWhichMayFail2:(NSError **)error { // no-warning
28 if (error) *error = [NSError errorWithDomain:@"domain" code:1 userInfo:0]; // no-warning
29 return 0;
30}
31@end