Debian Codegraph @

clang/test/SemaObjC/class-unavail-warning.m

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