blob: b2f594fe320175ff85da50d32fd8e140752e22fc [file] [log] [blame]
Fariborz Jahanian1147c5e2009-12-14 17:36:25 +00001// RUN: clang -cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
Fariborz Jahanianc35b9e42008-04-21 21:05:54 +00002
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'}}
Fariborz Jahanian12bac252009-04-14 23:15:21 +000020@synthesize prop_id; // expected-error {{synthesized property 'prop_id' must either be named the same}} // expected-note {{previous declaration is here}}
21@synthesize prop_id = IVAR; // expected-error {{type of property 'prop_id' does not match type of ivar 'IVAR'}} // expected-error {{property 'prop_id' is already implemented}}
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
Chris Lattner16ede0e2009-04-12 23:51:02 +000042int func1() {
Steve Naroff5e0a74f2008-09-29 14:20:56 +000043 id foo;
44 double bar = [foo bar];
45 return 0;
46}
Fariborz Jahanianc35b9e42008-04-21 21:05:54 +000047
Chris Lattner16ede0e2009-04-12 23:51:02 +000048// PR3932
49typedef id BYObjectIdentifier;
50@interface Foo1 {
51 void *isa;
52}
53@property(copy) BYObjectIdentifier identifier;
54@end
55