1*67e74705SXin Li// RUN: %clang_cc1 -fsyntax-only -Wunused-property-ivar -verify -Wno-objc-root-class %s 2*67e74705SXin Li// rdar://14989999 3*67e74705SXin Li 4*67e74705SXin Li@interface NSObject @end 5*67e74705SXin Li 6*67e74705SXin Li@interface Example : NSObject 7*67e74705SXin Li@property (nonatomic, copy) id t; // expected-note {{property declared here}} 8*67e74705SXin Li@property (nonatomic, copy) id u; // expected-note {{property declared here}} 9*67e74705SXin Li@property (nonatomic, copy) id v; // expected-note {{property declared here}} 10*67e74705SXin Li@property (nonatomic, copy) id w; 11*67e74705SXin Li@property (nonatomic, copy) id x; // expected-note {{property declared here}} 12*67e74705SXin Li@property (nonatomic, copy) id y; // expected-note {{property declared here}} 13*67e74705SXin Li@property (nonatomic, copy) id z; 14*67e74705SXin Li@property (nonatomic, copy) id ok; 15*67e74705SXin Li@end 16*67e74705SXin Li 17*67e74705SXin Li@implementation Example 18*67e74705SXin Li- (void) setX:(id)newX { // expected-warning {{ivar '_x' which backs the property is not referenced in this property's accessor}} 19*67e74705SXin Li _y = newX; 20*67e74705SXin Li} 21*67e74705SXin Li- (id) y { // expected-warning {{ivar '_y' which backs the property is not referenced in this property's accessor}} 22*67e74705SXin Li return _v; 23*67e74705SXin Li} 24*67e74705SXin Li 25*67e74705SXin Li- (void) setV:(id)newV { // expected-warning {{ivar '_v' which backs the property is not referenced in this property's accessor}} 26*67e74705SXin Li _y = newV; 27*67e74705SXin Li} 28*67e74705SXin Li 29*67e74705SXin Li// No warning here because there is no backing ivar. 30*67e74705SXin Li// both setter/getter are user defined. 31*67e74705SXin Li- (void) setW:(id)newW { 32*67e74705SXin Li _y = newW; 33*67e74705SXin Li} 34*67e74705SXin Li- (id) w { 35*67e74705SXin Li return _v; 36*67e74705SXin Li} 37*67e74705SXin Li 38*67e74705SXin Li- (id) u { // expected-warning {{ivar '_u' which backs the property is not referenced in this property's accessor}} 39*67e74705SXin Li return _v; 40*67e74705SXin Li} 41*67e74705SXin Li 42*67e74705SXin Li@synthesize ok = okIvar; 43*67e74705SXin Li- (void) setOk:(id)newOk { 44*67e74705SXin Li okIvar = newOk; 45*67e74705SXin Li} 46*67e74705SXin Li 47*67e74705SXin Li@synthesize t = tIvar; 48*67e74705SXin Li- (void) setT:(id)newT { // expected-warning {{ivar 'tIvar' which backs the property is not referenced in this property's accessor}} 49*67e74705SXin Li okIvar = newT; 50*67e74705SXin Li} 51*67e74705SXin Li@end 52*67e74705SXin Li 53*67e74705SXin Li// rdar://15473432 54*67e74705SXin Litypedef char BOOL; 55*67e74705SXin Li@interface CalDAVServerVersion { 56*67e74705SXin Li BOOL _supportsTimeRangeFilterWithoutEndDate; 57*67e74705SXin Li} 58*67e74705SXin Li@property (nonatomic, readonly,nonatomic) BOOL supportsTimeRangeFilterWithoutEndDate; 59*67e74705SXin Li@end 60*67e74705SXin Li 61*67e74705SXin Li@interface CalDAVConcreteServerVersion : CalDAVServerVersion { 62*67e74705SXin Li} 63*67e74705SXin Li@end 64*67e74705SXin Li 65*67e74705SXin Li@interface CalendarServerVersion : CalDAVConcreteServerVersion 66*67e74705SXin Li@end 67*67e74705SXin Li 68*67e74705SXin Li@implementation CalDAVServerVersion 69*67e74705SXin Li@synthesize supportsTimeRangeFilterWithoutEndDate=_supportsTimeRangeFilterWithoutEndDate; 70*67e74705SXin Li@end 71*67e74705SXin Li 72*67e74705SXin Li@implementation CalendarServerVersion 73*67e74705SXin Li-(BOOL)supportsTimeRangeFilterWithoutEndDate { 74*67e74705SXin Li return 0; 75*67e74705SXin Li} 76*67e74705SXin Li@end 77*67e74705SXin Li 78*67e74705SXin Li// rdar://15630719 79*67e74705SXin Li@interface CDBModifyRecordsOperation : NSObject 80*67e74705SXin Li@property (nonatomic, assign) BOOL atomic; 81*67e74705SXin Li@end 82*67e74705SXin Li 83*67e74705SXin Li@class NSString; 84*67e74705SXin Li 85*67e74705SXin Li@implementation CDBModifyRecordsOperation 86*67e74705SXin Li- (void)setAtomic:(BOOL)atomic { 87*67e74705SXin Li if (atomic == __objc_yes) { 88*67e74705SXin Li NSString *recordZoneID = 0; 89*67e74705SXin Li } 90*67e74705SXin Li _atomic = atomic; 91*67e74705SXin Li} 92*67e74705SXin Li@end 93*67e74705SXin Li 94*67e74705SXin Li// rdar://15728901 95*67e74705SXin Li@interface GATTOperation : NSObject { 96*67e74705SXin Li long operation; 97*67e74705SXin Li} 98*67e74705SXin Li@property(assign) long operation; 99*67e74705SXin Li@end 100*67e74705SXin Li 101*67e74705SXin Li@implementation GATTOperation 102*67e74705SXin Li@synthesize operation; 103*67e74705SXin Li+ (id) operation { 104*67e74705SXin Li return 0; 105*67e74705SXin Li} 106*67e74705SXin Li@end 107*67e74705SXin Li 108*67e74705SXin Li// rdar://15727327 109*67e74705SXin Li@interface Radar15727327 : NSObject 110*67e74705SXin Li@property (assign, readonly) long p; 111*67e74705SXin Li@property (assign) long q; // expected-note 2 {{property declared here}} 112*67e74705SXin Li@property (assign, readonly) long r; // expected-note {{property declared here}} 113*67e74705SXin Li- (long)Meth; 114*67e74705SXin Li@end 115*67e74705SXin Li 116*67e74705SXin Li@implementation Radar15727327 117*67e74705SXin Li@synthesize p; 118*67e74705SXin Li@synthesize q; 119*67e74705SXin Li@synthesize r; 120*67e74705SXin Li- (long)Meth { return p; } 121*67e74705SXin Li- (long) p { [self Meth]; return 0; } 122*67e74705SXin Li- (long) q { return 0; } // expected-warning {{ivar 'q' which backs the property is not referenced in this property's accessor}} 123*67e74705SXin Li- (void) setQ : (long) val { } // expected-warning {{ivar 'q' which backs the property is not referenced in this property's accessor}} 124*67e74705SXin Li- (long) r { [self Meth]; return p; } // expected-warning {{ivar 'r' which backs the property is not referenced in this property's accessor}} 125*67e74705SXin Li@end 126*67e74705SXin Li 127*67e74705SXin Li@interface I1 128*67e74705SXin Li@property (readonly) int p1; 129*67e74705SXin Li@property (readonly) int p2; // expected-note {{property declared here}} 130*67e74705SXin Li@end 131*67e74705SXin Li 132*67e74705SXin Li@implementation I1 133*67e74705SXin Li@synthesize p1=_p1; 134*67e74705SXin Li@synthesize p2=_p2; 135*67e74705SXin Li 136*67e74705SXin Li-(int)p1 { 137*67e74705SXin Li return [self getP1]; 138*67e74705SXin Li} 139*67e74705SXin Li-(int)getP1 { 140*67e74705SXin Li return _p1; 141*67e74705SXin Li} 142*67e74705SXin Li-(int)getP2 { 143*67e74705SXin Li return _p2; 144*67e74705SXin Li} 145*67e74705SXin Li-(int)p2 { // expected-warning {{ivar '_p2' which backs the property is not referenced in this property's accessor}} 146*67e74705SXin Li Radar15727327 *o; 147*67e74705SXin Li return [o Meth]; 148*67e74705SXin Li} 149*67e74705SXin Li@end 150*67e74705SXin Li 151*67e74705SXin Li// rdar://15873425 152*67e74705SXin Li@protocol MyProtocol 153*67e74705SXin Li@property (nonatomic, readonly) int myProperty; 154*67e74705SXin Li@end 155*67e74705SXin Li 156*67e74705SXin Li@interface MyFirstClass : NSObject <MyProtocol> 157*67e74705SXin Li@end 158*67e74705SXin Li 159*67e74705SXin Li@interface MySecondClass : NSObject <MyProtocol> 160*67e74705SXin Li@end 161*67e74705SXin Li 162*67e74705SXin Li@implementation MyFirstClass 163*67e74705SXin Li@synthesize myProperty; 164*67e74705SXin Li@end 165*67e74705SXin Li 166*67e74705SXin Li@implementation MySecondClass 167*67e74705SXin Li@dynamic myProperty; 168*67e74705SXin Li-(int)myProperty // should not warn; property is dynamic 169*67e74705SXin Li{ 170*67e74705SXin Li return 0; 171*67e74705SXin Li} 172*67e74705SXin Li@end 173*67e74705SXin Li 174*67e74705SXin Li// rdar://15890251 175*67e74705SXin Li@class NSURL; 176*67e74705SXin Li 177*67e74705SXin Li@protocol MCCIDURLProtocolDataProvider 178*67e74705SXin Li@required 179*67e74705SXin Li@property(strong, atomic, readonly) NSURL *cidURL; 180*67e74705SXin Li@property(strong, atomic, readonly) NSURL *cidURL1; // expected-note {{property declared here}} 181*67e74705SXin Li@end 182*67e74705SXin Li 183*67e74705SXin Li@interface UnrelatedClass : NSObject <MCCIDURLProtocolDataProvider> 184*67e74705SXin Li@end 185*67e74705SXin Li 186*67e74705SXin Li@implementation UnrelatedClass 187*67e74705SXin Li@synthesize cidURL = _cidURL; 188*67e74705SXin Li@synthesize cidURL1 = _cidURL1; 189*67e74705SXin Li@end 190*67e74705SXin Li 191*67e74705SXin Li@interface MUIWebAttachmentController : NSObject <MCCIDURLProtocolDataProvider> 192*67e74705SXin Li@end 193*67e74705SXin Li 194*67e74705SXin Li 195*67e74705SXin Li@implementation MUIWebAttachmentController 196*67e74705SXin Li- (NSURL *)cidURL { 197*67e74705SXin Li return 0; 198*67e74705SXin Li} 199*67e74705SXin Li@synthesize cidURL1 = _cidURL1; 200*67e74705SXin Li- (NSURL *)cidURL1 { // expected-warning {{ivar '_cidURL1' which backs the property is not referenced in this property's accessor}} 201*67e74705SXin Li return 0; 202*67e74705SXin Li} 203*67e74705SXin Li@end 204