Fix the clang-wpa example.
[clang.git] / test / SemaObjC / default-synthesize.m
blob33e3bd6f346458a3295052c4dd413ac1cc354d48
1 // RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi -fobjc-default-synthesize-properties -verify %s
3 @interface NSString @end
5 @interface NSObject @end
7 @interface SynthItAll
8 @property int howMany;
9 @property (retain) NSString* what;
10 @end
12 @implementation SynthItAll
13 //@synthesize howMany, what;
14 @end
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
22 @implementation SynthSetter
23 //@synthesize howMany, what;
25 - (int) howMany {
26     return self.howMany;
28 // - (void) setHowMany: (int) value
30 - (NSString*) what {
31     return self.what;
33 // - (void) setWhat: (NSString*) value    
34 @end
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
42 @implementation SynthGetter
43 //@synthesize howMany, what;
45 // - (int) howMany
46 - (void) setHowMany: (int) value {
47     self.howMany = value;
50 // - (NSString*) what
51 - (void) setWhat: (NSString*) value {
52     if (self.what != value) {
53     }
55 @end
58 @interface SynthNone : NSObject
59 @property int howMany;
60 @property (retain) NSString* what;
61 @end
63 @implementation SynthNone
64 //@synthesize howMany, what;  // REM: Redundant anyway
66 - (int) howMany {
67     return self.howMany;
69 - (void) setHowMany: (int) value {
70     self.howMany = value;
73 - (NSString*) what {
74     return self.what;
76 - (void) setWhat: (NSString*) value {
77     if (self.what != value) {
78     }
80 @end
82 @protocol TopProtocol
83   @property (readonly) id myString;
84 @end
86 @interface TopClass <TopProtocol> 
88   id myString; 
90 @end
92 @interface SubClass : TopClass <TopProtocol> 
93 @end
95 @implementation SubClass @end 
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
106 // Don't complain if a property is already @synthesized by usr.
107 @interface D
110 @property int PROP;
111 @end
113 @implementation D
114 - (int) Meth { return self.PROP; }
115 @synthesize PROP=IVAR;
116 @end