| Douglas Gregor | 83dea55 | 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 | 08a1eb7 | 2012-04-23 20:30:52 +0000 | [diff] [blame] | 2 | |
| 3 | @protocol P |
| Ted Kremenek | b79ee57 | 2013-12-18 23:30:06 +0000 | [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 | 08a1eb7 | 2012-04-23 20:30:52 +0000 | [diff] [blame] | 5 | @end |
| 6 | |
| 7 | @interface A <P> |
| Ted Kremenek | b79ee57 | 2013-12-18 23:30:06 +0000 | [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 | 66a8ca0 | 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 | 43dc0c7 | 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 | b1fa148 | 2011-09-23 20:23:42 +0000 | [diff] [blame] | 16 | @end |
| 17 | |
| Fariborz Jahanian | 3da28f8 | 2012-06-05 21:14:46 +0000 | [diff] [blame] | 18 | // rdar://11475360 |
| Douglas Gregor | b1fa148 | 2011-09-23 20:23:42 +0000 | [diff] [blame] | 19 | @interface B : A |
| Ted Kremenek | b544572 | 2013-04-06 00:34:27 +0000 | [diff] [blame] | 20 | - (void)method; // NOTE: we expect 'method' to *not* inherit availability. |
| Douglas Gregor | 66a8ca0 | 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 | 43dc0c7 | 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 | b1fa148 | 2011-09-23 20:23:42 +0000 | [diff] [blame] | 27 | @end |
| 28 | |
| 29 | void f(A *a, B *b) { |
| Fariborz Jahanian | c491c3f | 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 | b544572 | 2013-04-06 00:34:27 +0000 | [diff] [blame] | 31 | [b method]; // no-warning |
| Fariborz Jahanian | c491c3f | 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 | b1fa148 | 2011-09-23 20:23:42 +0000 | [diff] [blame] | 34 | } |
| Ted Kremenek | c20bb32 | 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 |
| Ted Kremenek | b79ee57 | 2013-12-18 23:30:06 +0000 | [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 | c20bb32 | 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 | |
| Fariborz Jahanian | 38c53fb | 2014-08-21 17:06:57 +0000 | [diff] [blame] | 63 | // rdar://18059669 |
| 64 | @class NSMutableArray; |
| 65 | |
| 66 | @interface NSDictionary |
| 67 | + (instancetype)dictionaryWithObjectsAndKeys:(id)firstObject, ... __attribute__((sentinel(0,1))); |
| 68 | @end |
| 69 | |
| 70 | @class NSString; |
| 71 | |
| 72 | extern NSString *NSNibTopLevelObjects __attribute__((availability(macosx,introduced=10.0 ,deprecated=10.8,message="" ))); |
| 73 | id NSNibOwner, topNibObjects; |
| 74 | |
| 75 | @interface AppDelegate (SIEImport) // expected-error {{cannot find interface declaration for 'AppDelegate'}} |
| 76 | |
| 77 | -(void)__attribute__((ibaction))importFromSIE:(id)sender; |
| 78 | |
| 79 | @end |
| 80 | |
| 81 | @implementation AppDelegate (SIEImport) // expected-error {{cannot find interface declaration for 'AppDelegate'}} |
| 82 | |
| 83 | -(void)__attribute__((ibaction))importFromSIE:(id)sender { |
| 84 | |
| 85 | NSMutableArray *topNibObjects; |
| 86 | NSDictionary *nibLoadDict = [NSDictionary dictionaryWithObjectsAndKeys:self, NSNibOwner, topNibObjects, NSNibTopLevelObjects, ((void *)0)]; |
| 87 | } |
| 88 | |
| 89 | @end |