blob: 2c9ea9ca3324d2e074c3883a9ed8d1ee62c43f1d [file] [log] [blame]
Argyrios Kyrtzidise80d4f22011-11-07 18:40:29 +00001// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result
2// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -x objective-c %s > %t
Argyrios Kyrtzidisd208ef92011-11-04 15:58:08 +00003// RUN: diff %t %s.result
Argyrios Kyrtzidise80d4f22011-11-07 18:40:29 +00004// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -x objective-c++ %s > %t
Argyrios Kyrtzidis3eaa22a2011-11-04 15:58:13 +00005// RUN: diff %t %s.result
Argyrios Kyrtzidisd208ef92011-11-04 15:58:08 +00006
7#include "Common.h"
Argyrios Kyrtzidis0c233fa2011-11-06 18:58:17 +00008#include "GC.h"
Argyrios Kyrtzidisd208ef92011-11-04 15:58:08 +00009
10void test1(CFTypeRef *cft) {
11 id x = NSMakeCollectable(cft);
12}
Argyrios Kyrtzidisd2b91122011-11-04 15:58:22 +000013
Argyrios Kyrtzidis01c047e2012-02-25 01:57:42 +000014@interface I1
Argyrios Kyrtzidisd2b91122011-11-04 15:58:22 +000015@end
16
17@implementation I1
18-(void)dealloc {
19 // dealloc
20 test1(0);
21}
22
23-(void)finalize {
24 // finalize
25 test1(0);
26}
27@end
28
29@interface I2
30@property (retain) id prop;
31@end
32
33@implementation I2
34@synthesize prop;
35
36-(void)finalize {
37 self.prop = 0;
38 // finalize
39 test1(0);
40}
41@end
Argyrios Kyrtzidise80d4f22011-11-07 18:40:29 +000042
43__attribute__((objc_arc_weak_reference_unavailable))
44@interface QQ {
45 __weak id s;
46 __weak QQ *q;
47}
48@end
Argyrios Kyrtzidis722d21c2011-11-07 18:46:46 +000049
50@interface I3
51@property (assign) I3 *__weak pw1, *__weak pw2;
52@property (assign) I3 *__strong ps;
53@property (assign) I3 * pds;
54@end
55
56@interface I4Impl {
57 I4Impl *pds2;
Argyrios Kyrtzidisdbe077a2011-11-08 05:56:11 +000058 I4Impl *pds3;
Argyrios Kyrtzidis3fc3dcd2011-11-28 00:23:12 +000059 __weak I4Impl *pw3;
60 __weak I4Impl *pw4;
Argyrios Kyrtzidis722d21c2011-11-07 18:46:46 +000061}
62@property (assign) I4Impl *__weak pw1, *__weak pw2;
63@property (assign) I4Impl *__strong ps;
64@property (assign) I4Impl * pds;
65@property (assign) I4Impl * pds2;
Argyrios Kyrtzidisdbe077a2011-11-08 05:56:11 +000066@property (readwrite) I4Impl * pds3;
Argyrios Kyrtzidise4a38a72011-11-08 22:10:58 +000067@property (readonly) I4Impl * pds4;
Argyrios Kyrtzidis3fc3dcd2011-11-28 00:23:12 +000068@property (readonly) __weak I4Impl *pw3;
69@property (assign) __weak I4Impl *pw4;
Argyrios Kyrtzidis722d21c2011-11-07 18:46:46 +000070@end
71
72@implementation I4Impl
Argyrios Kyrtzidis3fc3dcd2011-11-28 00:23:12 +000073@synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4;
Argyrios Kyrtzidisd5697912011-11-07 18:46:50 +000074
75-(void)test1:(CFTypeRef *)cft {
76 id x = NSMakeCollectable(cft);
77}
Argyrios Kyrtzidis722d21c2011-11-07 18:46:46 +000078@end
Fariborz Jahanian1630c152012-01-21 00:43:53 +000079
80// rdar://10532449
81@interface rdar10532449
82@property (assign) id assign_prop;
83@property (assign, readonly) id __strong strong_readonly_prop;
84@property (assign) id __weak weak_prop;
85@end
86
87@implementation rdar10532449
88@synthesize assign_prop, strong_readonly_prop, weak_prop;
89@end
Argyrios Kyrtzidis01c047e2012-02-25 01:57:42 +000090
91void test2(id p, __strong I1 *ap[]) {
92 for (__strong I1 *specRule in p) {
93 }
94}