blob: a255a36f2494c7c56ae99efcaa2ed29bb29f2416 [file] [log] [blame]
John McCalld1e40d52011-10-02 01:16:38 +00001// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -x objective-c %s.result
2// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only %s > %t
John McCall8f0e8d22011-06-15 23:25:17 +00003// RUN: diff %t %s.result
Argyrios Kyrtzidisd8b42162012-01-12 02:34:32 +00004// DISABLE: mingw32
John McCall8f0e8d22011-06-15 23:25:17 +00005
6#include "Common.h"
7
Argyrios Kyrtzidis86625b52011-07-12 22:05:17 +00008__attribute__((objc_arc_weak_reference_unavailable))
9@interface WeakOptOut
10@end
11
12@class _NSCachedAttributedString;
Argyrios Kyrtzidis86625b52011-07-12 22:05:17 +000013typedef _NSCachedAttributedString *BadClassForWeak;
14
Argyrios Kyrtzidis5363e8d2011-07-12 22:16:25 +000015@class Forw;
16
John McCall8f0e8d22011-06-15 23:25:17 +000017@interface Foo : NSObject {
Argyrios Kyrtzidis8b08eb32011-11-08 23:09:34 +000018 Foo *__weak x, *__weak w, *__weak q1, *__weak q2;
Argyrios Kyrtzidis86625b52011-07-12 22:05:17 +000019 WeakOptOut *__unsafe_unretained oo;
20 BadClassForWeak __unsafe_unretained bcw;
21 id __unsafe_unretained not_safe1;
22 NSObject *__unsafe_unretained not_safe2;
Argyrios Kyrtzidis5363e8d2011-07-12 22:16:25 +000023 Forw *__unsafe_unretained not_safe3;
Argyrios Kyrtzidis18fd0c62011-07-27 05:28:18 +000024 Foo *assign_plus1;
John McCall8f0e8d22011-06-15 23:25:17 +000025}
Argyrios Kyrtzidis8b08eb32011-11-08 23:09:34 +000026@property (weak, readonly) Foo *x;
Argyrios Kyrtzidis86625b52011-07-12 22:05:17 +000027@property (weak) Foo *w;
28@property (weak) Foo *q1, *q2;
Argyrios Kyrtzidis14c4b442011-07-13 19:22:00 +000029@property (unsafe_unretained) WeakOptOut *oo;
30@property (unsafe_unretained) BadClassForWeak bcw;
31@property (unsafe_unretained) id not_safe1;
32@property (unsafe_unretained) NSObject *not_safe2;
33@property (unsafe_unretained) Forw *not_safe3;
Argyrios Kyrtzidis18fd0c62011-07-27 05:28:18 +000034@property (readonly) Foo *assign_plus1;
Argyrios Kyrtzidisaf9b5e92011-11-08 22:10:58 +000035@property (readonly) Foo *assign_plus2;
36@property (readonly) Foo *assign_plus3;
Argyrios Kyrtzidis14c4b442011-07-13 19:22:00 +000037
Argyrios Kyrtzidis96886092011-07-13 19:47:57 +000038@property (weak) Foo *no_user_ivar1;
39@property (weak, readonly) Foo *no_user_ivar2;
Argyrios Kyrtzidis01b2b9b2011-10-17 23:14:16 +000040
Fariborz Jahanian86f96012012-01-20 19:15:02 +000041@property (strong) id def1;
42@property (atomic,strong) id def2;
43@property (strong,atomic) id def3;
Argyrios Kyrtzidis01b2b9b2011-10-17 23:14:16 +000044
John McCall8f0e8d22011-06-15 23:25:17 +000045@end
46
47@implementation Foo
Argyrios Kyrtzidis14c4b442011-07-13 19:22:00 +000048@synthesize x,w,q1,q2,oo,bcw,not_safe1,not_safe2,not_safe3;
Argyrios Kyrtzidis96886092011-07-13 19:47:57 +000049@synthesize no_user_ivar1, no_user_ivar2;
Argyrios Kyrtzidis94a90162011-08-10 21:46:48 +000050@synthesize assign_plus1, assign_plus2, assign_plus3;
Argyrios Kyrtzidis01b2b9b2011-10-17 23:14:16 +000051@synthesize def1, def2, def3;
Argyrios Kyrtzidis18fd0c62011-07-27 05:28:18 +000052
Argyrios Kyrtzidis94a90162011-08-10 21:46:48 +000053-(void)test:(Foo *)parm {
Argyrios Kyrtzidis18fd0c62011-07-27 05:28:18 +000054 assign_plus1 = [[Foo alloc] init];
55 assign_plus2 = [Foo new];
Argyrios Kyrtzidis94a90162011-08-10 21:46:48 +000056 assign_plus3 = parm;
Argyrios Kyrtzidis18fd0c62011-07-27 05:28:18 +000057}
John McCall8f0e8d22011-06-15 23:25:17 +000058@end
Argyrios Kyrtzidis44679012011-10-18 19:49:19 +000059
60@interface TestExt
Fariborz Jahanian86f96012012-01-20 19:15:02 +000061@property (strong,readonly) TestExt *x1;
Argyrios Kyrtzidis44679012011-10-18 19:49:19 +000062@property (weak, readonly) TestExt *x2;
63@end
64
65@interface TestExt()
Fariborz Jahanian86f96012012-01-20 19:15:02 +000066@property (strong,readwrite) TestExt *x1;
Argyrios Kyrtzidis44679012011-10-18 19:49:19 +000067@property (weak, readwrite) TestExt *x2;
Argyrios Kyrtzidis0fd4a682012-03-29 01:10:31 +000068@property (strong) TestExt *x3;
Argyrios Kyrtzidis44679012011-10-18 19:49:19 +000069@end
70
71@implementation TestExt
Argyrios Kyrtzidis0fd4a682012-03-29 01:10:31 +000072@synthesize x1, x2, x3;
Argyrios Kyrtzidis44679012011-10-18 19:49:19 +000073@end