blob: 4d00bd2b522d99bc0f0ed8fe2a1e0d20de6edc5c [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
Fariborz Jahanianc35b9e42008-04-21 21:05:54 +00002
3@interface I
4{
Ted Kremenekf921a482010-03-23 19:02:22 +00005 int IVAR; // expected-note{{ivar is declared here}}
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)
Fariborz Jahanian3ad230e2010-01-20 19:36:21 +000014@property int d1; // expected-warning {{property 'd1' requires method 'd1' to be defined }} \
15 // expected-warning {{property 'd1' requires method 'setD1:' to be defined }}
Fariborz Jahanianc35b9e42008-04-21 21:05:54 +000016@end
17
18@implementation I
Fariborz Jahanian6cdf16d2008-04-21 21:57:36 +000019@synthesize d1; // expected-error {{synthesized property 'd1' must either be named the same as}}
20@dynamic bad; // expected-error {{property implementation must have its declaration in interface 'I'}}
Fariborz Jahanian12bac252009-04-14 23:15:21 +000021@synthesize prop_id; // expected-error {{synthesized property 'prop_id' must either be named the same}} // expected-note {{previous declaration is here}}
Ted Kremenekf921a482010-03-23 19:02:22 +000022@synthesize prop_id = IVAR; // expected-error {{type of property 'prop_id' ('id') does not match type of ivar 'IVAR' ('int')}} // expected-error {{property 'prop_id' is already implemented}}
Fariborz Jahanian6cdf16d2008-04-21 21:57:36 +000023@synthesize name; // OK! property with same name as an accessible ivar of same name
Fariborz Jahanianc35b9e42008-04-21 21:05:54 +000024@end
25
Fariborz Jahanian3ad230e2010-01-20 19:36:21 +000026@implementation I(CAT) // expected-note 2 {{implementation is here}}
Fariborz Jahanianc35b9e42008-04-21 21:05:54 +000027@synthesize d1; // expected-error {{@synthesize not allowed in a category's implementation}}
28@dynamic bad; // expected-error {{property implementation must have its declaration in the category 'CAT'}}
29@end
30
31@implementation E // expected-warning {{cannot find interface declaration for 'E'}}
Fariborz Jahanian6cdf16d2008-04-21 21:57:36 +000032@dynamic d; // expected-error {{property implementation must have its declaration in interface 'E'}}
Fariborz Jahanianc35b9e42008-04-21 21:05:54 +000033@end
34
35@implementation Q(MYCAT) // expected-error {{cannot find interface declaration for 'Q'}}
36@dynamic d; // expected-error {{property implementation in a category with no category declaration}}
37@end
38
Steve Naroff5e0a74f2008-09-29 14:20:56 +000039@interface Foo
40@property double bar;
41@end
Fariborz Jahanianc35b9e42008-04-21 21:05:54 +000042
Chris Lattner16ede0e2009-04-12 23:51:02 +000043int func1() {
Steve Naroff5e0a74f2008-09-29 14:20:56 +000044 id foo;
45 double bar = [foo bar];
46 return 0;
47}
Fariborz Jahanianc35b9e42008-04-21 21:05:54 +000048
Chris Lattner16ede0e2009-04-12 23:51:02 +000049// PR3932
50typedef id BYObjectIdentifier;
51@interface Foo1 {
52 void *isa;
53}
54@property(copy) BYObjectIdentifier identifier;
55@end
56
Fariborz Jahanian6dd30fc2009-12-17 00:49:09 +000057@interface Foo2
58{
59 int ivar;
60}
61@property int treeController; // expected-note {{property declared here}}
62@property int ivar; // OK
63@property int treeController; // expected-error {{property has a previous declaration}}
64@end
65