xref: /minix/external/bsd/llvm/dist/clang/test/ARCMT/GC.m (revision 4684ddb6)
1// 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
3// RUN: diff %t %s.result
4// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -x objective-c++ %s > %t
5// RUN: diff %t %s.result
6// DISABLE: mingw32
7
8#include "Common.h"
9#include "GC.h"
10
11void test1(CFTypeRef *cft) {
12  id x = NSMakeCollectable(cft);
13}
14
15@interface I1
16@end
17
18@implementation I1
19-(void)dealloc {
20  // dealloc
21  test1(0);
22}
23
24-(void)finalize {
25  // finalize
26  test1(0);
27}
28@end
29
30@interface I2
31@property (retain) id prop;
32@end
33
34@implementation I2
35@synthesize prop;
36
37-(void)finalize {
38  self.prop = 0;
39  // finalize
40  test1(0);
41}
42@end
43
44__attribute__((objc_arc_weak_reference_unavailable))
45@interface QQ {
46  __weak id s;
47  __weak QQ *q;
48}
49@end
50
51@interface I3
52@property (assign) I3 *__weak pw1, *__weak pw2;
53@property (assign) I3 *__strong ps;
54@property (assign) I3 * pds;
55@end
56
57@interface I4Impl {
58  I4Impl *pds2;
59  I4Impl *pds3;
60  __weak I4Impl *pw3;
61  __weak I4Impl *pw4;
62}
63@property (assign) I4Impl *__weak pw1, *__weak pw2;
64@property (assign) I4Impl *__strong ps;
65@property (assign) I4Impl * pds;
66@property (assign) I4Impl * pds2;
67@property (readwrite) I4Impl * pds3;
68@property (readonly) I4Impl * pds4;
69@property (readonly) __weak I4Impl *pw3;
70@property (assign) __weak I4Impl *pw4;
71@end
72
73@implementation I4Impl
74@synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4;
75
76-(void)test1:(CFTypeRef *)cft {
77  id x = NSMakeCollectable(cft);
78}
79@end
80
81// rdar://10532449
82@interface rdar10532449
83@property (assign) id assign_prop;
84@property (assign, readonly) id __strong strong_readonly_prop;
85@property (assign) id __weak weak_prop;
86@end
87
88@implementation rdar10532449
89@synthesize assign_prop, strong_readonly_prop, weak_prop;
90@end
91
92void test2(id p, __strong I1 *ap[]) {
93  for (__strong I1 *specRule in p) {
94  }
95}
96