blob: 2c27a518dd7d0e6b441320a69496f21d2204ded8 [file] [log] [blame]
John McCalld1e40d52011-10-02 01:16:38 +00001// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify %s
John McCallf85e1932011-06-15 23:02:42 +00002// rdar://9340606
3
4@interface Foo {
5@public
6 id __unsafe_unretained x;
7 id __weak y;
Argyrios Kyrtzidisb8b03132011-06-24 00:08:59 +00008 id __autoreleasing z; // expected-error {{ivars cannot have __autoreleasing ownership}}
John McCallf85e1932011-06-15 23:02:42 +00009}
10@property(strong) id x; // expected-note {{property declared here}}
11@property(strong) id y; // expected-note {{property declared here}}
12@property(strong) id z;
13@end
14
15@implementation Foo
16@synthesize x; // expected-error {{existing ivar 'x' for strong property 'x' may not be __unsafe_unretained}}
17@synthesize y; // expected-error {{existing ivar 'y' for strong property 'y' may not be __weak}}
18@synthesize z; // suppressed
19@end
20
21@interface Bar {
22@public
23 id __unsafe_unretained x;
24 id __weak y;
Argyrios Kyrtzidisb8b03132011-06-24 00:08:59 +000025 id __autoreleasing z; // expected-error {{ivars cannot have __autoreleasing ownership}}
John McCallf85e1932011-06-15 23:02:42 +000026}
27@property(retain) id x; // expected-note {{property declared here}}
28@property(retain) id y; // expected-note {{property declared here}}
29@property(retain) id z;
30@end
31
32@implementation Bar
33@synthesize x; // expected-error {{existing ivar 'x' for strong property 'x' may not be __unsafe_unretained}}
34@synthesize y; // expected-error {{existing ivar 'y' for strong property 'y' may not be __weak}}
35@synthesize z; // suppressed
36@end
37
38@interface Bas {
39@public
40 id __unsafe_unretained x;
41 id __weak y;
Argyrios Kyrtzidisb8b03132011-06-24 00:08:59 +000042 id __autoreleasing z; // expected-error {{ivars cannot have __autoreleasing ownership}}
John McCallf85e1932011-06-15 23:02:42 +000043}
44@property(copy) id x; // expected-note {{property declared here}}
45@property(copy) id y; // expected-note {{property declared here}}
46@property(copy) id z;
47@end
48
49@implementation Bas
50@synthesize x; // expected-error {{existing ivar 'x' for strong property 'x' may not be __unsafe_unretained}}
51@synthesize y; // expected-error {{existing ivar 'y' for strong property 'y' may not be __weak}}
52@synthesize z; // suppressed
53@end
54
55@interface Bat
56@property(strong) __unsafe_unretained id x; // expected-error {{strong property 'x' may not also be declared __unsafe_unretained}}
57@property(strong) __autoreleasing id z; // expected-error {{strong property 'z' may not also be declared __autoreleasing}}
58@end
59
60@interface Bau
61@property(retain) __unsafe_unretained id x; // expected-error {{strong property 'x' may not also be declared __unsafe_unretained}}
62@property(retain) __autoreleasing id z; // expected-error {{strong property 'z' may not also be declared __autoreleasing}}
63@end
64
65@interface Bav
66@property(copy) __unsafe_unretained id x; // expected-error {{strong property 'x' may not also be declared __unsafe_unretained}}
67@property(copy) __autoreleasing id z; // expected-error {{strong property 'z' may not also be declared __autoreleasing}}
68@end
69
70// rdar://9341593
71@interface Gorf {
72 id __unsafe_unretained x;
73 id y;
74}
75@property(assign) id __unsafe_unretained x;
76@property(assign) id y; // expected-note {{property declared here}}
77@property(assign) id z;
78@end
79
80@implementation Gorf
81@synthesize x;
Fariborz Jahanian94144492011-08-26 21:21:19 +000082@synthesize y; // expected-error {{existing ivar 'y' for property 'y' with assign attribute must be __unsafe_unretained}}
John McCallf85e1932011-06-15 23:02:42 +000083@synthesize z;
84@end
85
86@interface Gorf2 {
87 id __unsafe_unretained x;
88 id y;
89}
90@property(unsafe_unretained) id __unsafe_unretained x;
91@property(unsafe_unretained) id y; // expected-note {{property declared here}}
92@property(unsafe_unretained) id z;
93@end
94
95@implementation Gorf2
96@synthesize x;
Fariborz Jahanian94144492011-08-26 21:21:19 +000097@synthesize y; // expected-error {{existing ivar 'y' for property 'y' with unsafe_unretained attribute must be __unsafe_unretained}}
John McCallf85e1932011-06-15 23:02:42 +000098@synthesize z;
99@end
100
101// rdar://9355230
102@interface I {
103 char _isAutosaving;
104}
105@property char isAutosaving;
106
107@end
108
109@implementation I
110@synthesize isAutosaving = _isAutosaving;
111@end
112
Fariborz Jahanian5fa065b2011-10-13 23:45:45 +0000113// rdar://10239594
114// Test for 'Class' properties being unretained.
115@interface MyClass {
116@private
117 Class _controllerClass;
118 id _controllerId;
119}
120@property (copy) Class controllerClass;
121@property (copy) id controllerId;
122@end
123
124@implementation MyClass
125@synthesize controllerClass = _controllerClass;
126@synthesize controllerId = _controllerId;
127@end
Fariborz Jahanian6e6f93a2012-01-10 19:28:26 +0000128
129// rdar://10630891
130@interface UIView @end
131@class UIColor;
132
133@interface UIView(UIViewRendering)
134@property(nonatomic,copy) UIColor *backgroundColor;
135@end
136
137@interface UILabel : UIView
138@end
139
140@interface MyView
141@property (strong) UILabel *label;
142@end
143
144@interface MyView2 : MyView @end
145
146@implementation MyView2
147- (void)foo {
148 super.label.backgroundColor = 0;
149}
150@end
151