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#include "Common.h"
8#include "GC.h"
9
10void test1(CFTypeRef *cft) {
11  id x = NSMakeCollectable(cft);
12}
13
14@interface I1
15@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
42
43__attribute__((objc_arc_weak_reference_unavailable))
44@interface QQ {
45  __weak id s;
46  __weak QQ *q;
47}
48@end
49
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;
58}
59@property (assign) I4Impl *__weak pw1, *__weak pw2;
60@property (assign) I4Impl *__strong ps;
61@property (assign) I4Impl * pds;
62@property (assign) I4Impl * pds2;
63@end
64
65@implementation I4Impl
66@synthesize pw1, pw2, ps, pds, pds2;
67
68-(void)test1:(CFTypeRef *)cft {
69  id x = NSMakeCollectable(cft);
70}
71@end
72
73@interface I5 {
74  __weak id prop;
75}
76@property (readonly) __weak id prop;
77@end
78