2019-01-10 06:31:37 +08:00
|
|
|
// RUN: %clang_cc1 -x objective-c -verify -fobjc-arc %s
|
|
|
|
|
|
|
|
@interface NSObject
|
|
|
|
|
|
|
|
+ (instancetype)new;
|
|
|
|
+ (instancetype)alloc;
|
|
|
|
|
2019-01-18 02:12:45 +08:00
|
|
|
- (void)declaredInSuper;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface NSObject (Category)
|
|
|
|
|
|
|
|
- (void)declaredInSuperCategory;
|
|
|
|
|
2019-01-10 06:31:37 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@interface Sub: NSObject
|
|
|
|
|
|
|
|
- (instancetype)init __attribute__((unavailable)); // expected-note 4 {{'init' has been explicitly marked unavailable here}}
|
|
|
|
|
2019-01-18 02:12:45 +08:00
|
|
|
- (void)notImplemented __attribute__((unavailable));
|
|
|
|
|
|
|
|
- (void)declaredInSuper __attribute__((unavailable));
|
|
|
|
- (void)declaredInSuperCategory __attribute__((unavailable));
|
2019-01-10 06:31:37 +08:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation Sub
|
|
|
|
|
|
|
|
+ (Sub *)create {
|
|
|
|
return [[self alloc] init];
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (Sub *)create2 {
|
|
|
|
return [self new];
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (Sub *)create3 {
|
|
|
|
return [Sub new];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (instancetype) init {
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)reportUseOfUnimplemented {
|
2019-01-18 02:12:45 +08:00
|
|
|
[self notImplemented];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)allowSuperCallUsingSelf {
|
|
|
|
[self declaredInSuper];
|
|
|
|
[[Sub alloc] declaredInSuper];
|
|
|
|
[self declaredInSuperCategory];
|
|
|
|
[[Sub alloc] declaredInSuperCategory];
|
2019-01-10 06:31:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface SubClassContext: Sub
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation SubClassContext
|
|
|
|
|
|
|
|
- (void)subClassContext {
|
|
|
|
(void)[[Sub alloc] init]; // expected-error {{'init' is unavailable}}
|
|
|
|
(void)[Sub new]; // expected-error {{'new' is unavailable}}
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
void unrelatedContext() {
|
|
|
|
(void)[[Sub alloc] init]; // expected-error {{'init' is unavailable}}
|
|
|
|
(void)[Sub new]; // expected-error {{'new' is unavailable}}
|
|
|
|
}
|
|
|
|
|
|
|
|
@interface X @end
|
|
|
|
|
|
|
|
@interface X (Foo)
|
|
|
|
-(void)meth __attribute__((unavailable));
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation X (Foo)
|
|
|
|
-(void)meth {}
|
|
|
|
-(void)call_it { [self meth]; }
|
|
|
|
@end
|