87 lines · plain
1// RUN: %clang_cc1 -x objective-c -verify -fobjc-arc %s2 3@interface NSObject4 5+ (instancetype)new;6+ (instancetype)alloc;7 8- (void)declaredInSuper;9 10@end11 12@interface NSObject (Category)13 14- (void)declaredInSuperCategory;15 16@end17 18@interface Sub: NSObject19 20- (instancetype)init __attribute__((unavailable)); // expected-note 4 {{'init' has been explicitly marked unavailable here}}21 22- (void)notImplemented __attribute__((unavailable));23 24- (void)declaredInSuper __attribute__((unavailable));25- (void)declaredInSuperCategory __attribute__((unavailable));26 27@end28 29@implementation Sub30 31+ (Sub *)create {32 return [[self alloc] init];33}34 35+ (Sub *)create2 {36 return [self new];37}38 39+ (Sub *)create3 {40 return [Sub new];41}42 43- (instancetype) init {44 return self;45}46 47- (void)reportUseOfUnimplemented {48 [self notImplemented];49}50 51- (void)allowSuperCallUsingSelf {52 [self declaredInSuper];53 [[Sub alloc] declaredInSuper];54 [self declaredInSuperCategory];55 [[Sub alloc] declaredInSuperCategory];56}57 58@end59 60@interface SubClassContext: Sub61@end62 63@implementation SubClassContext64 65- (void)subClassContext {66 (void)[[Sub alloc] init]; // expected-error {{'init' is unavailable}}67 (void)[Sub new]; // expected-error {{'new' is unavailable}}68}69 70@end71 72void unrelatedContext(void) {73 (void)[[Sub alloc] init]; // expected-error {{'init' is unavailable}}74 (void)[Sub new]; // expected-error {{'new' is unavailable}}75}76 77@interface X @end78 79@interface X (Foo)80-(void)meth __attribute__((unavailable));81@end82 83@implementation X (Foo)84-(void)meth {}85-(void)call_it { [self meth]; }86@end87