• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// RUN: %clang_cc1 %s -fsyntax-only -verify
2
3@interface A {
4  int X __attribute__((deprecated));
5}
6+ (void)F __attribute__((deprecated));
7- (void)f __attribute__((deprecated));
8@end
9
10@implementation A
11+ (void)F __attribute__((deprecated))
12{	// expected-warning {{method attribute can only be specified on method declarations}}
13  [self F]; // no warning, since the caller is also deprecated.
14}
15
16- (void)g
17{
18  X++;        // expected-warning{{'X' is deprecated}}
19  self->X++;  // expected-warning{{'X' is deprecated}}
20  [self f]; // expected-warning{{'f' is deprecated}}
21}
22
23- (void)f
24{
25  [self f]; // no warning, the caller is deprecated in its interface.
26}
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
45- (void)p __attribute__((deprecated));
46@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{
56  [a f];
57}
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
70
71
72@interface Bar
73
74@property (assign, setter = MySetter:) int FooBar __attribute__ ((deprecated));
75- (void) MySetter : (int) value;
76@end
77
78int t5() {
79  Bar *f;
80  f.FooBar = 1;	   // expected-warning {{warning: 'FooBar' is deprecated}}
81  return f.FooBar; // expected-warning {{warning: 'FooBar' is deprecated}}
82}
83
84
85__attribute ((deprecated))
86@interface DEPRECATED {
87  @public int ivar;
88}
89- (int) instancemethod;
90@property  int prop;
91@end
92
93@interface DEPRECATED (Category) // expected-warning {{warning: 'DEPRECATED' is deprecated}}
94@end
95
96@interface NS : DEPRECATED  // expected-warning {{warning: 'DEPRECATED' is deprecated}}
97@end
98
99
100@interface Test2
101@property int test2 __attribute__((deprecated));
102@end
103
104void test(Test2 *foo) {
105  int x;
106  x = foo.test2; // expected-warning {{'test2' is deprecated}}
107  x = [foo test2]; // expected-warning {{'test2' is deprecated}}
108  foo.test2 = x; // expected-warning {{'test2' is deprecated}}
109  [foo setTest2: x]; // expected-warning {{'setTest2:' is deprecated}}
110}
111