1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fsyntax-only -verify -Wno-objc-root-class %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc@interface I 4*f4a2713aSLionel Sambuc{ 5*f4a2713aSLionel Sambuc int IVAR; // expected-note{{instance variable is declared here}} 6*f4a2713aSLionel Sambuc int name; 7*f4a2713aSLionel Sambuc} 8*f4a2713aSLionel Sambuc@property int d1; 9*f4a2713aSLionel Sambuc@property id prop_id; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}}, expected-warning {{default property attribute 'assign' not appropriate for non-GC object}} 10*f4a2713aSLionel Sambuc@property int name; 11*f4a2713aSLionel Sambuc@end 12*f4a2713aSLionel Sambuc 13*f4a2713aSLionel Sambuc@interface I(CAT) 14*f4a2713aSLionel Sambuc@property int d1; 15*f4a2713aSLionel Sambuc@end 16*f4a2713aSLionel Sambuc 17*f4a2713aSLionel Sambuc@implementation I 18*f4a2713aSLionel Sambuc@synthesize d1; // expected-error {{synthesized property 'd1' must either be named the same as}} 19*f4a2713aSLionel Sambuc@dynamic bad; // expected-error {{property implementation must have its declaration in interface 'I'}} 20*f4a2713aSLionel Sambuc@synthesize prop_id; // expected-error {{synthesized property 'prop_id' must either be named the same}} // expected-note {{previous declaration is here}} 21*f4a2713aSLionel Sambuc@synthesize prop_id = IVAR; // expected-error {{type of property 'prop_id' ('id') does not match type of instance variable 'IVAR' ('int')}} // expected-error {{property 'prop_id' is already implemented}} 22*f4a2713aSLionel Sambuc@synthesize name; // OK! property with same name as an accessible ivar of same name 23*f4a2713aSLionel Sambuc@end 24*f4a2713aSLionel Sambuc 25*f4a2713aSLionel Sambuc@implementation I(CAT) 26*f4a2713aSLionel Sambuc@synthesize d1; // expected-error {{@synthesize not allowed in a category's implementation}} 27*f4a2713aSLionel Sambuc@dynamic bad; // expected-error {{property implementation must have its declaration in the category 'CAT'}} 28*f4a2713aSLionel Sambuc@end 29*f4a2713aSLionel Sambuc 30*f4a2713aSLionel Sambuc@implementation E // expected-warning {{cannot find interface declaration for 'E'}} 31*f4a2713aSLionel Sambuc@dynamic d; // expected-error {{property implementation must have its declaration in interface 'E'}} 32*f4a2713aSLionel Sambuc@end 33*f4a2713aSLionel Sambuc 34*f4a2713aSLionel Sambuc@implementation Q(MYCAT) // expected-error {{cannot find interface declaration for 'Q'}} 35*f4a2713aSLionel Sambuc@dynamic d; // expected-error {{property implementation in a category with no category declaration}} 36*f4a2713aSLionel Sambuc@end 37*f4a2713aSLionel Sambuc 38*f4a2713aSLionel Sambuc@interface Foo 39*f4a2713aSLionel Sambuc@property double bar; 40*f4a2713aSLionel Sambuc@end 41*f4a2713aSLionel Sambuc 42*f4a2713aSLionel Sambucint func1() { 43*f4a2713aSLionel Sambuc id foo; 44*f4a2713aSLionel Sambuc double bar = [foo bar]; 45*f4a2713aSLionel Sambuc return 0; 46*f4a2713aSLionel Sambuc} 47*f4a2713aSLionel Sambuc 48*f4a2713aSLionel Sambuc// PR3932 49*f4a2713aSLionel Sambuctypedef id BYObjectIdentifier; 50*f4a2713aSLionel Sambuc@interface Foo1 { 51*f4a2713aSLionel Sambuc void *isa; 52*f4a2713aSLionel Sambuc} 53*f4a2713aSLionel Sambuc@property(copy) BYObjectIdentifier identifier; 54*f4a2713aSLionel Sambuc@end 55*f4a2713aSLionel Sambuc 56*f4a2713aSLionel Sambuc@interface Foo2 57*f4a2713aSLionel Sambuc{ 58*f4a2713aSLionel Sambuc int ivar; 59*f4a2713aSLionel Sambuc} 60*f4a2713aSLionel Sambuc@property int treeController; // expected-note {{property declared here}} 61*f4a2713aSLionel Sambuc@property int ivar; // OK 62*f4a2713aSLionel Sambuc@property int treeController; // expected-error {{property has a previous declaration}} 63*f4a2713aSLionel Sambuc@end 64*f4a2713aSLionel Sambuc 65*f4a2713aSLionel Sambuc// rdar://10127639 66*f4a2713aSLionel Sambuc@synthesize window; // expected-error {{missing context for property implementation declaration}} 67*f4a2713aSLionel Sambuc 68*f4a2713aSLionel Sambuc// rdar://10408414 69*f4a2713aSLionel SambucClass test6_getClass(); 70*f4a2713aSLionel Sambuc@interface Test6 71*f4a2713aSLionel Sambuc@end 72*f4a2713aSLionel Sambuc@implementation Test6 73*f4a2713aSLionel Sambuc+ (float) globalValue { return 5.0f; } 74*f4a2713aSLionel Sambuc+ (float) gv { return test6_getClass().globalValue; } 75*f4a2713aSLionel Sambuc@end 76*f4a2713aSLionel Sambuc 77*f4a2713aSLionel Sambuc@interface Test7 78*f4a2713aSLionel Sambuc@property unsigned length; 79*f4a2713aSLionel Sambuc@end 80*f4a2713aSLionel Sambucvoid test7(Test7 *t) { 81*f4a2713aSLionel Sambuc char data[t.length] = {}; // expected-error {{variable-sized object may not be initialized}} 82*f4a2713aSLionel Sambuc} 83