]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/SemaObjC/unsued-backing-ivar-warning.m
Vendor import of clang release_34 branch r197841 (effectively, 3.4 RC3):
[FreeBSD/FreeBSD.git] / test / SemaObjC / unsued-backing-ivar-warning.m
1 // RUN: %clang_cc1  -fsyntax-only -Wunused-property-ivar -verify -Wno-objc-root-class %s
2 // rdar://14989999
3
4 @interface NSObject @end
5
6 @interface Example : NSObject
7 @property (nonatomic, copy) id t; // expected-note {{property declared here}}
8 @property (nonatomic, copy) id u; // expected-note {{property declared here}}
9 @property (nonatomic, copy) id v; // expected-note {{property declared here}}
10 @property (nonatomic, copy) id w;
11 @property (nonatomic, copy) id x; // expected-note {{property declared here}}
12 @property (nonatomic, copy) id y; // expected-note {{property declared here}}
13 @property (nonatomic, copy) id z;
14 @property (nonatomic, copy) id ok;
15 @end
16
17 @implementation Example
18 - (void) setX:(id)newX {  // expected-warning {{ivar '_x' which backs the property is not referenced in this property's accessor}}
19     _y = newX;
20 }
21 - (id) y { // expected-warning {{ivar '_y' which backs the property is not referenced in this property's accessor}}
22   return _v;
23 }
24
25 - (void) setV:(id)newV { // expected-warning {{ivar '_v' which backs the property is not referenced in this property's accessor}}
26     _y = newV;
27 }
28
29 // No warning here because there is no backing ivar.
30 // both setter/getter are user defined.
31 - (void) setW:(id)newW {
32     _y = newW;
33 }
34 - (id) w {
35   return _v;
36 }
37
38 - (id) u { // expected-warning {{ivar '_u' which backs the property is not referenced in this property's accessor}}
39   return _v;
40 }
41
42 @synthesize ok = okIvar;
43 - (void) setOk:(id)newOk {
44     okIvar = newOk;
45 }
46
47 @synthesize t = tIvar;
48 - (void) setT:(id)newT { // expected-warning {{ivar 'tIvar' which backs the property is not referenced in this property's accessor}}
49     okIvar = newT;
50 }
51 @end
52
53 // rdar://15473432
54 typedef char BOOL;
55 @interface CalDAVServerVersion {
56   BOOL _supportsTimeRangeFilterWithoutEndDate;
57 }
58 @property (nonatomic, readonly,nonatomic) BOOL supportsTimeRangeFilterWithoutEndDate;
59 @end
60
61 @interface CalDAVConcreteServerVersion : CalDAVServerVersion {
62 }
63 @end
64
65 @interface CalendarServerVersion : CalDAVConcreteServerVersion
66 @end
67
68 @implementation CalDAVServerVersion
69 @synthesize supportsTimeRangeFilterWithoutEndDate=_supportsTimeRangeFilterWithoutEndDate;
70 @end
71
72 @implementation CalendarServerVersion
73 -(BOOL)supportsTimeRangeFilterWithoutEndDate {
74   return 0;
75 }
76 @end