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