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