blob: 7990b1202e8ffac705111e991fe8b6363e2df274 [file] [log] [blame]
Douglas Gregor710e0c42011-09-23 20:28:32 +00001// RUN: %clang_cc1 -triple x86_64-apple-darwin9.0.0 -fsyntax-only -verify %s
Fariborz Jahaniand6724362012-04-23 20:30:52 +00002
3@protocol P
Stephen Hines651f13c2014-04-23 16:59:28 -07004- (void)proto_method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))); // expected-note 2 {{'proto_method' has been explicitly marked deprecated here}}
Fariborz Jahaniand6724362012-04-23 20:30:52 +00005@end
6
7@interface A <P>
Stephen Hines651f13c2014-04-23 16:59:28 -07008- (void)method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))); // expected-note {{'method' has been explicitly marked deprecated here}}
Douglas Gregorf4d918f2013-01-15 22:43:08 +00009
10- (void)overridden __attribute__((availability(macosx,introduced=10.3))); // expected-note{{overridden method is here}}
11- (void)overridden2 __attribute__((availability(macosx,introduced=10.3)));
12- (void)overridden3 __attribute__((availability(macosx,deprecated=10.3)));
13- (void)overridden4 __attribute__((availability(macosx,deprecated=10.3))); // expected-note{{overridden method is here}}
Douglas Gregor72daa3f2013-01-16 00:54:48 +000014- (void)overridden5 __attribute__((availability(macosx,unavailable)));
15- (void)overridden6 __attribute__((availability(macosx,introduced=10.3))); // expected-note{{overridden method is here}}
Douglas Gregorc193dd82011-09-23 20:23:42 +000016@end
17
Fariborz Jahanian1ea67442012-06-05 21:14:46 +000018// rdar://11475360
Douglas Gregorc193dd82011-09-23 20:23:42 +000019@interface B : A
Ted Kremenekcb344392013-04-06 00:34:27 +000020- (void)method; // NOTE: we expect 'method' to *not* inherit availability.
Douglas Gregorf4d918f2013-01-15 22:43:08 +000021- (void)overridden __attribute__((availability(macosx,introduced=10.4))); // expected-warning{{overriding method introduced after overridden method on OS X (10.4 vs. 10.3)}}
22- (void)overridden2 __attribute__((availability(macosx,introduced=10.2)));
23- (void)overridden3 __attribute__((availability(macosx,deprecated=10.4)));
24- (void)overridden4 __attribute__((availability(macosx,deprecated=10.2))); // expected-warning{{overriding method deprecated before overridden method on OS X (10.3 vs. 10.2)}}
Douglas Gregor72daa3f2013-01-16 00:54:48 +000025- (void)overridden5 __attribute__((availability(macosx,introduced=10.3)));
26- (void)overridden6 __attribute__((availability(macosx,unavailable))); // expected-warning{{overriding method cannot be unavailable on OS X when its overridden method is available}}
Douglas Gregorc193dd82011-09-23 20:23:42 +000027@end
28
29void f(A *a, B *b) {
Fariborz Jahanianfaab5612012-10-01 18:42:25 +000030 [a method]; // expected-warning{{'method' is deprecated: first deprecated in OS X 10.2}}
Ted Kremenekcb344392013-04-06 00:34:27 +000031 [b method]; // no-warning
Fariborz Jahanianfaab5612012-10-01 18:42:25 +000032 [a proto_method]; // expected-warning{{'proto_method' is deprecated: first deprecated in OS X 10.2}}
33 [b proto_method]; // expected-warning{{'proto_method' is deprecated: first deprecated in OS X 10.2}}
Douglas Gregorc193dd82011-09-23 20:23:42 +000034}
Ted Kremenek1db6d6b2013-04-08 23:39:32 +000035
36// Test case for <rdar://problem/11627873>. Warn about
37// using a deprecated method when that method is re-implemented in a
38// subclass where the redeclared method is not deprecated.
39@interface C
Stephen Hines651f13c2014-04-23 16:59:28 -070040- (void) method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))); // expected-note {{'method' has been explicitly marked deprecated here}}
Ted Kremenek1db6d6b2013-04-08 23:39:32 +000041@end
42
43@interface D : C
44- (void) method;
45@end
46
47@interface E : D
48- (void) method;
49@end
50
51@implementation D
52- (void) method {
53 [super method]; // expected-warning {{'method' is deprecated: first deprecated in OS X 10.2}}
54}
55@end
56
57@implementation E
58- (void) method {
59 [super method]; // no-warning
60}
61@end
62