Argyrios Kyrtzidis | 29f2787 | 2011-12-07 05:52:12 +0000 | [diff] [blame] | 1 | |
| 2 | @protocol NSObject |
| 3 | - (id)retain; |
| 4 | - (unsigned)retainCount; |
| 5 | - (oneway void)release; |
| 6 | - (id)autorelease; |
| 7 | @end |
| 8 | |
| 9 | @interface NSObject <NSObject> {} |
| 10 | - (id)init; |
| 11 | |
| 12 | + (id)new; |
| 13 | + (id)alloc; |
| 14 | - (void)dealloc; |
| 15 | |
| 16 | - (void)finalize; |
| 17 | |
| 18 | - (id)copy; |
| 19 | - (id)mutableCopy; |
| 20 | @end |
| 21 | |
| 22 | @interface A : NSObject |
| 23 | @end |
| 24 | |
| 25 | struct UnsafeS { |
| 26 | A *__unsafe_unretained unsafeObj; |
| 27 | }; |
| 28 | |
| 29 | id global_foo; |
| 30 | |
| 31 | void test1(A *a, struct UnsafeS *unsafeS) { |
| 32 | [unsafeS->unsafeObj retain]; |
| 33 | id foo = [unsafeS->unsafeObj retain]; // no warning. |
| 34 | [global_foo retain]; |
| 35 | [a retainCount]; |
| 36 | } |
| 37 | |
| 38 | // RUN: not %clang_cc1 -arcmt-check -triple x86_64-apple-darwin10 %s -serialize-diagnostic-file %t.diag |
Ted Kremenek | 3739b32 | 2012-03-20 20:49:45 +0000 | [diff] [blame] | 39 | // RUN: c-index-test -read-diagnostics %t.diag > %t 2>&1 |
| 40 | // RUN: FileCheck --input-file=%t %s |
Argyrios Kyrtzidis | 29f2787 | 2011-12-07 05:52:12 +0000 | [diff] [blame] | 41 | |
| 42 | // CHECK: {{.*}}check-with-serialized-diag.m:32:4: error: [rewriter] it is not safe to remove 'retain' message on an __unsafe_unretained type |
Ted Kremenek | 3739b32 | 2012-03-20 20:49:45 +0000 | [diff] [blame] | 43 | // CHECK-NEXT: Number FIXITs = 0 |
Argyrios Kyrtzidis | 29f2787 | 2011-12-07 05:52:12 +0000 | [diff] [blame] | 44 | // CHECK-NEXT: {{.*}}check-with-serialized-diag.m:34:4: error: [rewriter] it is not safe to remove 'retain' message on a global variable |
Ted Kremenek | 3739b32 | 2012-03-20 20:49:45 +0000 | [diff] [blame] | 45 | // CHECK-NEXT: Number FIXITs = 0 |
Argyrios Kyrtzidis | 29f2787 | 2011-12-07 05:52:12 +0000 | [diff] [blame] | 46 | // CHECK-NEXT: {{.*}}check-with-serialized-diag.m:32:4: error: ARC forbids explicit message send of 'retain' |
| 47 | // CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:32:23 {{.*}}check-with-serialized-diag.m:32:29 |
Ted Kremenek | 3739b32 | 2012-03-20 20:49:45 +0000 | [diff] [blame] | 48 | // CHECK-NEXT: Number FIXITs = 0 |
Argyrios Kyrtzidis | 29f2787 | 2011-12-07 05:52:12 +0000 | [diff] [blame] | 49 | // CHECK-NEXT: {{.*}}check-with-serialized-diag.m:34:4: error: ARC forbids explicit message send of 'retain' |
| 50 | // CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:34:15 {{.*}}check-with-serialized-diag.m:34:21 |
Ted Kremenek | 3739b32 | 2012-03-20 20:49:45 +0000 | [diff] [blame] | 51 | // CHECK-NEXT: Number FIXITs = 0 |
Argyrios Kyrtzidis | 29f2787 | 2011-12-07 05:52:12 +0000 | [diff] [blame] | 52 | // CHECK-NEXT: {{.*}}check-with-serialized-diag.m:35:4: error: ARC forbids explicit message send of 'retainCount' |
| 53 | // CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:35:6 {{.*}}check-with-serialized-diag.m:35:17 |
Ted Kremenek | 3739b32 | 2012-03-20 20:49:45 +0000 | [diff] [blame] | 54 | // CHECK-NEXT: Number FIXITs = 0 |
| 55 | |