| 1 |
// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s |
| 2 |
|
| 3 |
@interface Foo { |
| 4 |
@public |
| 5 |
id __unsafe_unretained x; // expected-error {{existing instance variable 'x' for strong property 'x' may not be __unsafe_unretained}} |
| 6 |
id __weak y; // expected-error {{existing instance variable 'y' for strong property 'y' may not be __weak}} |
| 7 |
id __autoreleasing z; // expected-error {{instance variables cannot have __autoreleasing ownership}} |
| 8 |
} |
| 9 |
@property(strong) id x; // expected-note {{property declared here}} |
| 10 |
@property(strong) id y; // expected-note {{property declared here}} |
| 11 |
@property(strong) id z; |
| 12 |
@end |
| 13 |
|
| 14 |
@implementation Foo |
| 15 |
@synthesize x; // expected-note {{property synthesized here}} |
| 16 |
@synthesize y; // expected-note {{property synthesized here}} |
| 17 |
@synthesize z; // suppressed |
| 18 |
@end |
| 19 |
|
| 20 |
@interface Bar { |
| 21 |
@public |
| 22 |
id __unsafe_unretained x; // expected-error {{existing instance variable 'x' for strong property 'x' may not be __unsafe_unretained}} |
| 23 |
id __weak y; // expected-error {{existing instance variable 'y' for strong property 'y' may not be __weak}} |
| 24 |
id __autoreleasing z; // expected-error {{instance variables cannot have __autoreleasing ownership}} |
| 25 |
} |
| 26 |
@property(retain) id x; // expected-note {{property declared here}} |
| 27 |
@property(retain) id y; // expected-note {{property declared here}} |
| 28 |
@property(retain) id z; |
| 29 |
@end |
| 30 |
|
| 31 |
@implementation Bar |
| 32 |
@synthesize x; // expected-note {{property synthesized here}} |
| 33 |
@synthesize y; // expected-note {{property synthesized here}} |
| 34 |
@synthesize z; // suppressed |
| 35 |
@end |
| 36 |
|
| 37 |
@interface Bas { |
| 38 |
@public |
| 39 |
id __unsafe_unretained x; // expected-error {{existing instance variable 'x' for strong property 'x' may not be __unsafe_unretained}} |
| 40 |
id __weak y; // expected-error {{existing instance variable 'y' for strong property 'y' may not be __weak}} |
| 41 |
id __autoreleasing z; // expected-error {{instance variables cannot have __autoreleasing ownership}} |
| 42 |
} |
| 43 |
@property(copy) id x; // expected-note {{property declared here}} |
| 44 |
@property(copy) id y; // expected-note {{property declared here}} |
| 45 |
@property(copy) id z; |
| 46 |
@end |
| 47 |
|
| 48 |
@implementation Bas |
| 49 |
@synthesize x; // expected-note {{property synthesized here}} |
| 50 |
@synthesize y; // expected-note {{property synthesized here}} |
| 51 |
@synthesize z; // suppressed |
| 52 |
@end |
| 53 |
|
| 54 |
@interface Bat |
| 55 |
@property(strong) __unsafe_unretained id x; // expected-error {{strong property 'x' may not also be declared __unsafe_unretained}} |
| 56 |
@property(strong) __autoreleasing id z; // expected-error {{strong property 'z' may not also be declared __autoreleasing}} |
| 57 |
@end |
| 58 |
|
| 59 |
@interface Bau |
| 60 |
@property(retain) __unsafe_unretained id x; // expected-error {{strong property 'x' may not also be declared __unsafe_unretained}} |
| 61 |
@property(retain) __autoreleasing id z; // expected-error {{strong property 'z' may not also be declared __autoreleasing}} |
| 62 |
@end |
| 63 |
|
| 64 |
@interface Bav |
| 65 |
@property(copy) __unsafe_unretained id x; // expected-error {{strong property 'x' may not also be declared __unsafe_unretained}} |
| 66 |
@property(copy) __autoreleasing id z; // expected-error {{strong property 'z' may not also be declared __autoreleasing}} |
| 67 |
@end |
| 68 |
|
| 69 |
@interface Gorf { |
| 70 |
id __unsafe_unretained x; |
| 71 |
id y; // expected-error {{existing instance variable 'y' for property 'y' with assign attribute must be __unsafe_unretained}} |
| 72 |
} |
| 73 |
@property(assign) id __unsafe_unretained x; |
| 74 |
@property(assign) id y; // expected-note {{property declared here}} |
| 75 |
@property(assign) id z; |
| 76 |
@end |
| 77 |
|
| 78 |
@implementation Gorf |
| 79 |
@synthesize x; |
| 80 |
@synthesize y; // expected-note {{property synthesized here}} |
| 81 |
@synthesize z; |
| 82 |
@end |
| 83 |
|
| 84 |
@interface Gorf2 { |
| 85 |
id __unsafe_unretained x; |
| 86 |
id y; // expected-error {{existing instance variable 'y' for property 'y' with unsafe_unretained attribute must be __unsafe_unretained}} |
| 87 |
} |
| 88 |
@property(unsafe_unretained) id __unsafe_unretained x; |
| 89 |
@property(unsafe_unretained) id y; // expected-note {{property declared here}} |
| 90 |
@property(unsafe_unretained) id z; |
| 91 |
@end |
| 92 |
|
| 93 |
@implementation Gorf2 |
| 94 |
@synthesize x; |
| 95 |
@synthesize y; // expected-note {{property synthesized here}} |
| 96 |
@synthesize z; |
| 97 |
@end |
| 98 |
|
| 99 |
@interface I { |
| 100 |
char _isAutosaving; |
| 101 |
} |
| 102 |
@property char isAutosaving; |
| 103 |
|
| 104 |
@end |
| 105 |
|
| 106 |
@implementation I |
| 107 |
@synthesize isAutosaving = _isAutosaving; |
| 108 |
@end |
| 109 |
|
| 110 |
// Test for 'Class' properties being unretained. |
| 111 |
@interface MyClass { |
| 112 |
@private |
| 113 |
Class _controllerClass; |
| 114 |
id _controllerId; |
| 115 |
} |
| 116 |
@property (copy) Class controllerClass; |
| 117 |
@property (copy) id controllerId; |
| 118 |
@end |
| 119 |
|
| 120 |
@implementation MyClass |
| 121 |
@synthesize controllerClass = _controllerClass; |
| 122 |
@synthesize controllerId = _controllerId; |
| 123 |
@end |
| 124 |
|
| 125 |
@interface UIView @end |
| 126 |
@class UIColor; |
| 127 |
|
| 128 |
@interface UIView(UIViewRendering) |
| 129 |
@property(nonatomic,copy) UIColor *backgroundColor; |
| 130 |
@end |
| 131 |
|
| 132 |
@interface UILabel : UIView |
| 133 |
@end |
| 134 |
|
| 135 |
@interface MyView |
| 136 |
@property (strong) UILabel *label; |
| 137 |
@end |
| 138 |
|
| 139 |
@interface MyView2 : MyView @end |
| 140 |
|
| 141 |
@implementation MyView2 |
| 142 |
- (void)foo { |
| 143 |
super.label.backgroundColor = 0; |
| 144 |
} |
| 145 |
@end |
| 146 |
|
| 147 |
@interface Baz |
| 148 |
@property id prop; |
| 149 |
@property __strong id strong_prop; |
| 150 |
@property (strong) id strong_attr_prop; |
| 151 |
@property (strong) __strong id really_strong_attr_prop; |
| 152 |
+ (id) alloc; |
| 153 |
- (id) init; |
| 154 |
- (id) implicit; |
| 155 |
- (void) setImplicit : (id) arg; |
| 156 |
@end |
| 157 |
|
| 158 |
void foo(Baz *f) { |
| 159 |
f.prop = [[Baz alloc] init]; |
| 160 |
f.strong_prop = [[Baz alloc] init]; |
| 161 |
f.strong_attr_prop = [[Baz alloc] init]; |
| 162 |
f.really_strong_attr_prop = [[Baz alloc] init]; |
| 163 |
f.implicit = [[Baz alloc] init]; |
| 164 |
} |
| 165 |
|
| 166 |
@interface Boom |
| 167 |
{ |
| 168 |
const void * innerPointerIvar __attribute__((objc_returns_inner_pointer)); // expected-error {{'objc_returns_inner_pointer' attribute only applies to Objective-C methods and Objective-C properties}} |
| 169 |
} |
| 170 |
@property (readonly) Boom * NotInnerPointer __attribute__((objc_returns_inner_pointer)); // expected-warning {{'objc_returns_inner_pointer' attribute only applies to properties that return a non-retainable pointer}} |
| 171 |
- (Boom *) NotInnerPointerMethod __attribute__((objc_returns_inner_pointer)); // expected-warning {{'objc_returns_inner_pointer' attribute only applies to methods that return a non-retainable pointer}} |
| 172 |
@property (readonly) const void * innerPointer __attribute__((objc_returns_inner_pointer)); |
| 173 |
@end |
| 174 |
|
| 175 |
@interface Foo2 { |
| 176 |
id _prop; // expected-error {{existing instance variable '_prop' for property 'prop' with assign attribute must be __unsafe_unretained}} |
| 177 |
} |
| 178 |
@property (nonatomic, assign) id prop; // expected-note {{property declared here}} |
| 179 |
@end |
| 180 |
|
| 181 |
@implementation Foo2 |
| 182 |
@end |
| 183 |
|
| 184 |
@interface NSObject |
| 185 |
-(id)init; |
| 186 |
@end |
| 187 |
|
| 188 |
typedef char BOOL; |
| 189 |
@interface Test13885083 : NSObject |
| 190 |
|
| 191 |
@property (nonatomic, assign) BOOL retain; // expected-error {{ARC forbids synthesis of 'retain'}} |
| 192 |
|
| 193 |
-(id)init; |
| 194 |
|
| 195 |
@end |
| 196 |
|
| 197 |
@implementation Test13885083 |
| 198 |
-(id) init |
| 199 |
{ |
| 200 |
self = [super init]; |
| 201 |
return self; |
| 202 |
} |
| 203 |
@end |
| 204 |
|