1 // RUN: %clang_cc1 -fsyntax-only -triple thumbv6-apple-ios3.0 -verify -Wno-objc-root-class %s
2 // RUN: %clang_cc1 -D WARN_PARTIAL -Wpartial-availability -fsyntax-only -triple thumbv6-apple-ios3.0 -verify -Wno-objc-root-class %s
3 // RUN: %clang_cc1 -x objective-c++ -fsyntax-only -triple thumbv6-apple-ios3.0 -verify -Wno-objc-root-class %s
5 typedef signed char BOOL;
8 @property(nonatomic,assign) id ptarget __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{property 'ptarget' is declared deprecated here}} expected-note {{'ptarget' has been explicitly marked deprecated here}}
10 #if defined(WARN_PARTIAL)
11 // expected-note@+2 {{'partialPtarget' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0}}
13 @property(nonatomic,assign) id partialPtarget __attribute__((availability(ios,introduced=5.0)));
17 - (void)setPtarget:(id)arg;
18 - (void)setPartialPtarget:(id)arg;
22 @interface UITableViewCell<P1>
23 @property(nonatomic,assign) id target __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{property 'target' is declared deprecated here}} expected-note {{'setTarget:' has been explicitly marked deprecated here}}
25 #if defined(WARN_PARTIAL)
26 // expected-note@+2 {{'setPartialTarget:' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0}}
28 @property(nonatomic,assign) id partialTarget __attribute__((availability(ios,introduced=5.0)));
31 @interface PSTableCell : UITableViewCell
32 - (void)setTarget:(id)target;
33 - (void)setPartialTarget:(id)target;
36 @interface UITableViewCell(UIDeprecated)
37 @property(nonatomic,assign) id dep_target __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note 2 {{'dep_target' has been explicitly marked deprecated here}} \
38 // expected-note 4 {{property 'dep_target' is declared deprecated here}} \
39 // expected-note 2 {{'setDep_target:' has been explicitly marked deprecated here}}
41 #if defined(WARN_PARTIAL)
42 // expected-note@+3 2 {{'partial_dep_target' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0}}
43 // expected-note@+2 2 {{'setPartial_dep_target:' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0}}
45 @property(nonatomic,assign) id partial_dep_target __attribute__((availability(ios,introduced=5.0)));
48 @implementation PSTableCell
49 - (void)setTarget:(id)target {};
50 - (void)setPartialTarget:(id)target {};
51 - (void)setPtarget:(id)val {};
53 [self setTarget: (id)0]; // no-warning
54 [self setDep_target: [self dep_target]]; // expected-warning {{'dep_target' is deprecated: first deprecated in iOS 3.0}} \
55 // expected-warning {{'setDep_target:' is deprecated: first deprecated in iOS 3.0}}
57 [self setPtarget: (id)0]; // no-warning
58 [self setPartialTarget: (id)0]; // no-warning
59 #if defined(WARN_PARTIAL)
60 // expected-warning@+2 {{'partial_dep_target' is only available on iOS 5.0 or newer}} expected-warning@+2 {{'setPartial_dep_target:' is only available on iOS 5.0 or newer}} expected-note@+2 {{enclose 'partial_dep_target' in an @available check to silence this warning}} expected-note@+2 {{enclose 'setPartial_dep_target:' in an @available check to silence this warning}}
62 [self setPartial_dep_target: [self partial_dep_target]];
64 [self setPartialPtarget: (id)0]; // no-warning
68 @implementation UITableViewCell
70 @synthesize partialTarget;
72 @synthesize partialPtarget;
73 - (void)setPtarget:(id)val {};
74 - (void)setPartialPtarget:(id)val {};
75 - (void)setTarget:(id)target {};
76 - (void)setPartialTarget:(id)target {};
78 [self setTarget: (id)0]; // expected-warning {{'setTarget:' is deprecated: first deprecated in iOS 3.0}}
79 [self setDep_target: [self dep_target]]; // expected-warning {{'dep_target' is deprecated: first deprecated in iOS 3.0}} \
80 // expected-warning {{'setDep_target:' is deprecated: first deprecated in iOS 3.0}}
82 [self setPtarget: (id)0]; // no-warning
84 #if defined(WARN_PARTIAL)
85 // expected-warning@+2 {{'setPartialTarget:' is only available on iOS 5.0 or newer}} expected-note@+2 {{enclose 'setPartialTarget:' in an @available check to silence this warning}}
87 [self setPartialTarget: (id)0];
88 #if defined(WARN_PARTIAL)
89 // expected-warning@+2 {{'partial_dep_target' is only available on iOS 5.0 or newer}} expected-warning@+2 {{'setPartial_dep_target:' is only available on iOS 5.0 or newer}} expected-note@+2 {{enclose 'partial_dep_target' in an @available check to silence this warning}} expected-note@+2 {{enclose 'setPartial_dep_target:' in an @available check to silence this warning}}
91 [self setPartial_dep_target: [self partial_dep_target]];
92 [self setPartialPtarget: (id)0]; // no-warning
97 @interface CustomAccessorNames
98 @property(getter=isEnabled,assign) BOOL enabled __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{'isEnabled' has been explicitly marked deprecated here}} expected-note {{property 'enabled' is declared deprecated here}}
100 @property(setter=setNewDelegate:,assign) id delegate __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{'setNewDelegate:' has been explicitly marked deprecated here}} expected-note {{property 'delegate' is declared deprecated here}}
102 #if defined(WARN_PARTIAL)
103 // expected-note@+2 {{'partialIsEnabled' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0}}
105 @property(getter=partialIsEnabled,assign) BOOL partialEnabled __attribute__((availability(ios,introduced=5.0)));
107 #if defined(WARN_PARTIAL)
108 // expected-note@+2 {{'partialSetNewDelegate:' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0}}
110 @property(setter=partialSetNewDelegate:,assign) id partialDelegate __attribute__((availability(ios,introduced=5.0)));
113 void testCustomAccessorNames(CustomAccessorNames *obj) {
114 if ([obj isEnabled]) // expected-warning {{'isEnabled' is deprecated: first deprecated in iOS 3.0}}
115 [obj setNewDelegate:0]; // expected-warning {{'setNewDelegate:' is deprecated: first deprecated in iOS 3.0}}
117 #if defined(WARN_PARTIAL)
118 // expected-warning@+2 {{'partialIsEnabled' is only available on iOS 5.0 or newer}} expected-warning@+3 {{'partialSetNewDelegate:' is only available on iOS 5.0 or newer}} expected-note@+2 {{enclose 'partialIsEnabled' in an @available check to silence this warning}} expected-note@+3 {{enclose 'partialSetNewDelegate:' in an @available check to silence this warning}}
120 if ([obj partialIsEnabled])
121 [obj partialSetNewDelegate:0];
125 @interface ProtocolInCategory
128 @interface ProtocolInCategory (TheCategory) <P1>
130 - (id)partialPtarget;
133 id useDeprecatedProperty(ProtocolInCategory *obj, id<P> obj2, int flag) {
135 return [obj ptarget]; // no-warning
136 return [obj2 ptarget]; // expected-warning {{'ptarget' is deprecated: first deprecated in iOS 3.0}}
139 return [obj partialPtarget]; // no-warning
140 #if defined(WARN_PARTIAL)
141 // expected-warning@+2 {{'partialPtarget' is only available on iOS 5.0 or newer}} expected-note@+2 {{enclose 'partialPtarget' in an @available check to silence this warning}}
143 return [obj2 partialPtarget];
150 @property(nonatomic,readonly) int x;
151 - (void)setX:(int)x __attribute__ ((deprecated)); // expected-note 2 {{'setX:' has been explicitly marked deprecated here}}
152 - (int)x __attribute__ ((unavailable)); // expected-note {{'x' has been explicitly marked unavailable here}}
156 - (void)setX:(int)x {
164 void testUserAccessorAttributes(Foo *foo) {
165 [foo setX:5678]; // expected-warning {{'setX:' is deprecated}}
166 foo.x = foo.x; // expected-error {{property access is using 'x' method which is unavailable}} \
167 // expected-warning {{property access is using 'setX:' method which is deprecated}}
170 // test implicit property does not emit duplicated warning.
172 - (int)size __attribute__((availability(ios,deprecated=3.0))); // expected-note {{'size' has been explicitly marked deprecated here}}
173 - (void)setSize: (int)x __attribute__((availability(ios,deprecated=2.0))); // expected-note {{'setSize:' has been explicitly marked deprecated here}}
176 void testImplicitProperty(id<Foo> object) {
177 object.size = object.size; // expected-warning {{'size' is deprecated: first deprecated in iOS 3.0}} \
178 // expected-warning {{'setSize:' is deprecated: first deprecated in iOS 2.0}}