1 // RUN: %clang_cc1 -fsyntax-only -triple thumbv6-apple-ios3.0 -verify -Wno-objc-root-class %s 2 // RUN: %clang_cc1 -x objective-c++ -fsyntax-only -triple thumbv6-apple-ios3.0 -verify -Wno-objc-root-class %s 3 // rdar://12324295 4 5 typedef signed char BOOL; 6 7 @protocol P 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}} 9 @end 10 11 @protocol P1<P> 12 - (void)setPtarget:(id)arg; 13 @end 14 15 16 @interface UITableViewCell<P1> 17 @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}} 18 @end 19 20 @interface PSTableCell : UITableViewCell 21 - (void)setTarget:(id)target; 22 @end 23 24 @interface UITableViewCell(UIDeprecated) 25 @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}} \ 26 // expected-note 4 {{property 'dep_target' is declared deprecated here}} \ 27 // expected-note 2 {{'setDep_target:' has been explicitly marked deprecated here}} 28 @end 29 30 @implementation PSTableCell 31 - (void)setTarget:(id)target {}; 32 - (void)setPtarget:(id)val {}; 33 - (void) Meth { 34 [self setTarget: (id)0]; // no-warning 35 [self setDep_target: [self dep_target]]; // expected-warning {{'dep_target' is deprecated: first deprecated in iOS 3.0}} \ 36 // expected-warning {{'setDep_target:' is deprecated: first deprecated in iOS 3.0}} 37 38 [self setPtarget: (id)0]; // no-warning 39 } 40 @end 41 42 @implementation UITableViewCell 43 @synthesize target; 44 @synthesize ptarget; 45 - (void)setPtarget:(id)val {}; 46 - (void)setTarget:(id)target {}; 47 - (void) Meth { 48 [self setTarget: (id)0]; // expected-warning {{'setTarget:' is deprecated: first deprecated in iOS 3.0}} 49 [self setDep_target: [self dep_target]]; // expected-warning {{'dep_target' is deprecated: first deprecated in iOS 3.0}} \ 50 // expected-warning {{'setDep_target:' is deprecated: first deprecated in iOS 3.0}} 51 52 [self setPtarget: (id)0]; // no-warning 53 } 54 @end 55 56 57 @interface CustomAccessorNames 58 @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}} 59 60 @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}} 61 @end 62 63 void testCustomAccessorNames(CustomAccessorNames *obj) { 64 if ([obj isEnabled]) // expected-warning {{'isEnabled' is deprecated: first deprecated in iOS 3.0}} 65 [obj setNewDelegate:0]; // expected-warning {{'setNewDelegate:' is deprecated: first deprecated in iOS 3.0}} 66 } 67 68 69 @interface ProtocolInCategory 70 @end 71 72 @interface ProtocolInCategory (TheCategory) <P1> 73 - (id)ptarget; 74 @end 75 76 id useDeprecatedProperty(ProtocolInCategory *obj, id<P> obj2, int flag) { 77 if (flag) 78 return [obj ptarget]; // no-warning 79 return [obj2 ptarget]; // expected-warning {{'ptarget' is deprecated: first deprecated in iOS 3.0}} 80 } 81 82 // rdar://15951801 83 @interface Foo 84 { 85 int _x; 86 } 87 @property(nonatomic,readonly) int x; 88 - (void)setX:(int)x __attribute__ ((deprecated)); // expected-note 2 {{'setX:' has been explicitly marked deprecated here}} 89 - (int)x __attribute__ ((unavailable)); // expected-note {{'x' has been explicitly marked unavailable here}} 90 @end 91 92 @implementation Foo 93 - (void)setX:(int)x { 94 _x = x; 95 } 96 - (int)x { 97 return _x; 98 } 99 @end 100 101 void testUserAccessorAttributes(Foo *foo) { 102 [foo setX:5678]; // expected-warning {{'setX:' is deprecated}} 103 foo.x = foo.x; // expected-error {{property access is using 'x' method which is unavailable}} \ 104 // expected-warning {{property access is using 'setX:' method which is deprecated}} 105 } 106