Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -verify %s |
Fariborz Jahanian | 02b0d65 | 2011-03-08 19:12:46 +0000 | [diff] [blame] | 2 | // rdar://9092208 |
| 3 | |
| 4 | __attribute__((unavailable("not available"))) |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 5 | @interface MyClass { // expected-note 8 {{'MyClass' has been explicitly marked unavailable here}} |
Fariborz Jahanian | 02b0d65 | 2011-03-08 19:12:46 +0000 | [diff] [blame] | 6 | @public |
| 7 | void *_test; |
Argyrios Kyrtzidis | 3a38744 | 2011-10-06 23:23:20 +0000 | [diff] [blame] | 8 | MyClass *ivar; // no error. |
Fariborz Jahanian | 02b0d65 | 2011-03-08 19:12:46 +0000 | [diff] [blame] | 9 | } |
| 10 | |
| 11 | - (id)self; |
| 12 | - new; |
| 13 | + (void)addObject:(id)anObject; |
Argyrios Kyrtzidis | 3a38744 | 2011-10-06 23:23:20 +0000 | [diff] [blame] | 14 | - (MyClass *)meth; // no error. |
Fariborz Jahanian | 02b0d65 | 2011-03-08 19:12:46 +0000 | [diff] [blame] | 15 | |
| 16 | @end |
| 17 | |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 18 | @interface Gorf { |
Argyrios Kyrtzidis | 3a38744 | 2011-10-06 23:23:20 +0000 | [diff] [blame] | 19 | MyClass *ivar; // expected-error {{unavailable}} |
| 20 | } |
| 21 | - (MyClass *)meth; // expected-error {{unavailable}} |
| 22 | @end |
| 23 | |
Argyrios Kyrtzidis | c076e37 | 2011-10-06 23:23:27 +0000 | [diff] [blame] | 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) // expected-error {{unavailable}} |
| 32 | @end |
| 33 | |
Fariborz Jahanian | 02b0d65 | 2011-03-08 19:12:46 +0000 | [diff] [blame] | 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 | } |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 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 | } |