blob: 3ebf3e7815f3a7613f63130aeaa0671dd2618168 [file] [log] [blame]
Stephen Hinesc568f1e2014-07-21 00:47:37 -07001// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -verify %s
Fariborz Jahanian02b0d652011-03-08 19:12:46 +00002// rdar://9092208
3
4__attribute__((unavailable("not available")))
Stephen Hines651f13c2014-04-23 16:59:28 -07005@interface MyClass { // expected-note 8 {{'MyClass' has been explicitly marked unavailable here}}
Fariborz Jahanian02b0d652011-03-08 19:12:46 +00006@public
7 void *_test;
Argyrios Kyrtzidis3a387442011-10-06 23:23:20 +00008 MyClass *ivar; // no error.
Fariborz Jahanian02b0d652011-03-08 19:12:46 +00009}
10
11- (id)self;
12- new;
13+ (void)addObject:(id)anObject;
Argyrios Kyrtzidis3a387442011-10-06 23:23:20 +000014- (MyClass *)meth; // no error.
Fariborz Jahanian02b0d652011-03-08 19:12:46 +000015
16@end
17
Stephen Hinesc568f1e2014-07-21 00:47:37 -070018@interface Gorf {
Argyrios Kyrtzidis3a387442011-10-06 23:23:20 +000019 MyClass *ivar; // expected-error {{unavailable}}
20}
21- (MyClass *)meth; // expected-error {{unavailable}}
22@end
23
Argyrios Kyrtzidisc076e372011-10-06 23:23:27 +000024@interface MyClass (Cat1)
25- (MyClass *)meth; // no error.
26@end
27
28@interface MyClass (Cat2) // no error.
29@end
30
31@implementation MyClass (Cat2) // expected-error {{unavailable}}
32@end
33
Fariborz Jahanian02b0d652011-03-08 19:12:46 +000034int 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}
Stephen Hinesc568f1e2014-07-21 00:47:37 -070043
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;
62Foo *g_foo = 0; // expected-error {{'Foo' is unavailable}}
63
64@class Foo;
65@class Foo;
66@class Foo;
67Foo * f_func() { // expected-error {{'Foo' is unavailable}}
68 return 0;
69}