| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s |
| 2 |
|
| 3 |
@interface A |
| 4 |
-(float) x; // expected-note {{declared here}} |
| 5 |
@property int x; // expected-warning {{type of property 'x' does not match type of accessor 'x'}} |
| 6 |
@end |
| 7 |
|
| 8 |
@interface A (Cat) |
| 9 |
@property int moo; // expected-note {{previous definition is here}} |
| 10 |
@end |
| 11 |
|
| 12 |
@implementation A (Cat) |
| 13 |
-(int) moo { |
| 14 |
return 0; |
| 15 |
} |
| 16 |
-(void) setMoo: (float) x { // expected-warning {{conflicting parameter types in implementation of 'setMoo:': 'int' vs 'float'}} |
| 17 |
} |
| 18 |
@end |
| 19 |
|
| 20 |
|
| 21 |
typedef int T[2]; |
| 22 |
typedef void (F)(void); |
| 23 |
|
| 24 |
@interface C |
| 25 |
@property(assign) T p2; // expected-error {{property cannot have array or function type 'T'}} |
| 26 |
|
| 27 |
@property(assign) F f2; // expected-error {{property cannot have array or function type 'F'}} |
| 28 |
|
| 29 |
@end |
| 30 |
|
| 31 |
|
| 32 |
@class SSyncSet; |
| 33 |
|
| 34 |
@interface SPeer |
| 35 |
@property(nonatomic,readonly,retain) SSyncSet* syncSet; |
| 36 |
@end |
| 37 |
|
| 38 |
@class SSyncSet_iDisk; |
| 39 |
|
| 40 |
@interface SPeer_iDisk_remote1 : SPeer |
| 41 |
- (SSyncSet_iDisk*) syncSet; // expected-note {{declared here}} |
| 42 |
@end |
| 43 |
|
| 44 |
@interface SPeer_iDisk_local |
| 45 |
- (SSyncSet_iDisk*) syncSet; |
| 46 |
@end |
| 47 |
|
| 48 |
@interface SSyncSet |
| 49 |
@end |
| 50 |
|
| 51 |
@interface SSyncSet_iDisk |
| 52 |
@property(nonatomic,readonly,retain) SPeer_iDisk_local* localPeer; |
| 53 |
@end |
| 54 |
|
| 55 |
@interface SPeer_iDisk_remote1 (protected) |
| 56 |
@end |
| 57 |
|
| 58 |
@implementation SPeer_iDisk_remote1 (protected) |
| 59 |
- (id) preferredSource1 |
| 60 |
{ |
| 61 |
return self.syncSet.localPeer; // expected-warning {{type of property 'syncSet' does not match type of accessor 'syncSet'}} |
| 62 |
} |
| 63 |
@end |
| 64 |
|
| 65 |
@interface NSArray @end |
| 66 |
|
| 67 |
@interface NSMutableArray : NSArray |
| 68 |
@end |
| 69 |
|
| 70 |
@interface Class1 |
| 71 |
{ |
| 72 |
NSMutableArray* pieces; |
| 73 |
NSArray* first; |
| 74 |
} |
| 75 |
|
| 76 |
@property (readonly) NSArray* pieces; // expected-warning {{type of property 'pieces' does not match type of accessor 'pieces'}} |
| 77 |
@property (readonly) NSMutableArray* first; |
| 78 |
|
| 79 |
- (NSMutableArray*) pieces; // expected-note 2 {{declared here}} |
| 80 |
- (NSArray*) first; |
| 81 |
|
| 82 |
// Don't warn about setter-like methods for readonly properties. |
| 83 |
- (void)setFirst:(char)val; |
| 84 |
- (void)setPieces:(char)val; |
| 85 |
|
| 86 |
@end |
| 87 |
|
| 88 |
@interface Class2 { |
| 89 |
Class1* container; |
| 90 |
} |
| 91 |
|
| 92 |
@end |
| 93 |
|
| 94 |
@implementation Class2 |
| 95 |
|
| 96 |
- (id) lastPiece |
| 97 |
{ |
| 98 |
return container.pieces; // expected-warning {{type of property 'pieces' does not match type of accessor 'pieces'}} |
| 99 |
} |
| 100 |
|
| 101 |
- (id)firstPiece |
| 102 |
{ |
| 103 |
return container.first; |
| 104 |
} |
| 105 |
@end |
| 106 |
|