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