blob: 24c036b55fe1cb4ebd750c73197390383893d2a0 [file] [log] [blame]
Fariborz Jahanianc35b9e42008-04-21 21:05:54 +00001// RUN: clang -fsyntax-only -verify %s
2
3@interface I
4{
5 int IVAR;
Fariborz Jahanian6cdf16d2008-04-21 21:57:36 +00006 int name;
Fariborz Jahanianc35b9e42008-04-21 21:05:54 +00007}
8@property int d1;
Daniel Dunbar95e61fb2008-09-23 21:53:23 +00009@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}}
Fariborz Jahanian6cdf16d2008-04-21 21:57:36 +000010@property int name;
Fariborz Jahanianc35b9e42008-04-21 21:05:54 +000011@end
12
13@interface I(CAT)
14@property int d1;
15@end
16
17@implementation I
Fariborz Jahanian6cdf16d2008-04-21 21:57:36 +000018@synthesize d1; // expected-error {{synthesized property 'd1' must either be named the same as}}
19@dynamic bad; // expected-error {{property implementation must have its declaration in interface 'I'}}
20@synthesize prop_id; // expected-error {{synthesized property 'prop_id' must either be named the same}}
Chris Lattnerd9d22dd2008-11-24 05:29:24 +000021@synthesize prop_id = IVAR; // expected-error {{type of property 'prop_id' does not match type of ivar 'IVAR'}}
Fariborz Jahanian6cdf16d2008-04-21 21:57:36 +000022@synthesize name; // OK! property with same name as an accessible ivar of same name
Fariborz Jahanianc35b9e42008-04-21 21:05:54 +000023@end
24
Fariborz Jahanian804058e2008-12-22 19:05:31 +000025@implementation I(CAT)
Fariborz Jahanianc35b9e42008-04-21 21:05:54 +000026@synthesize d1; // expected-error {{@synthesize not allowed in a category's implementation}}
27@dynamic bad; // expected-error {{property implementation must have its declaration in the category 'CAT'}}
28@end
29
30@implementation E // expected-warning {{cannot find interface declaration for 'E'}}
Fariborz Jahanian6cdf16d2008-04-21 21:57:36 +000031@dynamic d; // expected-error {{property implementation must have its declaration in interface 'E'}}
Fariborz Jahanianc35b9e42008-04-21 21:05:54 +000032@end
33
34@implementation Q(MYCAT) // expected-error {{cannot find interface declaration for 'Q'}}
35@dynamic d; // expected-error {{property implementation in a category with no category declaration}}
36@end
37
Steve Naroff5e0a74f2008-09-29 14:20:56 +000038@interface Foo
39@property double bar;
40@end
Fariborz Jahanianc35b9e42008-04-21 21:05:54 +000041
Steve Naroff5e0a74f2008-09-29 14:20:56 +000042int main() {
43 id foo;
44 double bar = [foo bar];
45 return 0;
46}
Fariborz Jahanianc35b9e42008-04-21 21:05:54 +000047