Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [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 | |
| 6 | @protocol P |
| 7 | - (void)proto_method __attribute__((availability(macosx,introduced=10_1,deprecated=10_2))); // expected-note 2 {{'proto_method' has been explicitly marked deprecated here}} |
| 8 | @end |
| 9 | |
| 10 | @interface A <P> |
| 11 | - (void)method __attribute__((availability(macosx,introduced=10_1,deprecated=10_2))); // expected-note {{'method' has been explicitly marked deprecated here}} |
| 12 | |
| 13 | - (void)overridden __attribute__((availability(macosx,introduced=10_3))); // expected-note{{overridden method is here}} |
| 14 | - (void)overridden2 __attribute__((availability(macosx,introduced=10_3))); |
| 15 | - (void)overridden3 __attribute__((availability(macosx,deprecated=10_3))); |
| 16 | - (void)overridden4 __attribute__((availability(macosx,deprecated=10_3))); // expected-note{{overridden method is here}} |
| 17 | - (void)overridden5 __attribute__((availability(macosx,unavailable))); |
| 18 | - (void)overridden6 __attribute__((availability(macosx,introduced=10_3))); // expected-note{{overridden method is here}} |
| 19 | @end |
| 20 | |
| 21 | // rdar://11475360 |
| 22 | @interface B : A |
| 23 | - (void)method; // NOTE: we expect 'method' to *not* inherit availability. |
| 24 | - (void)overridden __attribute__((availability(macosx,introduced=10_4))); // expected-warning{{overriding method introduced after overridden method on OS X (10_4 vs. 10_3)}} |
| 25 | - (void)overridden2 __attribute__((availability(macosx,introduced=10_2))); |
| 26 | - (void)overridden3 __attribute__((availability(macosx,deprecated=10_4))); |
| 27 | - (void)overridden4 __attribute__((availability(macosx,deprecated=10_2))); // expected-warning{{overriding method deprecated before overridden method on OS X (10_3 vs. 10_2)}} |
| 28 | - (void)overridden5 __attribute__((availability(macosx,introduced=10_3))); |
| 29 | - (void)overridden6 __attribute__((availability(macosx,unavailable))); // expected-warning{{overriding method cannot be unavailable on OS X when its overridden method is available}} |
| 30 | @end |
| 31 | |
| 32 | void f(A *a, B *b) { |
| 33 | [a method]; // expected-warning{{'method' is deprecated: first deprecated in OS X 10.2}} |
| 34 | [b method]; // no-warning |
| 35 | [a proto_method]; // expected-warning{{'proto_method' is deprecated: first deprecated in OS X 10.2}} |
| 36 | [b proto_method]; // expected-warning{{'proto_method' is deprecated: first deprecated in OS X 10.2}} |
| 37 | } |
| 38 | |
| 39 | // Test case for <rdar://problem/11627873>. Warn about |
| 40 | // using a deprecated method when that method is re-implemented in a |
| 41 | // subclass where the redeclared method is not deprecated. |
| 42 | @interface C |
| 43 | - (void) method __attribute__((availability(macosx,introduced=10_1,deprecated=10_2))); // expected-note {{'method' has been explicitly marked deprecated here}} |
| 44 | @end |
| 45 | |
| 46 | @interface D : C |
| 47 | - (void) method; |
| 48 | @end |
| 49 | |
| 50 | @interface E : D |
| 51 | - (void) method; |
| 52 | @end |
| 53 | |
| 54 | @implementation D |
| 55 | - (void) method { |
| 56 | [super method]; // expected-warning {{'method' is deprecated: first deprecated in OS X 10.2}} |
| 57 | } |
| 58 | @end |
| 59 | |
| 60 | @implementation E |
| 61 | - (void) method { |
| 62 | [super method]; // no-warning |
| 63 | } |
| 64 | @end |
| 65 | |
| 66 | // rdar://18059669 |
| 67 | @class NSMutableArray; |
| 68 | |
| 69 | @interface NSDictionary |
| 70 | + (instancetype)dictionaryWithObjectsAndKeys:(id)firstObject, ... __attribute__((sentinel(0,1))); |
| 71 | @end |
| 72 | |
| 73 | @class NSString; |
| 74 | |
| 75 | extern NSString *NSNibTopLevelObjects __attribute__((availability(macosx,introduced=10_0 ,deprecated=10_8,message="" ))); |
| 76 | id NSNibOwner, topNibObjects; |
| 77 | |
| 78 | @interface AppDelegate (SIEImport) // expected-error {{cannot find interface declaration for 'AppDelegate'}} |
| 79 | |
| 80 | -(void)__attribute__((ibaction))importFromSIE:(id)sender; |
| 81 | |
| 82 | @end |
| 83 | |
| 84 | @implementation AppDelegate (SIEImport) // expected-error {{cannot find interface declaration for 'AppDelegate'}} |
| 85 | |
| 86 | -(void)__attribute__((ibaction))importFromSIE:(id)sender { |
| 87 | |
| 88 | NSMutableArray *topNibObjects; |
| 89 | NSDictionary *nibLoadDict = [NSDictionary dictionaryWithObjectsAndKeys:self, NSNibOwner, topNibObjects, NSNibTopLevelObjects, ((void *)0)]; |
| 90 | } |
| 91 | |
| 92 | @end |
| 93 | |
| 94 | @interface Mixed |
| 95 | - (void)Meth1 __attribute__((availability(macosx,introduced=10.3_0))); // expected-warning {{use same version number separators '_' or '.'}} |
| 96 | - (void)Meth2 __attribute__((availability(macosx,introduced=10_3.1))); // expected-warning {{use same version number separators '_' or '.'}} |
| 97 | @end |
| 98 | |
| 99 | // rdar://18804883 |
| 100 | @protocol P18804883 |
| 101 | - (void)proto_method __attribute__((availability(macosx,introduced=10_1,deprecated=NA))); // means nothing (not deprecated) |
| 102 | @end |
| 103 | |
| 104 | @interface A18804883 <P18804883> |
| 105 | - (void)interface_method __attribute__((availability(macosx,introduced=NA))); // expected-note {{'interface_method' has been explicitly marked unavailable here}} |
| 106 | - (void)strange_method __attribute__((availability(macosx,introduced=NA,deprecated=NA))); // expected-note {{'strange_method' has been explicitly marked unavailable here}} |
| 107 | - (void) always_available __attribute__((availability(macosx,deprecated=NA))); |
| 108 | @end |
| 109 | |
| 110 | void foo (A18804883* pa) { |
| 111 | [pa interface_method]; // expected-error {{'interface_method' is unavailable: not available on OS X}} |
| 112 | [pa proto_method]; |
| 113 | [pa strange_method]; // expected-error {{'strange_method' is unavailable: not available on OS X}} |
| 114 | [pa always_available]; |
| 115 | } |
| 116 | |