blob: d8073d04693176569d6c40cae9e39119cff62d7b [file] [log] [blame]
Argyrios Kyrtzidis29f27872011-12-07 05:52:12 +00001
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
Ted Kremenek3739b322012-03-20 20:49:45 +000039// RUN: c-index-test -read-diagnostics %t.diag > %t 2>&1
40// RUN: FileCheck --input-file=%t %s
Argyrios Kyrtzidis29f27872011-12-07 05:52:12 +000041
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 Kremenek3739b322012-03-20 20:49:45 +000043// CHECK-NEXT: Number FIXITs = 0
Argyrios Kyrtzidis29f27872011-12-07 05:52:12 +000044// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:34:4: error: [rewriter] it is not safe to remove 'retain' message on a global variable
Ted Kremenek3739b322012-03-20 20:49:45 +000045// CHECK-NEXT: Number FIXITs = 0
Argyrios Kyrtzidis29f27872011-12-07 05:52:12 +000046// 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 Kremenek3739b322012-03-20 20:49:45 +000048// CHECK-NEXT: Number FIXITs = 0
Argyrios Kyrtzidis29f27872011-12-07 05:52:12 +000049// 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 Kremenek3739b322012-03-20 20:49:45 +000051// CHECK-NEXT: Number FIXITs = 0
Argyrios Kyrtzidis29f27872011-12-07 05:52:12 +000052// 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 Kremenek3739b322012-03-20 20:49:45 +000054// CHECK-NEXT: Number FIXITs = 0
55