2012-06-20 14:18:46 +08:00
|
|
|
// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fsyntax-only -verify -Wno-objc-root-class %s
|
2008-04-22 05:05:54 +08:00
|
|
|
|
|
|
|
@interface I
|
|
|
|
{
|
2012-09-25 06:00:36 +08:00
|
|
|
int IVAR; // expected-note{{instance variable is declared here}}
|
2008-04-22 05:57:36 +08:00
|
|
|
int name;
|
2008-04-22 05:05:54 +08:00
|
|
|
}
|
|
|
|
@property int d1;
|
2018-04-17 12:25:18 +08:00
|
|
|
@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 object}}
|
2008-04-22 05:57:36 +08:00
|
|
|
@property int name;
|
2008-04-22 05:05:54 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@interface I(CAT)
|
2013-04-25 01:06:38 +08:00
|
|
|
@property int d1;
|
2008-04-22 05:05:54 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation I
|
2008-04-22 05:57:36 +08:00
|
|
|
@synthesize d1; // expected-error {{synthesized property 'd1' must either be named the same as}}
|
|
|
|
@dynamic bad; // expected-error {{property implementation must have its declaration in interface 'I'}}
|
2009-04-15 07:15:21 +08:00
|
|
|
@synthesize prop_id; // expected-error {{synthesized property 'prop_id' must either be named the same}} // expected-note {{previous declaration is here}}
|
2012-09-25 06:00:36 +08:00
|
|
|
@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}}
|
2008-04-22 05:57:36 +08:00
|
|
|
@synthesize name; // OK! property with same name as an accessible ivar of same name
|
2008-04-22 05:05:54 +08:00
|
|
|
@end
|
|
|
|
|
2013-04-25 01:06:38 +08:00
|
|
|
@implementation I(CAT)
|
2008-04-22 05:05:54 +08:00
|
|
|
@synthesize d1; // expected-error {{@synthesize not allowed in a category's implementation}}
|
|
|
|
@dynamic bad; // expected-error {{property implementation must have its declaration in the category 'CAT'}}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation E // expected-warning {{cannot find interface declaration for 'E'}}
|
2008-04-22 05:57:36 +08:00
|
|
|
@dynamic d; // expected-error {{property implementation must have its declaration in interface 'E'}}
|
2008-04-22 05:05:54 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation Q(MYCAT) // expected-error {{cannot find interface declaration for 'Q'}}
|
|
|
|
@dynamic d; // expected-error {{property implementation in a category with no category declaration}}
|
|
|
|
@end
|
|
|
|
|
2008-09-29 22:20:56 +08:00
|
|
|
@interface Foo
|
|
|
|
@property double bar;
|
|
|
|
@end
|
2008-04-22 05:05:54 +08:00
|
|
|
|
2009-04-13 07:51:02 +08:00
|
|
|
int func1() {
|
2008-09-29 22:20:56 +08:00
|
|
|
id foo;
|
|
|
|
double bar = [foo bar];
|
|
|
|
return 0;
|
|
|
|
}
|
2008-04-22 05:05:54 +08:00
|
|
|
|
2009-04-13 07:51:02 +08:00
|
|
|
// PR3932
|
|
|
|
typedef id BYObjectIdentifier;
|
|
|
|
@interface Foo1 {
|
|
|
|
void *isa;
|
|
|
|
}
|
|
|
|
@property(copy) BYObjectIdentifier identifier;
|
|
|
|
@end
|
|
|
|
|
2009-12-17 08:49:09 +08:00
|
|
|
@interface Foo2
|
|
|
|
{
|
|
|
|
int ivar;
|
|
|
|
}
|
|
|
|
@property int treeController; // expected-note {{property declared here}}
|
|
|
|
@property int ivar; // OK
|
|
|
|
@property int treeController; // expected-error {{property has a previous declaration}}
|
|
|
|
@end
|
|
|
|
|
2011-09-18 02:48:50 +08:00
|
|
|
// rdar://10127639
|
|
|
|
@synthesize window; // expected-error {{missing context for property implementation declaration}}
|
2011-11-08 06:49:50 +08:00
|
|
|
|
|
|
|
// rdar://10408414
|
|
|
|
Class test6_getClass();
|
|
|
|
@interface Test6
|
|
|
|
@end
|
|
|
|
@implementation Test6
|
|
|
|
+ (float) globalValue { return 5.0f; }
|
|
|
|
+ (float) gv { return test6_getClass().globalValue; }
|
|
|
|
@end
|
2012-01-11 08:14:46 +08:00
|
|
|
|
|
|
|
@interface Test7
|
|
|
|
@property unsigned length;
|
|
|
|
@end
|
|
|
|
void test7(Test7 *t) {
|
|
|
|
char data[t.length] = {}; // expected-error {{variable-sized object may not be initialized}}
|
|
|
|
}
|