blob: 260462abc0b8719625d1d823d20e8c375ebd261e [file] [log] [blame]
Patrick Beardb2f68202012-04-06 18:12:22 +00001// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
Anders Carlsson59843ad2009-02-14 19:08:58 +00002
Chris Lattner553905d2009-02-16 17:19:12 +00003@interface A {
Fariborz Jahanian350e9562012-05-27 16:59:48 +00004 int X __attribute__((deprecated)); // expected-note 2 {{declared here}}
Chris Lattner553905d2009-02-16 17:19:12 +00005}
Fariborz Jahanian350e9562012-05-27 16:59:48 +00006+ (void)F __attribute__((deprecated)); // expected-note 2 {{declared here}}
7- (void)f __attribute__((deprecated)); // expected-note 4 {{declared here}}
Anders Carlsson59843ad2009-02-14 19:08:58 +00008@end
9
10@implementation A
11+ (void)F __attribute__((deprecated))
Fariborz Jahanian7fda4002011-10-22 01:21:15 +000012{
Chris Lattnerb254ca02009-02-16 17:08:46 +000013 [self F]; // no warning, since the caller is also deprecated.
Anders Carlsson59843ad2009-02-14 19:08:58 +000014}
15
16- (void)g
17{
Chris Lattner553905d2009-02-16 17:19:12 +000018 X++; // expected-warning{{'X' is deprecated}}
19 self->X++; // expected-warning{{'X' is deprecated}}
Anders Carlsson59843ad2009-02-14 19:08:58 +000020 [self f]; // expected-warning{{'f' is deprecated}}
21}
22
23- (void)f
24{
Chris Lattnerf15970c2009-02-16 19:35:30 +000025 [self f]; // no warning, the caller is deprecated in its interface.
Anders Carlsson59843ad2009-02-14 19:08:58 +000026}
27@end
28
29@interface B: A
30@end
31
32@implementation B
33+ (void)G
34{
35 [super F]; // expected-warning{{'F' is deprecated}}
36}
37
38- (void)g
39{
40 [super f]; // // expected-warning{{'f' is deprecated}}
41}
42@end
43
44@protocol P
Fariborz Jahanian350e9562012-05-27 16:59:48 +000045- (void)p __attribute__((deprecated)); // expected-note {{declared here}}
Anders Carlsson59843ad2009-02-14 19:08:58 +000046@end
47
48void t1(A *a)
49{
50 [A F]; // expected-warning{{'F' is deprecated}}
51 [a f]; // expected-warning{{'f' is deprecated}}
52}
53
54void t2(id a)
55{
Ted Kremenekd6cf9122012-02-10 02:45:47 +000056 [a f];
Anders Carlsson59843ad2009-02-14 19:08:58 +000057}
58
59void t3(A<P>* a)
60{
61 [a f]; // expected-warning{{'f' is deprecated}}
62 [a p]; // expected-warning{{'p' is deprecated}}
63}
64
65void t4(Class c)
66{
67 [c F];
68}
69
Chris Lattner7eba82e2009-02-16 18:35:08 +000070
71
72@interface Bar
73
Fariborz Jahanian350e9562012-05-27 16:59:48 +000074@property (assign, setter = MySetter:) int FooBar __attribute__ ((deprecated)); // expected-note 2 {{declared here}}
Chris Lattner7eba82e2009-02-16 18:35:08 +000075- (void) MySetter : (int) value;
76@end
77
78int t5() {
79 Bar *f;
Richard Trieu2fe9b7f2011-12-15 00:38:15 +000080 f.FooBar = 1; // expected-warning {{'FooBar' is deprecated}}
81 return f.FooBar; // expected-warning {{'FooBar' is deprecated}}
Chris Lattner7eba82e2009-02-16 18:35:08 +000082}
83
Chris Lattner16b34b42009-02-16 21:30:01 +000084
85__attribute ((deprecated))
Fariborz Jahanian350e9562012-05-27 16:59:48 +000086@interface DEPRECATED { // expected-note 2 {{declared here}}
Chris Lattner16b34b42009-02-16 21:30:01 +000087 @public int ivar;
Argyrios Kyrtzidis3a387442011-10-06 23:23:20 +000088 DEPRECATED *ivar2; // no warning.
Chris Lattner16b34b42009-02-16 21:30:01 +000089}
90- (int) instancemethod;
Argyrios Kyrtzidis3a387442011-10-06 23:23:20 +000091- (DEPRECATED *) meth; // no warning.
Chris Lattner16b34b42009-02-16 21:30:01 +000092@property int prop;
93@end
94
Argyrios Kyrtzidisc076e372011-10-06 23:23:27 +000095@interface DEPRECATED (Category) // no warning.
96- (DEPRECATED *) meth2; // no warning.
97@end
98
99@interface DEPRECATED (Category2) // no warning.
100@end
101
Richard Trieu2fe9b7f2011-12-15 00:38:15 +0000102@implementation DEPRECATED (Category2) // expected-warning {{'DEPRECATED' is deprecated}}
Chris Lattner16b34b42009-02-16 21:30:01 +0000103@end
Chris Lattnerc7984dd2009-02-16 21:33:09 +0000104
Richard Trieu2fe9b7f2011-12-15 00:38:15 +0000105@interface NS : DEPRECATED // expected-warning {{'DEPRECATED' is deprecated}}
Chris Lattnerc7984dd2009-02-16 21:33:09 +0000106@end
107
108
John McCall5de74d12010-11-10 07:01:40 +0000109@interface Test2
Fariborz Jahanian350e9562012-05-27 16:59:48 +0000110@property int test2 __attribute__((deprecated)); // expected-note 4 {{declared here}}
John McCall5de74d12010-11-10 07:01:40 +0000111@end
112
113void test(Test2 *foo) {
114 int x;
115 x = foo.test2; // expected-warning {{'test2' is deprecated}}
116 x = [foo test2]; // expected-warning {{'test2' is deprecated}}
117 foo.test2 = x; // expected-warning {{'test2' is deprecated}}
118 [foo setTest2: x]; // expected-warning {{'setTest2:' is deprecated}}
119}
Douglas Gregor13d05ac2011-09-23 19:19:41 +0000120
121__attribute__((deprecated))
122@interface A(Blah) // expected-error{{attributes may not be specified on a category}}
123@end
Eli Friedmanf66a0dd2012-08-08 23:04:35 +0000124
125
126typedef struct {
127 int x;
128} footype __attribute((deprecated)); // expected-note 2 {{declared here}}
129
130@interface foo {
131 footype a; // expected-warning {{'footype' is deprecated}}
132 footype b __attribute((deprecated));
133}
134@property footype c; // expected-warning {{'footype' is deprecated}}
135@property footype d __attribute((deprecated));
136@end