]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/SemaObjC/default-synthesize.m
Update clang to r108428.
[FreeBSD/FreeBSD.git] / test / SemaObjC / default-synthesize.m
1 // RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi2 -verify %s
2
3 @interface NSString @end
4
5 @interface NSObject @end
6
7 @interface SynthItAll
8 @property int howMany;
9 @property (retain) NSString* what;
10 @end
11
12 @implementation SynthItAll
13 //@synthesize howMany, what;
14 @end
15
16
17 @interface SynthSetter : NSObject
18 @property (nonatomic) int howMany;  // REM: nonatomic to avoid warnings about only implementing one of the pair
19 @property (nonatomic, retain) NSString* what;
20 @end
21
22 @implementation SynthSetter
23 //@synthesize howMany, what;
24
25 - (int) howMany {
26     return self.howMany;
27 }
28 // - (void) setHowMany: (int) value
29
30 - (NSString*) what {
31     return self.what;
32 }
33 // - (void) setWhat: (NSString*) value    
34 @end
35
36
37 @interface SynthGetter : NSObject
38 @property (nonatomic) int howMany;  // REM: nonatomic to avoid warnings about only implementing one of the pair
39 @property (nonatomic, retain) NSString* what;
40 @end
41
42 @implementation SynthGetter
43 //@synthesize howMany, what;
44
45 // - (int) howMany
46 - (void) setHowMany: (int) value {
47     self.howMany = value;
48 }
49
50 // - (NSString*) what
51 - (void) setWhat: (NSString*) value {
52     if (self.what != value) {
53     }
54 }
55 @end
56
57
58 @interface SynthNone : NSObject
59 @property int howMany;
60 @property (retain) NSString* what;
61 @end
62
63 @implementation SynthNone
64 //@synthesize howMany, what;  // REM: Redundant anyway
65
66 - (int) howMany {
67     return self.howMany;
68 }
69 - (void) setHowMany: (int) value {
70     self.howMany = value;
71 }
72
73 - (NSString*) what {
74     return self.what;
75 }
76 - (void) setWhat: (NSString*) value {
77     if (self.what != value) {
78     }
79 }
80 @end
81
82 @protocol TopProtocol
83   @property (readonly) id myString;
84 @end
85
86 @interface TopClass <TopProtocol> 
87 {
88   id myString; 
89 }
90 @end
91
92 @interface SubClass : TopClass <TopProtocol> 
93 @end
94
95 @implementation SubClass @end 
96
97 // rdar: // 7920807
98 @interface C @end
99 @interface C (Category)
100 @property int p; // expected-warning {{property 'p' requires method 'p' to be defined }} \
101                  // expected-warning {{property 'p' requires method 'setP:' to be defined}}
102 @end
103 @implementation C (Category) // expected-note 2 {{implementation is here}}
104 @end
105
106 // Don't complain if a property is already @synthesized by usr.
107 @interface D
108 {
109 }
110 @property int PROP;
111 @end
112
113 @implementation D
114 - (int) Meth { return self.PROP; }
115 @synthesize PROP=IVAR;
116 @end
117