1 // RUN: %clang_cc1 -fsyntax-only -Wunused-property-ivar -verify -Wno-objc-root-class %s
3 @interface NSObject @end
5 @interface Example : NSObject
6 @property (nonatomic, copy) id t; // expected-note {{property declared here}}
7 @property (nonatomic, copy) id u; // expected-note {{property declared here}}
8 @property (nonatomic, copy) id v; // expected-note {{property declared here}}
9 @property (nonatomic, copy) id w;
10 @property (nonatomic, copy) id x; // expected-note {{property declared here}}
11 @property (nonatomic, copy) id y; // expected-note {{property declared here}}
12 @property (nonatomic, copy) id z;
13 @property (nonatomic, copy) id ok;
16 @implementation Example
17 - (void) setX:(id)newX { // expected-warning {{ivar '_x' which backs the property is not referenced in this property's accessor}}
20 - (id) y { // expected-warning {{ivar '_y' which backs the property is not referenced in this property's accessor}}
24 - (void) setV:(id)newV { // expected-warning {{ivar '_v' which backs the property is not referenced in this property's accessor}}
28 // No warning here because there is no backing ivar.
29 // both setter/getter are user defined.
30 - (void) setW:(id)newW {
37 - (id) u { // expected-warning {{ivar '_u' which backs the property is not referenced in this property's accessor}}
41 @synthesize ok = okIvar;
42 - (void) setOk:(id)newOk {
46 @synthesize t = tIvar;
47 - (void) setT:(id)newT { // expected-warning {{ivar 'tIvar' which backs the property is not referenced in this property's accessor}}
53 @interface CalDAVServerVersion {
54 BOOL _supportsTimeRangeFilterWithoutEndDate;
56 @property (nonatomic, readonly,nonatomic) BOOL supportsTimeRangeFilterWithoutEndDate;
59 @interface CalDAVConcreteServerVersion : CalDAVServerVersion {
63 @interface CalendarServerVersion : CalDAVConcreteServerVersion
66 @implementation CalDAVServerVersion
67 @synthesize supportsTimeRangeFilterWithoutEndDate=_supportsTimeRangeFilterWithoutEndDate;
70 @implementation CalendarServerVersion
71 -(BOOL)supportsTimeRangeFilterWithoutEndDate {
76 @interface CDBModifyRecordsOperation : NSObject
77 @property (nonatomic, assign) BOOL atomic;
82 @implementation CDBModifyRecordsOperation
83 - (void)setAtomic:(BOOL)atomic {
84 if (atomic == __objc_yes) {
85 NSString *recordZoneID = 0;
91 @interface GATTOperation : NSObject {
94 @property(assign) long operation;
97 @implementation GATTOperation
98 @synthesize operation;
104 @interface Radar15727327 : NSObject
105 @property (assign, readonly) long p;
106 @property (assign) long q; // expected-note 2 {{property declared here}}
107 @property (assign, readonly) long r; // expected-note {{property declared here}}
111 @implementation Radar15727327
115 - (long)Meth { return p; }
116 - (long) p { [self Meth]; return 0; }
117 - (long) q { return 0; } // expected-warning {{ivar 'q' which backs the property is not referenced in this property's accessor}}
118 - (void) setQ : (long) val { } // expected-warning {{ivar 'q' which backs the property is not referenced in this property's accessor}}
119 - (long) r { [self Meth]; return p; } // expected-warning {{ivar 'r' which backs the property is not referenced in this property's accessor}}
123 @property (readonly) int p1;
124 @property (readonly) int p2; // expected-note {{property declared here}}
140 -(int)p2 { // expected-warning {{ivar '_p2' which backs the property is not referenced in this property's accessor}}
147 @property (nonatomic, readonly) int myProperty;
150 @interface MyFirstClass : NSObject <MyProtocol>
153 @interface MySecondClass : NSObject <MyProtocol>
156 @implementation MyFirstClass
157 @synthesize myProperty;
160 @implementation MySecondClass
162 -(int)myProperty // should not warn; property is dynamic
170 @protocol MCCIDURLProtocolDataProvider
172 @property(strong, atomic, readonly) NSURL *cidURL;
173 @property(strong, atomic, readonly) NSURL *cidURL1; // expected-note {{property declared here}}
176 @interface UnrelatedClass : NSObject <MCCIDURLProtocolDataProvider>
179 @implementation UnrelatedClass
180 @synthesize cidURL = _cidURL;
181 @synthesize cidURL1 = _cidURL1;
184 @interface MUIWebAttachmentController : NSObject <MCCIDURLProtocolDataProvider>
188 @implementation MUIWebAttachmentController
192 @synthesize cidURL1 = _cidURL1;
193 - (NSURL *)cidURL1 { // expected-warning {{ivar '_cidURL1' which backs the property is not referenced in this property's accessor}}