Clang Project

clang_source_code/test/SemaObjC/warn-deprecated-implementations.m
1// RUN: %clang_cc1 -triple=x86_64-apple-macos10.10 -fsyntax-only -Wdeprecated-implementations -verify -Wno-objc-root-class %s
2// rdar://8973810
3// rdar://12717705
4
5@protocol P
6- (void) D __attribute__((deprecated)); // expected-note {{method 'D' declared here}}
7
8- (void) unavailable __attribute__((__unavailable__)); // expected-note {{method 'unavailable' declared here}}
9@end
10
11@interface A <P>
12+ (void)F __attribute__((deprecated));
13@end
14
15@interface A()
16- (void) E __attribute__((deprecated));
17@end
18
19@implementation A
20+ (void)F { } // No warning, implementing its own deprecated method
21- (void) D {} //  expected-warning {{implementing deprecated method}}
22- (void) E {} // No warning, implementing deprecated method in its class extension.
23
24- (void) unavailable { } // expected-warning {{implementing unavailable metho}}
25@end
26
27@interface A(CAT)
28- (void) G __attribute__((deprecated)); 
29@end
30
31@implementation A(CAT)
32- (void) G {}  // No warning, implementing its own deprecated method
33@end
34
35__attribute__((deprecated)) // expected-note {{'CL' has been explicitly marked deprecated here}}
36@interface CL // expected-note 2 {{class declared here}} 
37@end
38
39@implementation CL // expected-warning {{implementing deprecated class}}
40@end
41
42@implementation CL (SomeCategory) // expected-warning {{implementing deprecated category}}
43@end
44
45@interface CL_SUB : CL // expected-warning {{'CL' is deprecated}}
46@end
47
48@interface BASE
49- (void) B __attribute__((deprecated)); // expected-note {{method 'B' declared here}}
50
51+ (void) unavailable __attribute__((availability(macos, unavailable))); // expected-note {{method 'unavailable' declared here}}
52@end
53
54@interface SUB : BASE
55@end
56
57@implementation SUB
58- (void) B {} // expected-warning {{implementing deprecated method}}
59+ (void) unavailable { } // expected-warning {{implementing unavailable method}}
60@end
61
62@interface Test
63@end
64
65@interface Test()
66- (id)initSpecialInPrivateHeader __attribute__((deprecated));
67@end
68
69@implementation Test
70- (id)initSpecialInPrivateHeader {
71  return (void *)0;
72}
73@end
74
75__attribute__((deprecated))
76@interface Test(DeprecatedCategory) // expected-note {{category declared here}}
77@end
78
79@implementation Test(DeprecatedCategory) // expected-warning {{implementing deprecated category}}
80@end
81