xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/atomoic-property-synnthesis-rules.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc/*
4*f4a2713aSLionel Sambuc  Conditions for warning:
5*f4a2713aSLionel Sambuc  1. the property is atomic
6*f4a2713aSLionel Sambuc  2. the current @implementation contains an @synthesize for the property
7*f4a2713aSLionel Sambuc  3. the current @implementation contains a hand-written setter XOR getter
8*f4a2713aSLionel Sambuc  4. the property is read-write
9*f4a2713aSLionel Sambuc
10*f4a2713aSLionel Sambuc  Cases marked WARN should warn one the following:
11*f4a2713aSLionel Sambuc  warning: Atomic property 'x' has a synthesized setter and a
12*f4a2713aSLionel Sambuc  manually-implemented getter, which may break atomicity.
13*f4a2713aSLionel Sambuc  warning: Atomic property 'x' has a synthesized getter and a
14*f4a2713aSLionel Sambuc  manually-implemented setter, which may break atomicity.
15*f4a2713aSLionel Sambuc
16*f4a2713aSLionel Sambuc  Cases not marked WARN only satisfy the indicated subset
17*f4a2713aSLionel Sambuc  of the conditions required to warn.
18*f4a2713aSLionel Sambuc
19*f4a2713aSLionel Sambuc  There should be 8 warnings.
20*f4a2713aSLionel Sambuc*/
21*f4a2713aSLionel Sambuc
22*f4a2713aSLionel Sambuc@interface Foo
23*f4a2713aSLionel Sambuc{
24*f4a2713aSLionel Sambuc    /* 12 4 */    int GetSet;
25*f4a2713aSLionel Sambuc    /* WARN */    int Get;
26*f4a2713aSLionel Sambuc    /* WARN */    int Set;
27*f4a2713aSLionel Sambuc    /* 12 4 */    int None;
28*f4a2713aSLionel Sambuc    /*  2 4 */    int GetSet_Nonatomic;
29*f4a2713aSLionel Sambuc    /*  234 */    int Get_Nonatomic;
30*f4a2713aSLionel Sambuc    /*  234 */    int Set_Nonatomic;
31*f4a2713aSLionel Sambuc    /*  2 4 */    int None_Nonatomic;
32*f4a2713aSLionel Sambuc
33*f4a2713aSLionel Sambuc    /* 12   */    int GetSet_ReadOnly;
34*f4a2713aSLionel Sambuc    /* 123  */    int Get_ReadOnly;
35*f4a2713aSLionel Sambuc    /* 123  */    int Set_ReadOnly;
36*f4a2713aSLionel Sambuc    /* 12   */    int None_ReadOnly;
37*f4a2713aSLionel Sambuc    /*  2   */    int GetSet_Nonatomic_ReadOnly;
38*f4a2713aSLionel Sambuc    /*  23  */    int Get_Nonatomic_ReadOnly;
39*f4a2713aSLionel Sambuc    /*  23  */    int Set_Nonatomic_ReadOnly;
40*f4a2713aSLionel Sambuc    /*  2   */    int None_Nonatomic_ReadOnly;
41*f4a2713aSLionel Sambuc
42*f4a2713aSLionel Sambuc    /* 12 4 */    int GetSet_ReadWriteInExt;
43*f4a2713aSLionel Sambuc    /* WARN */    int Get_ReadWriteInExt;
44*f4a2713aSLionel Sambuc    /* WARN */    int Set_ReadWriteInExt;
45*f4a2713aSLionel Sambuc    /* 12 4 */    int None_ReadWriteInExt;
46*f4a2713aSLionel Sambuc    /*  2 4 */    int GetSet_Nonatomic_ReadWriteInExt;
47*f4a2713aSLionel Sambuc    /*  234 */    int Get_Nonatomic_ReadWriteInExt;
48*f4a2713aSLionel Sambuc    /*  234 */    int Set_Nonatomic_ReadWriteInExt;
49*f4a2713aSLionel Sambuc    /*  2 4 */    int None_Nonatomic_ReadWriteInExt;
50*f4a2713aSLionel Sambuc
51*f4a2713aSLionel Sambuc
52*f4a2713aSLionel Sambuc    /* 12 4 */    int GetSet_LateSynthesize;
53*f4a2713aSLionel Sambuc    /* WARN */    int Get_LateSynthesize;
54*f4a2713aSLionel Sambuc    /* WARN */    int Set_LateSynthesize;
55*f4a2713aSLionel Sambuc    /* 12 4 */    int None_LateSynthesize;
56*f4a2713aSLionel Sambuc    /*  2 4 */    int GetSet_Nonatomic_LateSynthesize;
57*f4a2713aSLionel Sambuc    /*  234 */    int Get_Nonatomic_LateSynthesize;
58*f4a2713aSLionel Sambuc    /*  234 */    int Set_Nonatomic_LateSynthesize;
59*f4a2713aSLionel Sambuc    /*  2 4 */    int None_Nonatomic_LateSynthesize;
60*f4a2713aSLionel Sambuc
61*f4a2713aSLionel Sambuc    /* 12   */    int GetSet_ReadOnly_LateSynthesize;
62*f4a2713aSLionel Sambuc    /* 123  */    int Get_ReadOnly_LateSynthesize;
63*f4a2713aSLionel Sambuc    /* 123  */    int Set_ReadOnly_LateSynthesize;
64*f4a2713aSLionel Sambuc    /* 12   */    int None_ReadOnly_LateSynthesize;
65*f4a2713aSLionel Sambuc    /*  2   */    int GetSet_Nonatomic_ReadOnly_LateSynthesize;
66*f4a2713aSLionel Sambuc    /*  23  */    int Get_Nonatomic_ReadOnly_LateSynthesize;
67*f4a2713aSLionel Sambuc    /*  23  */    int Set_Nonatomic_ReadOnly_LateSynthesize;
68*f4a2713aSLionel Sambuc    /*  2   */    int None_Nonatomic_ReadOnly_LateSynthesize;
69*f4a2713aSLionel Sambuc
70*f4a2713aSLionel Sambuc    /* 12 4 */    int GetSet_ReadWriteInExt_LateSynthesize;
71*f4a2713aSLionel Sambuc    /* WARN */    int Get_ReadWriteInExt_LateSynthesize;
72*f4a2713aSLionel Sambuc    /* WARN */    int Set_ReadWriteInExt_LateSynthesize;
73*f4a2713aSLionel Sambuc    /* 12 4 */    int None_ReadWriteInExt_LateSynthesize;
74*f4a2713aSLionel Sambuc    /*  2 4 */    int GetSet_Nonatomic_ReadWriteInExt_LateSynthesize;
75*f4a2713aSLionel Sambuc    /*  234 */    int Get_Nonatomic_ReadWriteInExt_LateSynthesize;
76*f4a2713aSLionel Sambuc    /*  234 */    int Set_Nonatomic_ReadWriteInExt_LateSynthesize;
77*f4a2713aSLionel Sambuc    /*  2 4 */    int None_Nonatomic_ReadWriteInExt_LateSynthesize;
78*f4a2713aSLionel Sambuc
79*f4a2713aSLionel Sambuc
80*f4a2713aSLionel Sambuc    /* 1  4 */    int GetSet_NoSynthesize;
81*f4a2713aSLionel Sambuc    /* 1 34 */    int Get_NoSynthesize;
82*f4a2713aSLionel Sambuc    /* 1 34 */    int Set_NoSynthesize;
83*f4a2713aSLionel Sambuc    /* 1  4 */    int None_NoSynthesize;
84*f4a2713aSLionel Sambuc    /*    4 */    int GetSet_Nonatomic_NoSynthesize;
85*f4a2713aSLionel Sambuc    /*   34 */    int Get_Nonatomic_NoSynthesize;
86*f4a2713aSLionel Sambuc    /*   34 */    int Set_Nonatomic_NoSynthesize;
87*f4a2713aSLionel Sambuc    /*    4 */    int None_Nonatomic_NoSynthesize;
88*f4a2713aSLionel Sambuc
89*f4a2713aSLionel Sambuc    /* 1    */    int GetSet_ReadOnly_NoSynthesize;
90*f4a2713aSLionel Sambuc    /* 1 3  */    int Get_ReadOnly_NoSynthesize;
91*f4a2713aSLionel Sambuc    /* 1 3  */    int Set_ReadOnly_NoSynthesize;
92*f4a2713aSLionel Sambuc    /* 1    */    int None_ReadOnly_NoSynthesize;
93*f4a2713aSLionel Sambuc    /*      */    int GetSet_Nonatomic_ReadOnly_NoSynthesize;
94*f4a2713aSLionel Sambuc    /*   3  */    int Get_Nonatomic_ReadOnly_NoSynthesize;
95*f4a2713aSLionel Sambuc    /*   3  */    int Set_Nonatomic_ReadOnly_NoSynthesize;
96*f4a2713aSLionel Sambuc    /*      */    int None_Nonatomic_ReadOnly_NoSynthesize;
97*f4a2713aSLionel Sambuc
98*f4a2713aSLionel Sambuc    /* 1  4 */    int GetSet_ReadWriteInExt_NoSynthesize;
99*f4a2713aSLionel Sambuc    /* 1 34 */    int Get_ReadWriteInExt_NoSynthesize;
100*f4a2713aSLionel Sambuc    /* 1 34 */    int Set_ReadWriteInExt_NoSynthesize;
101*f4a2713aSLionel Sambuc    /* 1  4 */    int None_ReadWriteInExt_NoSynthesize;
102*f4a2713aSLionel Sambuc    /*    4 */    int GetSet_Nonatomic_ReadWriteInExt_NoSynthesize;
103*f4a2713aSLionel Sambuc    /*   34 */    int Get_Nonatomic_ReadWriteInExt_NoSynthesize;
104*f4a2713aSLionel Sambuc    /*   34 */    int Set_Nonatomic_ReadWriteInExt_NoSynthesize;
105*f4a2713aSLionel Sambuc    /*    4 */    int None_Nonatomic_ReadWriteInExt_NoSynthesize;
106*f4a2713aSLionel Sambuc}
107*f4a2713aSLionel Sambuc
108*f4a2713aSLionel Sambuc// read-write - might warn
109*f4a2713aSLionel Sambuc@property int GetSet;
110*f4a2713aSLionel Sambuc@property int Get;	// expected-note {{property declared here}} \
111*f4a2713aSLionel Sambuc                        // expected-note {{setter and getter must both be synthesized}}
112*f4a2713aSLionel Sambuc@property int Set;	// expected-note {{property declared here}} \
113*f4a2713aSLionel Sambuc                        // expected-note {{setter and getter must both be synthesized}}
114*f4a2713aSLionel Sambuc@property int None;
115*f4a2713aSLionel Sambuc@property(nonatomic) int GetSet_Nonatomic;
116*f4a2713aSLionel Sambuc@property(nonatomic) int Get_Nonatomic;
117*f4a2713aSLionel Sambuc@property(nonatomic) int Set_Nonatomic;
118*f4a2713aSLionel Sambuc@property(nonatomic) int None_Nonatomic;
119*f4a2713aSLionel Sambuc
120*f4a2713aSLionel Sambuc// read-only - must not warn
121*f4a2713aSLionel Sambuc@property(readonly) int GetSet_ReadOnly;
122*f4a2713aSLionel Sambuc@property(readonly) int Get_ReadOnly;
123*f4a2713aSLionel Sambuc@property(readonly) int Set_ReadOnly;
124*f4a2713aSLionel Sambuc@property(readonly) int None_ReadOnly;
125*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int GetSet_Nonatomic_ReadOnly;
126*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int Get_Nonatomic_ReadOnly;
127*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int Set_Nonatomic_ReadOnly;
128*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int None_Nonatomic_ReadOnly;
129*f4a2713aSLionel Sambuc
130*f4a2713aSLionel Sambuc// read-only in class, read-write in class extension - might warn
131*f4a2713aSLionel Sambuc@property(readonly) int GetSet_ReadWriteInExt;
132*f4a2713aSLionel Sambuc@property(readonly) int Get_ReadWriteInExt;	// expected-note {{property declared here}} \
133*f4a2713aSLionel Sambuc                                                // expected-note {{setter and getter must both be synthesized}}
134*f4a2713aSLionel Sambuc@property(readonly) int Set_ReadWriteInExt;	// expected-note {{property declared here}} \
135*f4a2713aSLionel Sambuc                                                // expected-note {{setter and getter must both be synthesized}}
136*f4a2713aSLionel Sambuc@property(readonly) int None_ReadWriteInExt;
137*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int GetSet_Nonatomic_ReadWriteInExt;
138*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int Get_Nonatomic_ReadWriteInExt;
139*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int Set_Nonatomic_ReadWriteInExt;
140*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int None_Nonatomic_ReadWriteInExt;
141*f4a2713aSLionel Sambuc
142*f4a2713aSLionel Sambuc
143*f4a2713aSLionel Sambuc// same as above, but @synthesize follows the hand-written methods - might warn
144*f4a2713aSLionel Sambuc@property int GetSet_LateSynthesize;
145*f4a2713aSLionel Sambuc@property int Get_LateSynthesize;	// expected-note {{property declared here}} \
146*f4a2713aSLionel Sambuc                                        // expected-note {{setter and getter must both be synthesized}}
147*f4a2713aSLionel Sambuc@property int Set_LateSynthesize;	// expected-note {{property declared here}} \
148*f4a2713aSLionel Sambuc                                        // expected-note {{setter and getter must both be synthesized}}
149*f4a2713aSLionel Sambuc@property int None_LateSynthesize;
150*f4a2713aSLionel Sambuc@property(nonatomic) int GetSet_Nonatomic_LateSynthesize;
151*f4a2713aSLionel Sambuc@property(nonatomic) int Get_Nonatomic_LateSynthesize;
152*f4a2713aSLionel Sambuc@property(nonatomic) int Set_Nonatomic_LateSynthesize;
153*f4a2713aSLionel Sambuc@property(nonatomic) int None_Nonatomic_LateSynthesize;
154*f4a2713aSLionel Sambuc
155*f4a2713aSLionel Sambuc@property(readonly) int GetSet_ReadOnly_LateSynthesize;
156*f4a2713aSLionel Sambuc@property(readonly) int Get_ReadOnly_LateSynthesize;
157*f4a2713aSLionel Sambuc@property(readonly) int Set_ReadOnly_LateSynthesize;
158*f4a2713aSLionel Sambuc@property(readonly) int None_ReadOnly_LateSynthesize;
159*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int GetSet_Nonatomic_ReadOnly_LateSynthesize;
160*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int Get_Nonatomic_ReadOnly_LateSynthesize;
161*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int Set_Nonatomic_ReadOnly_LateSynthesize;
162*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int None_Nonatomic_ReadOnly_LateSynthesize;
163*f4a2713aSLionel Sambuc
164*f4a2713aSLionel Sambuc@property(readonly) int GetSet_ReadWriteInExt_LateSynthesize;
165*f4a2713aSLionel Sambuc@property(readonly) int Get_ReadWriteInExt_LateSynthesize;	// expected-note {{property declared here}} \
166*f4a2713aSLionel Sambuc                                                                // expected-note {{setter and getter must both be synthesized}}
167*f4a2713aSLionel Sambuc@property(readonly) int Set_ReadWriteInExt_LateSynthesize;	// expected-note {{property declared here}} \
168*f4a2713aSLionel Sambuc                                                                // expected-note {{setter and getter must both be synthesized}}
169*f4a2713aSLionel Sambuc@property(readonly) int None_ReadWriteInExt_LateSynthesize;
170*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int GetSet_Nonatomic_ReadWriteInExt_LateSynthesize;
171*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int Get_Nonatomic_ReadWriteInExt_LateSynthesize;
172*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int Set_Nonatomic_ReadWriteInExt_LateSynthesize;
173*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int None_Nonatomic_ReadWriteInExt_LateSynthesize;
174*f4a2713aSLionel Sambuc
175*f4a2713aSLionel Sambuc
176*f4a2713aSLionel Sambuc// same as above, but with no @synthesize - must not warn
177*f4a2713aSLionel Sambuc@property int GetSet_NoSynthesize;
178*f4a2713aSLionel Sambuc@property int Get_NoSynthesize;
179*f4a2713aSLionel Sambuc@property int Set_NoSynthesize;
180*f4a2713aSLionel Sambuc@property int None_NoSynthesize;
181*f4a2713aSLionel Sambuc@property(nonatomic) int GetSet_Nonatomic_NoSynthesize;
182*f4a2713aSLionel Sambuc@property(nonatomic) int Get_Nonatomic_NoSynthesize;
183*f4a2713aSLionel Sambuc@property(nonatomic) int Set_Nonatomic_NoSynthesize;
184*f4a2713aSLionel Sambuc@property(nonatomic) int None_Nonatomic_NoSynthesize;
185*f4a2713aSLionel Sambuc
186*f4a2713aSLionel Sambuc@property(readonly) int GetSet_ReadOnly_NoSynthesize;
187*f4a2713aSLionel Sambuc@property(readonly) int Get_ReadOnly_NoSynthesize;
188*f4a2713aSLionel Sambuc@property(readonly) int Set_ReadOnly_NoSynthesize;
189*f4a2713aSLionel Sambuc@property(readonly) int None_ReadOnly_NoSynthesize;
190*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int GetSet_Nonatomic_ReadOnly_NoSynthesize;
191*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int Get_Nonatomic_ReadOnly_NoSynthesize;
192*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int Set_Nonatomic_ReadOnly_NoSynthesize;
193*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int None_Nonatomic_ReadOnly_NoSynthesize;
194*f4a2713aSLionel Sambuc
195*f4a2713aSLionel Sambuc@property(readonly) int GetSet_ReadWriteInExt_NoSynthesize;
196*f4a2713aSLionel Sambuc@property(readonly) int Get_ReadWriteInExt_NoSynthesize;
197*f4a2713aSLionel Sambuc@property(readonly) int Set_ReadWriteInExt_NoSynthesize;
198*f4a2713aSLionel Sambuc@property(readonly) int None_ReadWriteInExt_NoSynthesize;
199*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int GetSet_Nonatomic_ReadWriteInExt_NoSynthesize;
200*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int Get_Nonatomic_ReadWriteInExt_NoSynthesize;
201*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int Set_Nonatomic_ReadWriteInExt_NoSynthesize;
202*f4a2713aSLionel Sambuc@property(nonatomic,readonly) int None_Nonatomic_ReadWriteInExt_NoSynthesize;
203*f4a2713aSLionel Sambuc
204*f4a2713aSLionel Sambuc@end
205*f4a2713aSLionel Sambuc
206*f4a2713aSLionel Sambuc
207*f4a2713aSLionel Sambuc@interface Foo ()
208*f4a2713aSLionel Sambuc
209*f4a2713aSLionel Sambuc@property(readwrite) int GetSet_ReadWriteInExt;
210*f4a2713aSLionel Sambuc@property(readwrite) int Get_ReadWriteInExt;
211*f4a2713aSLionel Sambuc@property(readwrite) int Set_ReadWriteInExt;
212*f4a2713aSLionel Sambuc@property(readwrite) int None_ReadWriteInExt;
213*f4a2713aSLionel Sambuc@property(nonatomic,readwrite) int GetSet_Nonatomic_ReadWriteInExt;
214*f4a2713aSLionel Sambuc@property(nonatomic,readwrite) int Get_Nonatomic_ReadWriteInExt;
215*f4a2713aSLionel Sambuc@property(nonatomic,readwrite) int Set_Nonatomic_ReadWriteInExt;
216*f4a2713aSLionel Sambuc@property(nonatomic,readwrite) int None_Nonatomic_ReadWriteInExt;
217*f4a2713aSLionel Sambuc
218*f4a2713aSLionel Sambuc@property(readwrite) int GetSet_ReadWriteInExt_LateSynthesize;
219*f4a2713aSLionel Sambuc@property(readwrite) int Get_ReadWriteInExt_LateSynthesize;
220*f4a2713aSLionel Sambuc@property(readwrite) int Set_ReadWriteInExt_LateSynthesize;
221*f4a2713aSLionel Sambuc@property(readwrite) int None_ReadWriteInExt_LateSynthesize;
222*f4a2713aSLionel Sambuc@property(nonatomic,readwrite) int GetSet_Nonatomic_ReadWriteInExt_LateSynthesize;
223*f4a2713aSLionel Sambuc@property(nonatomic,readwrite) int Get_Nonatomic_ReadWriteInExt_LateSynthesize;
224*f4a2713aSLionel Sambuc@property(nonatomic,readwrite) int Set_Nonatomic_ReadWriteInExt_LateSynthesize;
225*f4a2713aSLionel Sambuc@property(nonatomic,readwrite) int None_Nonatomic_ReadWriteInExt_LateSynthesize;
226*f4a2713aSLionel Sambuc
227*f4a2713aSLionel Sambuc@property(readwrite) int GetSet_ReadWriteInExt_NoSynthesize;
228*f4a2713aSLionel Sambuc@property(readwrite) int Get_ReadWriteInExt_NoSynthesize;
229*f4a2713aSLionel Sambuc@property(readwrite) int Set_ReadWriteInExt_NoSynthesize;
230*f4a2713aSLionel Sambuc@property(readwrite) int None_ReadWriteInExt_NoSynthesize;
231*f4a2713aSLionel Sambuc@property(nonatomic,readwrite) int GetSet_Nonatomic_ReadWriteInExt_NoSynthesize;
232*f4a2713aSLionel Sambuc@property(nonatomic,readwrite) int Get_Nonatomic_ReadWriteInExt_NoSynthesize;
233*f4a2713aSLionel Sambuc@property(nonatomic,readwrite) int Set_Nonatomic_ReadWriteInExt_NoSynthesize;
234*f4a2713aSLionel Sambuc@property(nonatomic,readwrite) int None_Nonatomic_ReadWriteInExt_NoSynthesize;
235*f4a2713aSLionel Sambuc
236*f4a2713aSLionel Sambuc@end
237*f4a2713aSLionel Sambuc
238*f4a2713aSLionel Sambuc@implementation Foo
239*f4a2713aSLionel Sambuc
240*f4a2713aSLionel Sambuc@synthesize GetSet, Get, Set, None, GetSet_Nonatomic, Get_Nonatomic, Set_Nonatomic, None_Nonatomic;
241*f4a2713aSLionel Sambuc@synthesize GetSet_ReadOnly, Get_ReadOnly, Set_ReadOnly, None_ReadOnly, GetSet_Nonatomic_ReadOnly, Get_Nonatomic_ReadOnly, Set_Nonatomic_ReadOnly, None_Nonatomic_ReadOnly;
242*f4a2713aSLionel Sambuc@synthesize GetSet_ReadWriteInExt, Get_ReadWriteInExt, Set_ReadWriteInExt, None_ReadWriteInExt, GetSet_Nonatomic_ReadWriteInExt, Get_Nonatomic_ReadWriteInExt, Set_Nonatomic_ReadWriteInExt, None_Nonatomic_ReadWriteInExt;
243*f4a2713aSLionel Sambuc
244*f4a2713aSLionel Sambuc#define GET(x) \
245*f4a2713aSLionel Sambuc    -(int) x { return self->x; }
246*f4a2713aSLionel Sambuc#define SET(x) \
247*f4a2713aSLionel Sambuc    -(void) set##x:(int)value { self->x = value; }
248*f4a2713aSLionel Sambuc
249*f4a2713aSLionel SambucGET(GetSet)
250*f4a2713aSLionel SambucSET(GetSet)
251*f4a2713aSLionel SambucGET(Get) // expected-warning {{writable atomic property 'Get' cannot pair a synthesized setter with a user defined getter}}
252*f4a2713aSLionel SambucSET(Set) // expected-warning {{writable atomic property 'Set' cannot pair a synthesized getter with a user defined setter}}
253*f4a2713aSLionel SambucGET(GetSet_Nonatomic)
254*f4a2713aSLionel SambucSET(GetSet_Nonatomic)
255*f4a2713aSLionel SambucGET(Get_Nonatomic)
256*f4a2713aSLionel SambucSET(Set_Nonatomic)
257*f4a2713aSLionel Sambuc
258*f4a2713aSLionel SambucGET(GetSet_ReadOnly)
259*f4a2713aSLionel SambucSET(GetSet_ReadOnly)
260*f4a2713aSLionel SambucGET(Get_ReadOnly)
261*f4a2713aSLionel SambucSET(Set_ReadOnly)
262*f4a2713aSLionel SambucGET(GetSet_Nonatomic_ReadOnly)
263*f4a2713aSLionel SambucSET(GetSet_Nonatomic_ReadOnly)
264*f4a2713aSLionel SambucGET(Get_Nonatomic_ReadOnly)
265*f4a2713aSLionel SambucSET(Set_Nonatomic_ReadOnly)
266*f4a2713aSLionel Sambuc
267*f4a2713aSLionel SambucGET(GetSet_ReadWriteInExt)
268*f4a2713aSLionel SambucSET(GetSet_ReadWriteInExt)
269*f4a2713aSLionel SambucGET(Get_ReadWriteInExt) // expected-warning {{writable atomic property 'Get_ReadWriteInExt' cannot pair a synthesized setter with a user defined getter}}
270*f4a2713aSLionel SambucSET(Set_ReadWriteInExt) // expected-warning {{writable atomic property 'Set_ReadWriteInExt' cannot pair a synthesized getter with a user defined setter}}
271*f4a2713aSLionel SambucGET(GetSet_Nonatomic_ReadWriteInExt)
272*f4a2713aSLionel SambucSET(GetSet_Nonatomic_ReadWriteInExt)
273*f4a2713aSLionel SambucGET(Get_Nonatomic_ReadWriteInExt)
274*f4a2713aSLionel SambucSET(Set_Nonatomic_ReadWriteInExt)
275*f4a2713aSLionel Sambuc
276*f4a2713aSLionel Sambuc
277*f4a2713aSLionel SambucGET(GetSet_LateSynthesize)
278*f4a2713aSLionel SambucSET(GetSet_LateSynthesize)
279*f4a2713aSLionel SambucGET(Get_LateSynthesize) // expected-warning {{writable atomic property 'Get_LateSynthesize' cannot pair a synthesized setter with a user defined getter}}
280*f4a2713aSLionel SambucSET(Set_LateSynthesize) // expected-warning {{writable atomic property 'Set_LateSynthesize' cannot pair a synthesized getter with a user defined setter}}
281*f4a2713aSLionel SambucGET(GetSet_Nonatomic_LateSynthesize)
282*f4a2713aSLionel SambucSET(GetSet_Nonatomic_LateSynthesize)
283*f4a2713aSLionel SambucGET(Get_Nonatomic_LateSynthesize)
284*f4a2713aSLionel SambucSET(Set_Nonatomic_LateSynthesize)
285*f4a2713aSLionel Sambuc
286*f4a2713aSLionel SambucGET(GetSet_ReadOnly_LateSynthesize)
287*f4a2713aSLionel SambucSET(GetSet_ReadOnly_LateSynthesize)
288*f4a2713aSLionel SambucGET(Get_ReadOnly_LateSynthesize)
289*f4a2713aSLionel SambucSET(Set_ReadOnly_LateSynthesize)
290*f4a2713aSLionel SambucGET(GetSet_Nonatomic_ReadOnly_LateSynthesize)
291*f4a2713aSLionel SambucSET(GetSet_Nonatomic_ReadOnly_LateSynthesize)
292*f4a2713aSLionel SambucGET(Get_Nonatomic_ReadOnly_LateSynthesize)
293*f4a2713aSLionel SambucSET(Set_Nonatomic_ReadOnly_LateSynthesize)
294*f4a2713aSLionel Sambuc
295*f4a2713aSLionel SambucGET(GetSet_ReadWriteInExt_LateSynthesize)
296*f4a2713aSLionel SambucSET(GetSet_ReadWriteInExt_LateSynthesize)
297*f4a2713aSLionel SambucGET(Get_ReadWriteInExt_LateSynthesize) // expected-warning {{writable atomic property 'Get_ReadWriteInExt_LateSynthesize' cannot pair a synthesized setter with a user defined getter}}
298*f4a2713aSLionel SambucSET(Set_ReadWriteInExt_LateSynthesize) // expected-warning {{writable atomic property 'Set_ReadWriteInExt_LateSynthesize' cannot pair a synthesized getter with a user defined setter}}
299*f4a2713aSLionel SambucGET(GetSet_Nonatomic_ReadWriteInExt_LateSynthesize)
300*f4a2713aSLionel SambucSET(GetSet_Nonatomic_ReadWriteInExt_LateSynthesize)
301*f4a2713aSLionel SambucGET(Get_Nonatomic_ReadWriteInExt_LateSynthesize)
302*f4a2713aSLionel SambucSET(Set_Nonatomic_ReadWriteInExt_LateSynthesize)
303*f4a2713aSLionel Sambuc
304*f4a2713aSLionel Sambuc
305*f4a2713aSLionel SambucGET(GetSet_NoSynthesize)
306*f4a2713aSLionel SambucSET(GetSet_NoSynthesize)
307*f4a2713aSLionel SambucGET(Get_NoSynthesize)
308*f4a2713aSLionel SambucSET(Set_NoSynthesize)
309*f4a2713aSLionel SambucGET(GetSet_Nonatomic_NoSynthesize)
310*f4a2713aSLionel SambucSET(GetSet_Nonatomic_NoSynthesize)
311*f4a2713aSLionel SambucGET(Get_Nonatomic_NoSynthesize)
312*f4a2713aSLionel SambucSET(Set_Nonatomic_NoSynthesize)
313*f4a2713aSLionel Sambuc
314*f4a2713aSLionel SambucGET(GetSet_ReadOnly_NoSynthesize)
315*f4a2713aSLionel SambucSET(GetSet_ReadOnly_NoSynthesize)
316*f4a2713aSLionel SambucGET(Get_ReadOnly_NoSynthesize)
317*f4a2713aSLionel SambucSET(Set_ReadOnly_NoSynthesize)
318*f4a2713aSLionel SambucGET(GetSet_Nonatomic_ReadOnly_NoSynthesize)
319*f4a2713aSLionel SambucSET(GetSet_Nonatomic_ReadOnly_NoSynthesize)
320*f4a2713aSLionel SambucGET(Get_Nonatomic_ReadOnly_NoSynthesize)
321*f4a2713aSLionel SambucSET(Set_Nonatomic_ReadOnly_NoSynthesize)
322*f4a2713aSLionel Sambuc
323*f4a2713aSLionel SambucGET(GetSet_ReadWriteInExt_NoSynthesize)
324*f4a2713aSLionel SambucSET(GetSet_ReadWriteInExt_NoSynthesize)
325*f4a2713aSLionel SambucGET(Get_ReadWriteInExt_NoSynthesize)
326*f4a2713aSLionel SambucSET(Set_ReadWriteInExt_NoSynthesize)
327*f4a2713aSLionel SambucGET(GetSet_Nonatomic_ReadWriteInExt_NoSynthesize)
328*f4a2713aSLionel SambucSET(GetSet_Nonatomic_ReadWriteInExt_NoSynthesize)
329*f4a2713aSLionel SambucGET(Get_Nonatomic_ReadWriteInExt_NoSynthesize)
330*f4a2713aSLionel SambucSET(Set_Nonatomic_ReadWriteInExt_NoSynthesize)
331*f4a2713aSLionel Sambuc
332*f4a2713aSLionel Sambuc
333*f4a2713aSLionel Sambuc// late synthesize - follows getter/setter implementations
334*f4a2713aSLionel Sambuc
335*f4a2713aSLionel Sambuc@synthesize GetSet_LateSynthesize, Get_LateSynthesize, Set_LateSynthesize, None_LateSynthesize, GetSet_Nonatomic_LateSynthesize, Get_Nonatomic_LateSynthesize, Set_Nonatomic_LateSynthesize, None_Nonatomic_LateSynthesize;
336*f4a2713aSLionel Sambuc@synthesize GetSet_ReadOnly_LateSynthesize, Get_ReadOnly_LateSynthesize, Set_ReadOnly_LateSynthesize, None_ReadOnly_LateSynthesize, GetSet_Nonatomic_ReadOnly_LateSynthesize, Get_Nonatomic_ReadOnly_LateSynthesize, Set_Nonatomic_ReadOnly_LateSynthesize, None_Nonatomic_ReadOnly_LateSynthesize;
337*f4a2713aSLionel Sambuc@synthesize GetSet_ReadWriteInExt_LateSynthesize, Get_ReadWriteInExt_LateSynthesize, Set_ReadWriteInExt_LateSynthesize, None_ReadWriteInExt_LateSynthesize, GetSet_Nonatomic_ReadWriteInExt_LateSynthesize, Get_Nonatomic_ReadWriteInExt_LateSynthesize, Set_Nonatomic_ReadWriteInExt_LateSynthesize, None_Nonatomic_ReadWriteInExt_LateSynthesize;
338*f4a2713aSLionel Sambuc
339*f4a2713aSLionel Sambuc// no synthesize - use dynamic instead
340*f4a2713aSLionel Sambuc
341*f4a2713aSLionel Sambuc@dynamic GetSet_NoSynthesize, Get_NoSynthesize, Set_NoSynthesize, None_NoSynthesize, GetSet_Nonatomic_NoSynthesize, Get_Nonatomic_NoSynthesize, Set_Nonatomic_NoSynthesize, None_Nonatomic_NoSynthesize;
342*f4a2713aSLionel Sambuc@dynamic GetSet_ReadOnly_NoSynthesize, Get_ReadOnly_NoSynthesize, Set_ReadOnly_NoSynthesize, None_ReadOnly_NoSynthesize, GetSet_Nonatomic_ReadOnly_NoSynthesize, Get_Nonatomic_ReadOnly_NoSynthesize, Set_Nonatomic_ReadOnly_NoSynthesize, None_Nonatomic_ReadOnly_NoSynthesize;
343*f4a2713aSLionel Sambuc@dynamic GetSet_ReadWriteInExt_NoSynthesize, Get_ReadWriteInExt_NoSynthesize, Set_ReadWriteInExt_NoSynthesize, None_ReadWriteInExt_NoSynthesize, GetSet_Nonatomic_ReadWriteInExt_NoSynthesize, Get_Nonatomic_ReadWriteInExt_NoSynthesize, Set_Nonatomic_ReadWriteInExt_NoSynthesize, None_Nonatomic_ReadWriteInExt_NoSynthesize;
344*f4a2713aSLionel Sambuc
345*f4a2713aSLionel Sambuc@end
346*f4a2713aSLionel Sambuc
347*f4a2713aSLionel Sambuc/*
348*f4a2713aSLionel Sambuc// the following method should cause a warning along the lines of
349*f4a2713aSLionel Sambuc// :warning: Atomic property 'x' cannot pair a synthesized setter/getter with a manually implemented setter/getter
350*f4a2713aSLionel Sambuc- (void) setX: (int) aValue
351*f4a2713aSLionel Sambuc{
352*f4a2713aSLionel Sambuc    x = aValue;
353*f4a2713aSLionel Sambuc}
354*f4a2713aSLionel Sambuc
355*f4a2713aSLionel Sambuc// no warning 'cause this is nonatomic
356*f4a2713aSLionel Sambuc- (void) setY: (int) aValue
357*f4a2713aSLionel Sambuc{
358*f4a2713aSLionel Sambuc    y = aValue;
359*f4a2713aSLionel Sambuc}
360*f4a2713aSLionel Sambuc
361*f4a2713aSLionel Sambuc// the following method should cause a warning along the lines of
362*f4a2713aSLionel Sambuc// :warning: Atomic property 'x' cannot pair a synthesized setter/getter with a manually implemented setter/getter
363*f4a2713aSLionel Sambuc- (int) j
364*f4a2713aSLionel Sambuc{
365*f4a2713aSLionel Sambuc    return j;
366*f4a2713aSLionel Sambuc}
367*f4a2713aSLionel Sambuc
368*f4a2713aSLionel Sambuc// no warning 'cause this is nonatomic
369*f4a2713aSLionel Sambuc- (int) k
370*f4a2713aSLionel Sambuc{
371*f4a2713aSLionel Sambuc    return k;
372*f4a2713aSLionel Sambuc}
373*f4a2713aSLionel Sambuc@end
374*f4a2713aSLionel Sambuc*/
375*f4a2713aSLionel Sambucint main (int argc, const char * argv[]) {
376*f4a2713aSLionel Sambuc    return 0;
377*f4a2713aSLionel Sambuc}
378