1// RUN: %clang_cc1 -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result
2// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-gc-only -x objective-c %s > %t
3// RUN: diff %t %s.result
4// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-gc-only -x objective-c++ %s > %t
5// RUN: diff %t %s.result
6
7// MRC __weak broke this test somehow.
8// XFAIL: *
9
10#include "Common.h"
11#include "GC.h"
12
13void test1(CFTypeRef *cft) {
14  id x = NSMakeCollectable(cft);
15}
16
17@interface I1
18@end
19
20@implementation I1
21-(void)dealloc {
22  // dealloc
23  test1(0);
24}
25
26-(void)finalize {
27  // finalize
28  test1(0);
29}
30@end
31
32@interface I2
33@property (retain) id prop;
34@end
35
36@implementation I2
37@synthesize prop;
38
39-(void)finalize {
40  self.prop = 0;
41  // finalize
42  test1(0);
43}
44@end
45
46__attribute__((objc_arc_weak_reference_unavailable))
47@interface QQ {
48  __weak id s;
49  __weak QQ *q;
50}
51@end
52
53@interface I3
54@property (assign) I3 *__weak pw1, *__weak pw2;
55@property (assign) I3 *__strong ps;
56@property (assign) I3 * pds;
57@end
58
59@interface I4Impl {
60  I4Impl *pds2;
61}
62@property (assign) I4Impl *__weak pw1, *__weak pw2;
63@property (assign) I4Impl *__strong ps;
64@property (assign) I4Impl * pds;
65@property (assign) I4Impl * pds2;
66@end
67
68@implementation I4Impl
69@synthesize pw1, pw2, ps, pds, pds2;
70
71-(void)test1:(CFTypeRef *)cft {
72  id x = NSMakeCollectable(cft);
73}
74@end
75
76@interface I5 {
77  __weak id prop;
78}
79@property (readonly) __weak id prop;
80@end
81