xref: /llvm-project/clang/test/SemaObjC/warn-protocol-method-deprecated.m (revision 0f1c1be1968076d6f96f8a7bcc4a15cf195ecd97)
1// RUN: %clang_cc1 -fsyntax-only -Wno-objc-root-class -verify %s
2
3@protocol TestProtocol
4- (void)newProtocolMethod;
5- (void)deprecatedProtocolMethod __attribute__((deprecated)); // expected-note 2 {{'deprecatedProtocolMethod' has been explicitly marked deprecated here}}
6@end
7
8@interface NSObject @end
9
10@interface TestClass : NSObject <TestProtocol>
11
12- (void)newInstanceMethod;
13- (void)deprecatedInstanceMethod __attribute__((deprecated)); // expected-note {{'deprecatedInstanceMethod' has been explicitly marked deprecated here}}
14
15@end
16
17int main(int argc, const char * argv[])
18{
19
20    TestClass *testObj = (TestClass*)0;
21    [testObj newInstanceMethod];
22    [testObj deprecatedInstanceMethod]; // expected-warning {{'deprecatedInstanceMethod' is deprecated}}
23
24    [testObj newProtocolMethod];
25    [testObj deprecatedProtocolMethod]; // expected-warning {{'deprecatedProtocolMethod' is deprecated}}
26
27    id <TestProtocol> testProto = testObj;
28    [testProto newProtocolMethod];
29    [testProto deprecatedProtocolMethod]; // expected-warning {{'deprecatedProtocolMethod' is deprecated}}
30    return 0;
31}
32