1// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s
3
4@interface A {
5  int X __attribute__((deprecated)); // expected-note 2 {{declared here}}
6}
7+ (void)F __attribute__((deprecated)); // expected-note 2 {{declared here}}
8- (void)f __attribute__((deprecated)); // expected-note 4 {{declared here}}
9@end
10
11@implementation A
12+ (void)F __attribute__((deprecated))
13{
14  [self F]; // no warning, since the caller is also deprecated.
15}
16
17- (void)g
18{
19  X++;        // expected-warning{{'X' is deprecated}}
20  self->X++;  // expected-warning{{'X' is deprecated}}
21  [self f]; // expected-warning{{'f' is deprecated}}
22}
23
24- (void)f
25{
26  [self f]; // no warning, the caller is deprecated in its interface.
27}
28@end
29
30@interface B: A
31@end
32
33@implementation B
34+ (void)G
35{
36  [super F]; // expected-warning{{'F' is deprecated}}
37}
38
39- (void)g
40{
41  [super f]; // // expected-warning{{'f' is deprecated}}
42}
43@end
44
45@protocol P
46- (void)p __attribute__((deprecated)); // expected-note {{declared here}}
47@end
48
49void t1(A *a)
50{
51  [A F]; // expected-warning{{'F' is deprecated}}
52  [a f]; // expected-warning{{'f' is deprecated}}
53}
54
55void t2(id a)
56{
57  [a f];
58}
59
60void t3(A<P>* a)
61{
62  [a f]; // expected-warning{{'f' is deprecated}}
63  [a p]; // expected-warning{{'p' is deprecated}}
64}
65
66void t4(Class c)
67{
68  [c F];
69}
70
71
72
73@interface Bar
74
75@property (assign, setter = MySetter:) int FooBar __attribute__ ((deprecated)); // expected-note 2 {{declared here}}
76- (void) MySetter : (int) value;
77@end
78
79int t5() {
80  Bar *f;
81  f.FooBar = 1;	   // expected-warning {{'FooBar' is deprecated}}
82  return f.FooBar; // expected-warning {{'FooBar' is deprecated}}
83}
84
85
86__attribute ((deprecated))
87@interface DEPRECATED { // expected-note 2 {{declared here}}
88  @public int ivar;
89  DEPRECATED *ivar2; // no warning.
90}
91- (int) instancemethod;
92- (DEPRECATED *) meth; // no warning.
93@property  int prop;
94@end
95
96@interface DEPRECATED (Category) // no warning.
97- (DEPRECATED *) meth2; // no warning.
98@end
99
100@interface DEPRECATED (Category2) // no warning.
101@end
102
103@implementation DEPRECATED (Category2) // expected-warning {{'DEPRECATED' is deprecated}}
104@end
105
106@interface NS : DEPRECATED  // expected-warning {{'DEPRECATED' is deprecated}}
107@end
108
109
110@interface Test2
111@property int test2 __attribute__((deprecated)); // expected-note 4 {{declared here}} \
112						 // expected-note 2 {{property 'test2' is declared deprecated here}}
113@end
114
115void test(Test2 *foo) {
116  int x;
117  x = foo.test2; // expected-warning {{'test2' is deprecated}}
118  x = [foo test2]; // expected-warning {{'test2' is deprecated}}
119  foo.test2 = x; // expected-warning {{'test2' is deprecated}}
120  [foo setTest2: x]; // expected-warning {{'setTest2:' is deprecated}}
121}
122
123__attribute__((deprecated))
124@interface A(Blah) // expected-error{{attributes may not be specified on a category}}
125@end
126
127
128typedef struct {
129	int x;
130} footype __attribute((deprecated)); // expected-note 2 {{declared here}}
131
132@interface foo {
133	footype a; // expected-warning {{'footype' is deprecated}}
134	footype b __attribute((deprecated));
135}
136@property footype c; // expected-warning {{'footype' is deprecated}}
137@property footype d __attribute((deprecated));
138@end
139
140// rdar://13569424
141@interface NewI
142+(void)cmeth;
143@end
144
145typedef NewI DeprI __attribute__((deprecated("blah"))); // expected-note 4 {{'DeprI' declared here}}
146
147@interface SI : DeprI // expected-warning {{'DeprI' is deprecated: blah}}
148-(DeprI*)meth; // expected-warning {{'DeprI' is deprecated: blah}}
149@end
150
151@implementation SI
152-(DeprI*)meth { // expected-warning {{'DeprI' is deprecated: blah}}
153  [DeprI cmeth]; // expected-warning {{'DeprI' is deprecated: blah}}
154  return 0;
155}
156@end
157