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