1 // RUN: %clang_cc1 -fsyntax-only -fblocks -triple x86_64-apple-darwin10 -verify %s
3 __attribute__((unavailable("not available")))
4 @interface MyClass { // expected-note 7 {{'MyClass' has been explicitly marked unavailable here}}
7 MyClass *ivar; // no error.
12 + (void)addObject:(id)anObject;
13 - (MyClass *)meth; // no error.
18 MyClass *ivar; // expected-error {{unavailable}}
20 - (MyClass *)meth; // expected-error {{unavailable}}
23 @interface MyClass (Cat1)
24 - (MyClass *)meth; // no error.
27 @interface MyClass (Cat2) // no error.
30 @implementation MyClass (Cat2) // no error.
34 [MyClass new]; // expected-error {{'MyClass' is unavailable: not available}}
35 [MyClass self]; // expected-error {{'MyClass' is unavailable: not available}}
36 [MyClass addObject:((void *)0)]; // expected-error {{'MyClass' is unavailable: not available}}
38 MyClass *foo = [MyClass new]; // expected-error 2 {{'MyClass' is unavailable: not available}}
43 @interface NSObject @end
45 __attribute__((visibility("default"))) __attribute__((availability(macosx,unavailable)))
46 @interface Foo : NSObject @end // expected-note 3 {{'Foo' has been explicitly marked unavailable here}}
47 @interface AppDelegate : NSObject
52 @implementation AppDelegate
53 - (void) applicationDidFinishLaunching
55 Foo *foo = 0; // expected-error {{'Foo' is unavailable}}
60 Foo *g_foo = 0; // expected-error {{'Foo' is unavailable}}
65 Foo * f_func(void) { // expected-error {{'Foo' is unavailable}}
69 #define UNAVAILABLE __attribute__((unavailable("not available")))
72 @interface Base // expected-note {{unavailable here}}
76 @protocol SomeProto // expected-note 4 {{unavailable here}}
79 @interface Sub : Base<SomeProto> // expected-error 2 {{unavailable}}
81 @interface IP<SomeProto> // expected-error {{unavailable}}
83 @protocol SubProt<SomeProto> // expected-error {{unavailable}}
85 @interface Sub(cat)<SomeProto> // expected-error {{unavailable}}
89 @interface UnavailSub : Base<SomeProto> // no error
92 @interface UnavailIP<SomeProto> // no error
95 @protocol UnavailProt<SomeProto> // no error
97 @interface UnavailSub(cat)<SomeProto> // no error
100 int unavail_global UNAVAILABLE;
102 UNAVAILABLE __attribute__((objc_root_class))
103 @interface TestAttrContext
107 @implementation TestAttrContext
109 unavail_global = 2; // no warn
111 unavail_global = 4; // no warn
116 typedef int unavailable_int UNAVAILABLE; // expected-note {{'unavailable_int' has been explicitly marked unavailable here}}
120 extern unavailable_int global_unavailable; // expected-error {{'unavailable_int' is unavailable: not available}}