blob: c357eeb1717740ecac583dc2cac4ab2d2d5a7b23 [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 *x, *w, *q1, *q2;
Argyrios Kyrtzidis86625b52011-07-12 22:05:17 +000019 WeakOptOut *oo;
20 BadClassForWeak bcw;
21 id not_safe1;
22 NSObject *not_safe2;
Argyrios Kyrtzidis5363e8d2011-07-12 22:16:25 +000023 Forw *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 (readonly) Foo *x;
Argyrios Kyrtzidis86625b52011-07-12 22:05:17 +000027@property (assign) Foo *w;
Argyrios Kyrtzidis14c4b442011-07-13 19:22:00 +000028@property Foo *q1, *q2;
Argyrios Kyrtzidis86625b52011-07-12 22:05:17 +000029@property (assign) WeakOptOut *oo;
30@property (assign) BadClassForWeak bcw;
31@property (assign) id not_safe1;
Argyrios Kyrtzidis14c4b442011-07-13 19:22:00 +000032@property () NSObject *not_safe2;
33@property Forw *not_safe3;
Argyrios Kyrtzidis18fd0c62011-07-27 05:28:18 +000034@property (readonly) Foo *assign_plus1;
35@property (readonly) Foo *assign_plus2;
Argyrios Kyrtzidis94a90162011-08-10 21:46:48 +000036@property (readonly) Foo *assign_plus3;
Argyrios Kyrtzidis14c4b442011-07-13 19:22:00 +000037
Argyrios Kyrtzidis96886092011-07-13 19:47:57 +000038@property (assign) Foo *no_user_ivar1;
39@property (readonly) Foo *no_user_ivar2;
Argyrios Kyrtzidis01b2b9b2011-10-17 23:14:16 +000040
41@property (retain) id def1;
42@property (atomic,retain) id def2;
43@property (retain,atomic) id def3;
44
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 retain];
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
61@property (retain,readonly) TestExt *x1;
62@property (readonly) TestExt *x2;
63@end
64
65@interface TestExt()
66@property (retain,readwrite) TestExt *x1;
67@property (readwrite) TestExt *x2;
Argyrios Kyrtzidis0fd4a682012-03-29 01:10:31 +000068@property (retain) 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