Fariborz Jahanian | dbc956d | 2014-10-02 16:39:45 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin9.0.0 -fsyntax-only -verify %s |
| 2 | // RUN: %clang_cc1 -x objective-c++ -std=c++11 -triple x86_64-apple-darwin9.0.0 -fsyntax-only -verify %s |
| 3 | // RUN: %clang_cc1 -x objective-c++ -std=c++03 -triple x86_64-apple-darwin9.0.0 -fsyntax-only -verify %s |
| 4 | // rdar://18490958 |
| 5 | |
Jordan Rose | 7e5de9c | 2015-07-16 22:30:10 +0000 | [diff] [blame] | 6 | #if !__has_feature(attribute_availability_with_version_underscores) |
| 7 | # error "missing feature" |
| 8 | #endif |
| 9 | |
Fariborz Jahanian | dbc956d | 2014-10-02 16:39:45 +0000 | [diff] [blame] | 10 | @protocol P |
| 11 | - (void)proto_method __attribute__((availability(macosx,introduced=10_1,deprecated=10_2))); // expected-note 2 {{'proto_method' has been explicitly marked deprecated here}} |
| 12 | @end |
| 13 | |
| 14 | @interface A <P> |
| 15 | - (void)method __attribute__((availability(macosx,introduced=10_1,deprecated=10_2))); // expected-note {{'method' has been explicitly marked deprecated here}} |
| 16 | |
| 17 | - (void)overridden __attribute__((availability(macosx,introduced=10_3))); // expected-note{{overridden method is here}} |
| 18 | - (void)overridden2 __attribute__((availability(macosx,introduced=10_3))); |
| 19 | - (void)overridden3 __attribute__((availability(macosx,deprecated=10_3))); |
| 20 | - (void)overridden4 __attribute__((availability(macosx,deprecated=10_3))); // expected-note{{overridden method is here}} |
| 21 | - (void)overridden5 __attribute__((availability(macosx,unavailable))); |
| 22 | - (void)overridden6 __attribute__((availability(macosx,introduced=10_3))); // expected-note{{overridden method is here}} |
| 23 | @end |
| 24 | |
| 25 | // rdar://11475360 |
| 26 | @interface B : A |
| 27 | - (void)method; // NOTE: we expect 'method' to *not* inherit availability. |
Jan Korous | 2325569 | 2018-05-17 11:51:49 +0000 | [diff] [blame] | 28 | - (void)overridden __attribute__((availability(macosx,introduced=10_4))); // expected-warning{{overriding method introduced after overridden method on macOS (10.4 vs. 10.3)}} |
Fariborz Jahanian | dbc956d | 2014-10-02 16:39:45 +0000 | [diff] [blame] | 29 | - (void)overridden2 __attribute__((availability(macosx,introduced=10_2))); |
| 30 | - (void)overridden3 __attribute__((availability(macosx,deprecated=10_4))); |
Jan Korous | 2325569 | 2018-05-17 11:51:49 +0000 | [diff] [blame] | 31 | - (void)overridden4 __attribute__((availability(macosx,deprecated=10_2))); // expected-warning{{overriding method deprecated before overridden method on macOS (10.3 vs. 10.2)}} |
Fariborz Jahanian | dbc956d | 2014-10-02 16:39:45 +0000 | [diff] [blame] | 32 | - (void)overridden5 __attribute__((availability(macosx,introduced=10_3))); |
Manman Ren | ccf25bb | 2016-06-28 20:55:30 +0000 | [diff] [blame] | 33 | - (void)overridden6 __attribute__((availability(macosx,unavailable))); // expected-warning{{overriding method cannot be unavailable on macOS when its overridden method is available}} |
Fariborz Jahanian | dbc956d | 2014-10-02 16:39:45 +0000 | [diff] [blame] | 34 | @end |
| 35 | |
| 36 | void f(A *a, B *b) { |
Manman Ren | ccf25bb | 2016-06-28 20:55:30 +0000 | [diff] [blame] | 37 | [a method]; // expected-warning{{'method' is deprecated: first deprecated in macOS 10.2}} |
Fariborz Jahanian | dbc956d | 2014-10-02 16:39:45 +0000 | [diff] [blame] | 38 | [b method]; // no-warning |
Manman Ren | ccf25bb | 2016-06-28 20:55:30 +0000 | [diff] [blame] | 39 | [a proto_method]; // expected-warning{{'proto_method' is deprecated: first deprecated in macOS 10.2}} |
| 40 | [b proto_method]; // expected-warning{{'proto_method' is deprecated: first deprecated in macOS 10.2}} |
Fariborz Jahanian | dbc956d | 2014-10-02 16:39:45 +0000 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | // Test case for <rdar://problem/11627873>. Warn about |
| 44 | // using a deprecated method when that method is re-implemented in a |
| 45 | // subclass where the redeclared method is not deprecated. |
| 46 | @interface C |
| 47 | - (void) method __attribute__((availability(macosx,introduced=10_1,deprecated=10_2))); // expected-note {{'method' has been explicitly marked deprecated here}} |
| 48 | @end |
| 49 | |
| 50 | @interface D : C |
| 51 | - (void) method; |
| 52 | @end |
| 53 | |
| 54 | @interface E : D |
| 55 | - (void) method; |
| 56 | @end |
| 57 | |
| 58 | @implementation D |
| 59 | - (void) method { |
Manman Ren | ccf25bb | 2016-06-28 20:55:30 +0000 | [diff] [blame] | 60 | [super method]; // expected-warning {{'method' is deprecated: first deprecated in macOS 10.2}} |
Fariborz Jahanian | dbc956d | 2014-10-02 16:39:45 +0000 | [diff] [blame] | 61 | } |
| 62 | @end |
| 63 | |
| 64 | @implementation E |
| 65 | - (void) method { |
| 66 | [super method]; // no-warning |
| 67 | } |
| 68 | @end |
| 69 | |
| 70 | // rdar://18059669 |
| 71 | @class NSMutableArray; |
| 72 | |
| 73 | @interface NSDictionary |
| 74 | + (instancetype)dictionaryWithObjectsAndKeys:(id)firstObject, ... __attribute__((sentinel(0,1))); |
| 75 | @end |
| 76 | |
| 77 | @class NSString; |
| 78 | |
| 79 | extern NSString *NSNibTopLevelObjects __attribute__((availability(macosx,introduced=10_0 ,deprecated=10_8,message="" ))); |
| 80 | id NSNibOwner, topNibObjects; |
| 81 | |
| 82 | @interface AppDelegate (SIEImport) // expected-error {{cannot find interface declaration for 'AppDelegate'}} |
| 83 | |
| 84 | -(void)__attribute__((ibaction))importFromSIE:(id)sender; |
| 85 | |
| 86 | @end |
| 87 | |
| 88 | @implementation AppDelegate (SIEImport) // expected-error {{cannot find interface declaration for 'AppDelegate'}} |
| 89 | |
| 90 | -(void)__attribute__((ibaction))importFromSIE:(id)sender { |
| 91 | |
| 92 | NSMutableArray *topNibObjects; |
| 93 | NSDictionary *nibLoadDict = [NSDictionary dictionaryWithObjectsAndKeys:self, NSNibOwner, topNibObjects, NSNibTopLevelObjects, ((void *)0)]; |
| 94 | } |
| 95 | |
| 96 | @end |
Fariborz Jahanian | ce72e63 | 2014-10-02 17:57:26 +0000 | [diff] [blame] | 97 | |
| 98 | @interface Mixed |
| 99 | - (void)Meth1 __attribute__((availability(macosx,introduced=10.3_0))); // expected-warning {{use same version number separators '_' or '.'}} |
| 100 | - (void)Meth2 __attribute__((availability(macosx,introduced=10_3.1))); // expected-warning {{use same version number separators '_' or '.'}} |
| 101 | @end |
Fariborz Jahanian | 5a29e6a | 2014-11-05 23:58:55 +0000 | [diff] [blame] | 102 | |
| 103 | // rdar://18804883 |
| 104 | @protocol P18804883 |
| 105 | - (void)proto_method __attribute__((availability(macosx,introduced=10_1,deprecated=NA))); // means nothing (not deprecated) |
| 106 | @end |
| 107 | |
| 108 | @interface A18804883 <P18804883> |
| 109 | - (void)interface_method __attribute__((availability(macosx,introduced=NA))); // expected-note {{'interface_method' has been explicitly marked unavailable here}} |
| 110 | - (void)strange_method __attribute__((availability(macosx,introduced=NA,deprecated=NA))); // expected-note {{'strange_method' has been explicitly marked unavailable here}} |
| 111 | - (void) always_available __attribute__((availability(macosx,deprecated=NA))); |
| 112 | @end |
| 113 | |
| 114 | void foo (A18804883* pa) { |
Manman Ren | ccf25bb | 2016-06-28 20:55:30 +0000 | [diff] [blame] | 115 | [pa interface_method]; // expected-error {{'interface_method' is unavailable: not available on macOS}} |
Fariborz Jahanian | 5a29e6a | 2014-11-05 23:58:55 +0000 | [diff] [blame] | 116 | [pa proto_method]; |
Manman Ren | ccf25bb | 2016-06-28 20:55:30 +0000 | [diff] [blame] | 117 | [pa strange_method]; // expected-error {{'strange_method' is unavailable: not available on macOS}} |
Fariborz Jahanian | 5a29e6a | 2014-11-05 23:58:55 +0000 | [diff] [blame] | 118 | [pa always_available]; |
| 119 | } |
| 120 | |