1 // RUN: %clang_cc1 -triple x86_64-apple-macosx-10.9 -Wunguarded-availability -fblocks -fsyntax-only -verify %s
3 __attribute__((objc_root_class))
9 @interface MyObject : NSObject
10 -(instancetype)init __attribute__((unavailable)); // expected-note{{'init' has been explicitly marked unavailable here}}
13 void usemyobject(void) {
14 [MyObject new]; // expected-error{{'new' is unavailable}}
17 @interface MyOtherObject : NSObject
18 +(instancetype)init __attribute__((unavailable));
22 void usemyotherobject(void) {
23 [MyOtherObject new]; // no error; new is overrideen.
26 @interface NotGoodOverride : NSObject
27 +(instancetype)init __attribute__((unavailable));
29 +(instancetype)new: (int)x;
32 void usenotgoodoverride(void) {
33 [NotGoodOverride new]; // no error
36 @interface NotNSObject
41 @interface NotMyObject : NotNSObject
42 -(instancetype)init __attribute__((unavailable));
45 void usenotmyobject(void) {
46 [NotMyObject new]; // no error; this isn't NSObject
49 @interface FromSelf : NSObject
50 -(instancetype)init __attribute__((unavailable));
51 +(FromSelf*)another_one;
54 @implementation FromSelf
55 +(FromSelf*)another_one {
60 @interface NoInit : NSObject
61 -(instancetype)init __attribute__((unavailable)); // expected-note {{'init' has been explicitly marked unavailable here}}
64 @interface NoInitSub : NoInit @end
66 @implementation NoInitSub
67 -(void)meth:(Class)c {
68 [c new]; // No error; unknown interface.
69 [NoInitSub new]; // expected-error {{'new' is unavailable}}