xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/class-unavail-warning.m (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc// RUN: %clang_cc1  -fsyntax-only  -triple x86_64-apple-darwin10 -verify %s
2f4a2713aSLionel Sambuc// rdar://9092208
3f4a2713aSLionel Sambuc
4f4a2713aSLionel Sambuc__attribute__((unavailable("not available")))
5*0a6a1f1dSLionel Sambuc@interface MyClass { // expected-note 8 {{'MyClass' has been explicitly marked unavailable here}}
6f4a2713aSLionel Sambuc@public
7f4a2713aSLionel Sambuc    void *_test;
8f4a2713aSLionel Sambuc    MyClass *ivar; // no error.
9f4a2713aSLionel Sambuc}
10f4a2713aSLionel Sambuc
11f4a2713aSLionel Sambuc- (id)self;
12f4a2713aSLionel Sambuc- new;
13f4a2713aSLionel Sambuc+ (void)addObject:(id)anObject;
14f4a2713aSLionel Sambuc- (MyClass *)meth; // no error.
15f4a2713aSLionel Sambuc
16f4a2713aSLionel Sambuc@end
17f4a2713aSLionel Sambuc
18*0a6a1f1dSLionel Sambuc@interface Gorf {
19f4a2713aSLionel Sambuc  MyClass *ivar; // expected-error {{unavailable}}
20f4a2713aSLionel Sambuc}
21f4a2713aSLionel Sambuc- (MyClass *)meth; // expected-error {{unavailable}}
22f4a2713aSLionel Sambuc@end
23f4a2713aSLionel Sambuc
24f4a2713aSLionel Sambuc@interface MyClass (Cat1)
25f4a2713aSLionel Sambuc- (MyClass *)meth; // no error.
26f4a2713aSLionel Sambuc@end
27f4a2713aSLionel Sambuc
28f4a2713aSLionel Sambuc@interface MyClass (Cat2) // no error.
29f4a2713aSLionel Sambuc@end
30f4a2713aSLionel Sambuc
31f4a2713aSLionel Sambuc@implementation MyClass (Cat2) // expected-error {{unavailable}}
32f4a2713aSLionel Sambuc@end
33f4a2713aSLionel Sambuc
34f4a2713aSLionel Sambucint main() {
35f4a2713aSLionel Sambuc [MyClass new]; // expected-error {{'MyClass' is unavailable: not available}}
36f4a2713aSLionel Sambuc [MyClass self]; // expected-error {{'MyClass' is unavailable: not available}}
37f4a2713aSLionel Sambuc [MyClass addObject:((void *)0)]; // expected-error {{'MyClass' is unavailable: not available}}
38f4a2713aSLionel Sambuc
39f4a2713aSLionel Sambuc MyClass *foo = [MyClass new]; // expected-error 2 {{'MyClass' is unavailable: not available}}
40f4a2713aSLionel Sambuc
41f4a2713aSLionel Sambuc return 0;
42f4a2713aSLionel Sambuc}
43*0a6a1f1dSLionel Sambuc
44*0a6a1f1dSLionel Sambuc// rdar://16681279
45*0a6a1f1dSLionel Sambuc@interface NSObject @end
46*0a6a1f1dSLionel Sambuc
47*0a6a1f1dSLionel Sambuc__attribute__((visibility("default"))) __attribute__((availability(macosx,unavailable)))
48*0a6a1f1dSLionel Sambuc@interface Foo : NSObject @end // expected-note 3 {{'Foo' has been explicitly marked unavailable here}}
49*0a6a1f1dSLionel Sambuc@interface AppDelegate  : NSObject
50*0a6a1f1dSLionel Sambuc@end
51*0a6a1f1dSLionel Sambuc
52*0a6a1f1dSLionel Sambuc@class Foo;
53*0a6a1f1dSLionel Sambuc
54*0a6a1f1dSLionel Sambuc@implementation AppDelegate
55*0a6a1f1dSLionel Sambuc- (void) applicationDidFinishLaunching
56*0a6a1f1dSLionel Sambuc{
57*0a6a1f1dSLionel Sambuc  Foo *foo = 0; // expected-error {{'Foo' is unavailable}}
58*0a6a1f1dSLionel Sambuc}
59*0a6a1f1dSLionel Sambuc@end
60*0a6a1f1dSLionel Sambuc
61*0a6a1f1dSLionel Sambuc@class Foo;
62*0a6a1f1dSLionel SambucFoo *g_foo = 0; // expected-error {{'Foo' is unavailable}}
63*0a6a1f1dSLionel Sambuc
64*0a6a1f1dSLionel Sambuc@class Foo;
65*0a6a1f1dSLionel Sambuc@class Foo;
66*0a6a1f1dSLionel Sambuc@class Foo;
67*0a6a1f1dSLionel SambucFoo * f_func() { // expected-error {{'Foo' is unavailable}}
68*0a6a1f1dSLionel Sambuc  return 0;
69*0a6a1f1dSLionel Sambuc}
70