John McCall | d1e40d5 | 2011-10-02 01:16:38 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fobjc-exceptions -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result |
| 2 | // RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fobjc-exceptions -fblocks -fsyntax-only -x objective-c %s > %t |
John McCall | 8f0e8d2 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 3 | // RUN: diff %t %s.result |
| 4 | |
Argyrios Kyrtzidis | 1aa60ff | 2011-07-15 22:04:00 +0000 | [diff] [blame] | 5 | #define nil 0 |
| 6 | |
John McCall | 8f0e8d2 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 7 | typedef int BOOL; |
| 8 | |
| 9 | id IhaveSideEffect(); |
| 10 | |
| 11 | @protocol NSObject |
| 12 | - (BOOL)isEqual:(id)object; |
| 13 | - (id)retain; |
| 14 | - (oneway void)release; |
| 15 | @end |
| 16 | |
| 17 | @interface NSObject <NSObject> {} |
| 18 | @end |
| 19 | |
| 20 | @interface Foo : NSObject { |
| 21 | id bar; |
| 22 | } |
Fariborz Jahanian | 86f9601 | 2012-01-20 19:15:02 +0000 | [diff] [blame] | 23 | @property (strong) id bar; |
John McCall | 8f0e8d2 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 24 | -(void)test:(id)obj; |
| 25 | @end |
| 26 | |
| 27 | @implementation Foo |
| 28 | |
| 29 | @synthesize bar; |
| 30 | |
| 31 | -(void)test:(id)obj { |
| 32 | id x = self.bar; |
| 33 | self.bar = obj; |
| 34 | // do stuff with x; |
| 35 | |
| 36 | IhaveSideEffect(); |
| 37 | |
| 38 | x = 0; |
Argyrios Kyrtzidis | f55a869 | 2011-07-15 21:11:23 +0000 | [diff] [blame] | 39 | |
| 40 | @try { |
| 41 | } @finally { |
Argyrios Kyrtzidis | 1aa60ff | 2011-07-15 22:04:00 +0000 | [diff] [blame] | 42 | x = nil; |
Argyrios Kyrtzidis | f55a869 | 2011-07-15 21:11:23 +0000 | [diff] [blame] | 43 | } |
John McCall | 8f0e8d2 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | @end |
| 47 | |
| 48 | void func(Foo *p) { |
| 49 | } |
| 50 | |
| 51 | @interface Baz { |
| 52 | id <NSObject> _foo; |
| 53 | } |
| 54 | @end |
| 55 | |
| 56 | @implementation Baz |
John McCall | 8f0e8d2 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 57 | @end |
| 58 | |
| 59 | void block_test(Foo *p) { |
| 60 | id (^B)() = ^() { |
| 61 | if (p) { |
| 62 | id (^IB)() = ^() { |
| 63 | id bar = p; |
| 64 | return bar; |
| 65 | }; |
| 66 | IB(); |
| 67 | } |
| 68 | return p; |
| 69 | }; |
| 70 | } |
| 71 | |
| 72 | #define RELEASE_MACRO(x) [x release] |
| 73 | #define RELEASE_MACRO2(x) RELEASE_MACRO(x) |
| 74 | |
| 75 | void test2(id p) { |
| 76 | } |
Argyrios Kyrtzidis | 18fd0c6 | 2011-07-27 05:28:18 +0000 | [diff] [blame] | 77 | |
| 78 | @implementation Foo2 |
| 79 | |
| 80 | static id internal_var = 0; |
| 81 | |
| 82 | + (void)setIt:(id)newone { |
| 83 | if (internal_var != newone) { |
| 84 | internal_var = newone; |
| 85 | } |
| 86 | } |
| 87 | @end |