205 lines · plain
1// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s2 3@interface Foo {4@public5 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@end13 14@implementation Foo15@synthesize x; // expected-note {{property synthesized here}}16@synthesize y; // expected-note {{property synthesized here}}17@synthesize z; // suppressed18@end19 20@interface Bar {21@public22 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@end30 31@implementation Bar32@synthesize x; // expected-note {{property synthesized here}}33@synthesize y; // expected-note {{property synthesized here}}34@synthesize z; // suppressed35@end36 37@interface Bas {38@public39 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@end47 48@implementation Bas49@synthesize x; // expected-note {{property synthesized here}}50@synthesize y; // expected-note {{property synthesized here}}51@synthesize z; // suppressed52@end53 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@end58 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@end63 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@end68 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@end77 78@implementation Gorf79@synthesize x;80@synthesize y; // expected-note {{property synthesized here}}81@synthesize z;82@end83 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@end92 93@implementation Gorf294@synthesize x;95@synthesize y; // expected-note {{property synthesized here}}96@synthesize z;97@end98 99@interface I {100 char _isAutosaving;101}102@property char isAutosaving;103 104@end105 106@implementation I107@synthesize isAutosaving = _isAutosaving;108@end109 110// Test for 'Class' properties being unretained.111@interface MyClass {112@private113 Class _controllerClass;114 id _controllerId;115}116@property (copy) Class controllerClass;117@property (copy) id controllerId;118@end119 120@implementation MyClass121@synthesize controllerClass = _controllerClass;122@synthesize controllerId = _controllerId;123@end124 125@interface UIView @end126@class UIColor;127 128@interface UIView(UIViewRendering)129@property(nonatomic,copy) UIColor *backgroundColor;130@end131 132@interface UILabel : UIView133@end134 135@interface MyView 136@property (strong) UILabel *label;137@end138 139@interface MyView2 : MyView @end140 141@implementation MyView2142- (void)foo {143 super.label.backgroundColor = 0;144}145@end146 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@end157 158void 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@end174 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@end180 181@implementation Foo2182@end183 184@interface NSObject 185-(id)init;186@end187 188typedef char BOOL;189@interface Test13885083 : NSObject190 191@property (nonatomic, assign) BOOL retain; // expected-error {{ARC forbids synthesis of 'retain'}}192 193-(id)init;194 195@end196 197@implementation Test13885083198-(id) init199{200 self = [super init];201 return self;202}203@end204 205