2013-09-28 04:21:48 +08:00
|
|
|
// RUN: %clang_cc1 -x objective-c -fsyntax-only -verify -Wno-objc-root-class %s
|
|
|
|
// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s
|
2012-01-04 03:46:00 +08:00
|
|
|
|
2012-01-06 06:47:47 +08:00
|
|
|
#if __has_attribute(objc_requires_property_definitions)
|
|
|
|
__attribute ((objc_requires_property_definitions))
|
2012-01-05 06:29:28 +08:00
|
|
|
#endif
|
2012-01-06 06:47:47 +08:00
|
|
|
@interface NoAuto // expected-note 2 {{class with specified objc_requires_property_definitions attribute is declared here}}
|
2012-01-04 03:46:00 +08:00
|
|
|
@property int NoAutoProp; // expected-note 2 {{property declared here}}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation NoAuto // expected-warning {{property 'NoAutoProp' requires method 'NoAutoProp' to be defined}} \
|
|
|
|
// expected-warning {{property 'NoAutoProp' requires method 'setNoAutoProp:'}}
|
|
|
|
@end
|
|
|
|
|
2012-01-06 06:47:47 +08:00
|
|
|
__attribute ((objc_requires_property_definitions)) // redundant, just for testing
|
|
|
|
@interface Sub : NoAuto // expected-note 3 {{class with specified objc_requires_property_definitions attribute is declared here}}
|
2012-01-04 03:46:00 +08:00
|
|
|
@property (copy) id SubProperty; // expected-note 2 {{property declared here}}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation Sub // expected-warning {{property 'SubProperty' requires method 'SubProperty' to be defined}} \
|
|
|
|
// expected-warning {{property 'SubProperty' requires method 'setSubProperty:' to be defined}}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface Deep : Sub
|
|
|
|
@property (copy) id DeepProperty;
|
|
|
|
@property (copy) id DeepSynthProperty;
|
|
|
|
@property (copy) id DeepMustSynthProperty; // expected-note {{property declared here}}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation Deep // expected-warning {{property 'DeepMustSynthProperty' requires method 'setDeepMustSynthProperty:' to be defined}}
|
|
|
|
@dynamic DeepProperty;
|
|
|
|
@synthesize DeepSynthProperty;
|
|
|
|
- (id) DeepMustSynthProperty { return 0; }
|
|
|
|
@end
|
|
|
|
|
2017-03-23 19:44:25 +08:00
|
|
|
__attribute ((objc_requires_property_definitions)) // expected-error {{'objc_requires_property_definitions' attribute only applies to Objective-C interfaces}}
|
|
|
|
@interface Deep(CAT)
|
2012-01-04 06:52:32 +08:00
|
|
|
@end
|
|
|
|
|
2013-11-25 04:36:50 +08:00
|
|
|
__attribute ((objc_requires_property_definitions)) // expected-error {{'objc_requires_property_definitions' attribute only applies to Objective-C interfaces}}
|
2012-01-04 06:52:32 +08:00
|
|
|
@protocol P @end
|
2013-03-13 03:46:17 +08:00
|
|
|
|
|
|
|
// rdar://13388503
|
|
|
|
@interface NSObject @end
|
|
|
|
@protocol Foo
|
|
|
|
@property (readonly) char isFoo; // expected-note {{property declared here}}
|
2014-10-11 06:08:23 +08:00
|
|
|
@property (readonly) char isNotFree; // expected-note {{property declared here}}
|
2013-03-13 03:46:17 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@interface Bar : NSObject <Foo>
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation Bar
|
|
|
|
- (char)isFoo {
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-13 06:22:38 +08:00
|
|
|
- (char)isNotFree {
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-13 03:46:17 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@interface Baz : Bar
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface Baz ()
|
|
|
|
@property (readwrite) char isFoo; // expected-warning {{auto property synthesis will not synthesize property 'isFoo' because it is 'readwrite' but it will be synthesized 'readonly' via another property}}
|
|
|
|
@property char Property1; // expected-warning {{auto property synthesis will not synthesize property 'Property1' because it cannot share an ivar with another synthesized property}}
|
|
|
|
@property char Property2;
|
2014-07-27 04:52:26 +08:00
|
|
|
@property (readwrite) char isNotFree; // expected-warning {{auto property synthesis will not synthesize property 'isNotFree'}}
|
2013-03-13 03:46:17 +08:00
|
|
|
@end
|
|
|
|
|
2014-07-27 04:52:26 +08:00
|
|
|
@implementation Baz { // expected-note {{detected while default synthesizing properties in class implementation}}
|
2013-03-13 03:46:17 +08:00
|
|
|
char _isFoo;
|
2013-03-13 06:22:38 +08:00
|
|
|
char _isNotFree;
|
2013-03-13 03:46:17 +08:00
|
|
|
}
|
|
|
|
@synthesize Property2 = Property1; // expected-note {{property synthesized here}}
|
2013-03-13 06:22:38 +08:00
|
|
|
|
|
|
|
- (void) setIsNotFree : (char)Arg {
|
|
|
|
_isNotFree = Arg;
|
|
|
|
}
|
|
|
|
|
2013-03-13 03:46:17 +08:00
|
|
|
@end
|
2013-03-22 04:50:53 +08:00
|
|
|
|
|
|
|
// More test where such warnings should not be issued.
|
|
|
|
@protocol MyProtocol
|
|
|
|
-(void)setProp1:(id)x;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@protocol P1 <MyProtocol>
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface B
|
2014-10-11 06:08:23 +08:00
|
|
|
@property (readonly) id prop; // expected-note {{property declared here}}
|
|
|
|
@property (readonly) id prop1; // expected-note {{property declared here}}
|
|
|
|
@property (readonly) id prop2; // expected-note {{property declared here}}
|
2013-03-22 04:50:53 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@interface B()
|
|
|
|
-(void)setProp:(id)x;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface B(cat)
|
|
|
|
@property (readwrite) id prop2;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface S : B<P1>
|
2014-07-27 04:52:26 +08:00
|
|
|
@property (assign,readwrite) id prop; // expected-warning {{auto property synthesis will not synthesize property 'prop'}}
|
|
|
|
@property (assign,readwrite) id prop1; // expected-warning {{auto property synthesis will not synthesize property 'prop1'}}
|
|
|
|
@property (assign,readwrite) id prop2; // expected-warning {{auto property synthesis will not synthesize property 'prop2'}}
|
2013-03-22 04:50:53 +08:00
|
|
|
@end
|
|
|
|
|
2014-07-27 04:52:26 +08:00
|
|
|
@implementation S // expected-note 3 {{detected while default synthesizing properties in class implementation}}
|
2013-03-22 04:50:53 +08:00
|
|
|
@end
|
2013-06-08 02:32:55 +08:00
|
|
|
|
|
|
|
// rdar://14085456
|
|
|
|
// No warning must be issued in this test.
|
|
|
|
@interface ParentObject
|
|
|
|
@end
|
|
|
|
|
|
|
|
@protocol TestObject
|
|
|
|
@property (readonly) int six;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface TestObject : ParentObject <TestObject>
|
|
|
|
@property int six;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation TestObject
|
|
|
|
@synthesize six;
|
|
|
|
@end
|
|
|
|
|
2013-06-08 04:26:51 +08:00
|
|
|
// rdar://14094682
|
|
|
|
// no warning in this test
|
|
|
|
@interface ISAChallenge : NSObject {
|
|
|
|
}
|
|
|
|
|
|
|
|
@property (assign, readonly) int failureCount;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface ISSAChallenge : ISAChallenge {
|
|
|
|
int _failureCount;
|
|
|
|
}
|
|
|
|
@property (assign, readwrite) int failureCount;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation ISAChallenge
|
|
|
|
- (int)failureCount {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation ISSAChallenge
|
|
|
|
|
|
|
|
@synthesize failureCount = _failureCount;
|
|
|
|
@end
|
|
|
|
|
2013-07-24 03:30:11 +08:00
|
|
|
__attribute ((objc_requires_property_definitions(1))) // expected-error {{'objc_requires_property_definitions' attribute takes no arguments}}
|
2013-07-23 23:16:00 +08:00
|
|
|
@interface I1
|
|
|
|
@end
|
2013-09-26 03:36:32 +08:00
|
|
|
|
|
|
|
// rdar://15051465
|
|
|
|
@protocol SubFooling
|
|
|
|
@property(nonatomic, readonly) id hoho; // expected-note 2 {{property declared here}}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@protocol Fooing<SubFooling>
|
|
|
|
@property(nonatomic, readonly) id muahahaha; // expected-note 2 {{property declared here}}
|
|
|
|
@end
|
|
|
|
|
|
|
|
typedef NSObject<Fooing> FooObject;
|
|
|
|
|
|
|
|
@interface Okay : NSObject<Fooing>
|
|
|
|
@end
|
|
|
|
|
2013-12-13 07:40:14 +08:00
|
|
|
@implementation Okay // expected-warning {{auto property synthesis will not synthesize property 'muahahaha' declared in protocol 'Fooing'}} expected-warning {{auto property synthesis will not synthesize property 'hoho' declared in protocol 'SubFooling'}}
|
2017-07-03 18:12:24 +08:00
|
|
|
@end // expected-note 2 {{add a '@synthesize' directive}}
|
2013-09-26 03:36:32 +08:00
|
|
|
|
|
|
|
@interface Fail : FooObject
|
|
|
|
@end
|
|
|
|
|
2013-12-13 07:40:14 +08:00
|
|
|
@implementation Fail // expected-warning {{auto property synthesis will not synthesize property 'muahahaha' declared in protocol 'Fooing'}} expected-warning {{auto property synthesis will not synthesize property 'hoho' declared in protocol 'SubFooling'}}
|
2017-07-03 18:12:24 +08:00
|
|
|
@end // expected-note 2 {{add a '@synthesize' directive}}
|
2013-09-26 03:36:32 +08:00
|
|
|
|
2014-03-06 07:44:00 +08:00
|
|
|
// rdar://16089191
|
|
|
|
@class NSURL;
|
|
|
|
|
|
|
|
@interface Root
|
|
|
|
- (void)setFileURL : (NSURL *) arg;
|
|
|
|
- (void)setFile : (NSURL *) arg;
|
|
|
|
- (NSURL *)fileSys;
|
|
|
|
- (void)setFileSys : (NSURL *) arg;
|
|
|
|
- (NSURL *)fileKerl;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface SuperClass : Root
|
|
|
|
- (NSURL *)fileURL;
|
|
|
|
- (NSURL *)file;
|
|
|
|
- (NSURL *)fileLog;
|
|
|
|
- (void)setFileLog : (NSURL *) arg;
|
|
|
|
- (void)setFileKerl : (NSURL *) arg;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@protocol r16089191Protocol
|
|
|
|
@property (readonly) NSURL *fileURL;
|
2014-03-12 01:17:16 +08:00
|
|
|
@property (copy) NSURL *file;
|
|
|
|
@property (copy) NSURL *fileSys;
|
|
|
|
@property (copy) NSURL *fileLog;
|
|
|
|
@property (copy) NSURL *fileKerl;
|
2014-03-06 07:44:00 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@interface SubClass : SuperClass <r16089191Protocol>
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation SubClass
|
|
|
|
@end
|