| John McCall | 0bd3e40 | 2012-05-08 21:41:25 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -fobjc-exceptions -verify -Wno-objc-root-class %s | 
| John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 2 | // rdar://9309489 | 
|  | 3 |  | 
|  | 4 | @interface MyClass { | 
|  | 5 | id __weak myString; | 
|  | 6 | id StrongIvar; | 
|  | 7 | id __weak myString2; | 
|  | 8 | id __weak myString3; | 
|  | 9 | id StrongIvar5; | 
|  | 10 | } | 
|  | 11 | @property (strong) id myString; // expected-note {{property declared here}} | 
|  | 12 | @property (strong) id myString1; | 
|  | 13 | @property (retain) id myString2; // expected-note {{property declared here}} | 
|  | 14 | // | 
|  | 15 | @property (weak) id myString3; | 
|  | 16 | @property (weak) id myString4; | 
|  | 17 | @property __weak id myString5; // expected-note {{property declared here}} | 
|  | 18 | @end | 
|  | 19 |  | 
|  | 20 | @implementation MyClass | 
| Fariborz Jahanian | 14fd801 | 2012-09-24 22:00:36 +0000 | [diff] [blame] | 21 | @synthesize myString; // expected-error {{existing instance variable 'myString' for strong property 'myString' may not be __weak}} | 
| John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 22 | @synthesize myString1 = StrongIvar; // OK | 
| Fariborz Jahanian | 14fd801 | 2012-09-24 22:00:36 +0000 | [diff] [blame] | 23 | @synthesize myString2 = myString2; // expected-error {{existing instance variable 'myString2' for strong property 'myString2' may not be __weak}} | 
| John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 24 | // | 
|  | 25 | @synthesize myString3; // OK | 
|  | 26 | @synthesize myString4; // OK | 
| Fariborz Jahanian | 14fd801 | 2012-09-24 22:00:36 +0000 | [diff] [blame] | 27 | @synthesize myString5 = StrongIvar5; // expected-error {{existing instance variable 'StrongIvar5' for __weak property 'myString5' must be __weak}} | 
| John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 28 |  | 
|  | 29 | @end | 
|  | 30 |  | 
|  | 31 | // rdar://9340692 | 
|  | 32 | @interface Foo { | 
|  | 33 | @public | 
|  | 34 | id __unsafe_unretained x;   // should be __weak | 
|  | 35 | id __strong y; | 
| Fariborz Jahanian | 61740f6 | 2012-09-24 22:51:51 +0000 | [diff] [blame^] | 36 | id __autoreleasing z; // expected-error {{instance variables cannot have __autoreleasing ownership}} | 
| John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 37 | } | 
|  | 38 | @property(weak) id x; // expected-note {{property declared here}} | 
|  | 39 | @property(weak) id y; // expected-note {{property declared here}} | 
|  | 40 | @property(weak) id z; | 
|  | 41 | @end | 
|  | 42 |  | 
|  | 43 | @implementation Foo | 
| Fariborz Jahanian | 14fd801 | 2012-09-24 22:00:36 +0000 | [diff] [blame] | 44 | @synthesize x;	// expected-error {{existing instance variable 'x' for __weak property 'x' must be __weak}} | 
|  | 45 | @synthesize y;	// expected-error {{existing instance variable 'y' for __weak property 'y' must be __weak}} | 
| John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 46 | @synthesize z;  // suppressed | 
|  | 47 | @end | 
|  | 48 |  | 
| John McCall | 2499237 | 2012-02-21 21:48:05 +0000 | [diff] [blame] | 49 | // rdar://problem/10904479 | 
|  | 50 | // Don't crash. | 
|  | 51 | @interface Test2 | 
|  | 52 | // Minor FIXME: kill the redundant error | 
|  | 53 | @property (strong) UndeclaredClass *test2;  // expected-error {{unknown type name 'UndeclaredClass'}} expected-error {{must be of object type}} | 
|  | 54 | @end | 
|  | 55 | @implementation Test2 | 
|  | 56 | @synthesize test2; | 
|  | 57 | @end | 
| John McCall | 0bd3e40 | 2012-05-08 21:41:25 +0000 | [diff] [blame] | 58 |  | 
|  | 59 | // rdar://problem/11144407 | 
|  | 60 | @interface Test3 | 
|  | 61 | @property (strong) id exception; | 
|  | 62 | @end | 
|  | 63 | void test3(Test3 *t3) { | 
|  | 64 | @throw t3.exception; | 
|  | 65 | } |