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
25struct UnsafeS {
26  A *__unsafe_unretained unsafeObj;
27};
28
29id global_foo;
30
31void 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
39// RUN: c-index-test -read-diagnostics %t.diag > %t 2>&1
40// RUN: FileCheck --input-file=%t %s
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
43// CHECK-NEXT: Number FIXITs = 0
44// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:34:4: error: [rewriter] it is not safe to remove 'retain' message on a global variable
45// CHECK-NEXT: Number FIXITs = 0
46// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:32:23: error: ARC forbids explicit message send of 'retain'
47// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:32:4 {{.*}}check-with-serialized-diag.m:32:22
48// CHECK-NEXT: Number FIXITs = 0
49// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:34:15: error: ARC forbids explicit message send of 'retain'
50// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:34:4 {{.*}}check-with-serialized-diag.m:34:14
51// CHECK-NEXT: Number FIXITs = 0
52// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:35:6: error: ARC forbids explicit message send of 'retainCount'
53// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:35:4 {{.*}}check-with-serialized-diag.m:35:5
54// CHECK-NEXT: Number FIXITs = 0
55
56