Douglas Gregor | 710e0c4 | 2011-09-23 20:28:32 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin9.0.0 -fsyntax-only -verify %s |
Fariborz Jahanian | d672436 | 2012-04-23 20:30:52 +0000 | [diff] [blame] | 2 | |
| 3 | @protocol P |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 4 | - (void)proto_method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))); // expected-note 2 {{'proto_method' has been explicitly marked deprecated here}} |
Fariborz Jahanian | d672436 | 2012-04-23 20:30:52 +0000 | [diff] [blame] | 5 | @end |
| 6 | |
| 7 | @interface A <P> |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 8 | - (void)method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))); // expected-note {{'method' has been explicitly marked deprecated here}} |
Douglas Gregor | f4d918f | 2013-01-15 22:43:08 +0000 | [diff] [blame] | 9 | |
| 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 Gregor | 72daa3f | 2013-01-16 00:54:48 +0000 | [diff] [blame] | 14 | - (void)overridden5 __attribute__((availability(macosx,unavailable))); |
| 15 | - (void)overridden6 __attribute__((availability(macosx,introduced=10.3))); // expected-note{{overridden method is here}} |
Douglas Gregor | c193dd8 | 2011-09-23 20:23:42 +0000 | [diff] [blame] | 16 | @end |
| 17 | |
Fariborz Jahanian | 1ea6744 | 2012-06-05 21:14:46 +0000 | [diff] [blame] | 18 | // rdar://11475360 |
Douglas Gregor | c193dd8 | 2011-09-23 20:23:42 +0000 | [diff] [blame] | 19 | @interface B : A |
Ted Kremenek | cb34439 | 2013-04-06 00:34:27 +0000 | [diff] [blame] | 20 | - (void)method; // NOTE: we expect 'method' to *not* inherit availability. |
Douglas Gregor | f4d918f | 2013-01-15 22:43:08 +0000 | [diff] [blame] | 21 | - (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 Gregor | 72daa3f | 2013-01-16 00:54:48 +0000 | [diff] [blame] | 25 | - (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 Gregor | c193dd8 | 2011-09-23 20:23:42 +0000 | [diff] [blame] | 27 | @end |
| 28 | |
| 29 | void f(A *a, B *b) { |
Fariborz Jahanian | faab561 | 2012-10-01 18:42:25 +0000 | [diff] [blame] | 30 | [a method]; // expected-warning{{'method' is deprecated: first deprecated in OS X 10.2}} |
Ted Kremenek | cb34439 | 2013-04-06 00:34:27 +0000 | [diff] [blame] | 31 | [b method]; // no-warning |
Fariborz Jahanian | faab561 | 2012-10-01 18:42:25 +0000 | [diff] [blame] | 32 | [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 Gregor | c193dd8 | 2011-09-23 20:23:42 +0000 | [diff] [blame] | 34 | } |
Ted Kremenek | 1db6d6b | 2013-04-08 23:39:32 +0000 | [diff] [blame] | 35 | |
| 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 Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 40 | - (void) method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))); // expected-note {{'method' has been explicitly marked deprecated here}} |
Ted Kremenek | 1db6d6b | 2013-04-08 23:39:32 +0000 | [diff] [blame] | 41 | @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 | |