72 lines · plain
1// RUN: %clang_cc1 -triple x86_64-apple-macosx-10.9 -Wunguarded-availability -fblocks -fsyntax-only -verify %s2 3__attribute__((objc_root_class))4@interface NSObject5+(instancetype)new;6-(instancetype)init;7@end8 9@interface MyObject : NSObject10-(instancetype)init __attribute__((unavailable)); // expected-note{{'init' has been explicitly marked unavailable here}}11@end12 13void usemyobject(void) {14 [MyObject new]; // expected-error{{'new' is unavailable}}15}16 17@interface MyOtherObject : NSObject18+(instancetype)init __attribute__((unavailable));19+(instancetype)new;20@end21 22void usemyotherobject(void) {23 [MyOtherObject new]; // no error; new is overrideen.24}25 26@interface NotGoodOverride : NSObject27+(instancetype)init __attribute__((unavailable));28-(instancetype)new;29+(instancetype)new: (int)x;30@end31 32void usenotgoodoverride(void) {33 [NotGoodOverride new]; // no error34}35 36@interface NotNSObject37+(instancetype)new;38-(instancetype)init;39@end40 41@interface NotMyObject : NotNSObject42-(instancetype)init __attribute__((unavailable));43@end44 45void usenotmyobject(void) {46 [NotMyObject new]; // no error; this isn't NSObject47}48 49@interface FromSelf : NSObject50-(instancetype)init __attribute__((unavailable));51+(FromSelf*)another_one;52@end53 54@implementation FromSelf55+(FromSelf*)another_one {56 [self new];57}58@end59 60@interface NoInit : NSObject61-(instancetype)init __attribute__((unavailable)); // expected-note {{'init' has been explicitly marked unavailable here}}62@end63 64@interface NoInitSub : NoInit @end65 66@implementation NoInitSub67-(void)meth:(Class)c {68 [c new]; // No error; unknown interface.69 [NoInitSub new]; // expected-error {{'new' is unavailable}}70}71@end72