1 | // RUN: %clang_cc1 -fsyntax-only -fblocks -triple x86_64-apple-darwin10 -verify %s |
2 | // rdar://9092208 |
3 | |
4 | __attribute__((unavailable("not available"))) |
5 | @interface MyClass { // expected-note 7 {{'MyClass' has been explicitly marked unavailable here}} |
6 | @public |
7 | void *_test; |
8 | MyClass *ivar; // no error. |
9 | } |
10 | |
11 | - (id)self; |
12 | - new; |
13 | + (void)addObject:(id)anObject; |
14 | - (MyClass *)meth; // no error. |
15 | |
16 | @end |
17 | |
18 | @interface Gorf { |
19 | MyClass *ivar; // expected-error {{unavailable}} |
20 | } |
21 | - (MyClass *)meth; // expected-error {{unavailable}} |
22 | @end |
23 | |
24 | @interface MyClass (Cat1) |
25 | - (MyClass *)meth; // no error. |
26 | @end |
27 | |
28 | @interface MyClass (Cat2) // no error. |
29 | @end |
30 | |
31 | @implementation MyClass (Cat2) // no error. |
32 | @end |
33 | |
34 | int main() { |
35 | [MyClass new]; // expected-error {{'MyClass' is unavailable: not available}} |
36 | [MyClass self]; // expected-error {{'MyClass' is unavailable: not available}} |
37 | [MyClass addObject:((void *)0)]; // expected-error {{'MyClass' is unavailable: not available}} |
38 | |
39 | MyClass *foo = [MyClass new]; // expected-error 2 {{'MyClass' is unavailable: not available}} |
40 | |
41 | return 0; |
42 | } |
43 | |
44 | // rdar://16681279 |
45 | @interface NSObject @end |
46 | |
47 | __attribute__((visibility("default"))) __attribute__((availability(macosx,unavailable))) |
48 | @interface Foo : NSObject @end // expected-note 3 {{'Foo' has been explicitly marked unavailable here}} |
49 | @interface AppDelegate : NSObject |
50 | @end |
51 | |
52 | @class Foo; |
53 | |
54 | @implementation AppDelegate |
55 | - (void) applicationDidFinishLaunching |
56 | { |
57 | Foo *foo = 0; // expected-error {{'Foo' is unavailable}} |
58 | } |
59 | @end |
60 | |
61 | @class Foo; |
62 | Foo *g_foo = 0; // expected-error {{'Foo' is unavailable}} |
63 | |
64 | @class Foo; |
65 | @class Foo; |
66 | @class Foo; |
67 | Foo * f_func() { // expected-error {{'Foo' is unavailable}} |
68 | return 0; |
69 | } |
70 | |
71 | #define UNAVAILABLE __attribute__((unavailable("not available"))) |
72 | |
73 | UNAVAILABLE |
74 | @interface Base // expected-note {{unavailable here}} |
75 | @end |
76 | |
77 | UNAVAILABLE |
78 | @protocol SomeProto // expected-note 4 {{unavailable here}} |
79 | @end |
80 | |
81 | @interface Sub : Base<SomeProto> // expected-error 2 {{unavailable}} |
82 | @end |
83 | @interface IP<SomeProto> // expected-error {{unavailable}} |
84 | @end |
85 | @protocol SubProt<SomeProto> // expected-error {{unavailable}} |
86 | @end |
87 | @interface Sub(cat)<SomeProto> // expected-error {{unavailable}} |
88 | @end |
89 | |
90 | UNAVAILABLE |
91 | @interface UnavailSub : Base<SomeProto> // no error |
92 | @end |
93 | UNAVAILABLE |
94 | @interface UnavailIP<SomeProto> // no error |
95 | @end |
96 | UNAVAILABLE |
97 | @protocol UnavailProt<SomeProto> // no error |
98 | @end |
99 | @interface UnavailSub(cat)<SomeProto> // no error |
100 | @end |
101 | |
102 | int unavail_global UNAVAILABLE; |
103 | |
104 | UNAVAILABLE __attribute__((objc_root_class)) |
105 | @interface TestAttrContext |
106 | -meth; |
107 | @end |
108 | |
109 | @implementation TestAttrContext |
110 | -meth { |
111 | unavail_global = 2; // no warn |
112 | (void) ^{ |
113 | unavail_global = 4; // no warn |
114 | }; |
115 | } |
116 | @end |
117 | |
118 | typedef int unavailable_int UNAVAILABLE; // expected-note {{'unavailable_int' has been explicitly marked unavailable here}} |
119 | |
120 | UNAVAILABLE |
121 | @interface A |
122 | extern unavailable_int global_unavailable; // expected-error {{'unavailable_int' is unavailable: not available}} |
123 | @end |
124 | |