annotate clang/test/SemaObjC/property.m @ 180:680fa57a2f20

fix compile errors.
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 30 May 2020 17:44:06 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fsyntax-only -verify -Wno-objc-root-class %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 @interface I
anatofuz
parents:
diff changeset
4 {
anatofuz
parents:
diff changeset
5 int IVAR; // expected-note{{instance variable is declared here}}
anatofuz
parents:
diff changeset
6 int name;
anatofuz
parents:
diff changeset
7 }
anatofuz
parents:
diff changeset
8 @property int d1;
anatofuz
parents:
diff changeset
9 @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}}
anatofuz
parents:
diff changeset
10 @property int name;
anatofuz
parents:
diff changeset
11 @end
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 @interface I(CAT)
anatofuz
parents:
diff changeset
14 @property int d1;
anatofuz
parents:
diff changeset
15 @end
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 @implementation I
anatofuz
parents:
diff changeset
18 @synthesize d1; // expected-error {{synthesized property 'd1' must either be named the same as}}
anatofuz
parents:
diff changeset
19 @dynamic bad; // expected-error {{property implementation must have its declaration in interface 'I'}}
anatofuz
parents:
diff changeset
20 @synthesize prop_id; // expected-error {{synthesized property 'prop_id' must either be named the same}} // expected-note {{previous declaration is here}}
anatofuz
parents:
diff changeset
21 @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}}
anatofuz
parents:
diff changeset
22 @synthesize name; // OK! property with same name as an accessible ivar of same name
anatofuz
parents:
diff changeset
23 @end
anatofuz
parents:
diff changeset
24
anatofuz
parents:
diff changeset
25 @implementation I(CAT)
anatofuz
parents:
diff changeset
26 @synthesize d1; // expected-error {{@synthesize not allowed in a category's implementation}}
anatofuz
parents:
diff changeset
27 @dynamic bad; // expected-error {{property implementation must have its declaration in the category 'CAT'}}
anatofuz
parents:
diff changeset
28 @end
anatofuz
parents:
diff changeset
29
anatofuz
parents:
diff changeset
30 @implementation E // expected-warning {{cannot find interface declaration for 'E'}}
anatofuz
parents:
diff changeset
31 @dynamic d; // expected-error {{property implementation must have its declaration in interface 'E'}}
anatofuz
parents:
diff changeset
32 @end
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 @implementation Q(MYCAT) // expected-error {{cannot find interface declaration for 'Q'}}
anatofuz
parents:
diff changeset
35 @dynamic d; // expected-error {{property implementation in a category with no category declaration}}
anatofuz
parents:
diff changeset
36 @end
anatofuz
parents:
diff changeset
37
anatofuz
parents:
diff changeset
38 @interface Foo
anatofuz
parents:
diff changeset
39 @property double bar;
anatofuz
parents:
diff changeset
40 @end
anatofuz
parents:
diff changeset
41
anatofuz
parents:
diff changeset
42 int func1() {
anatofuz
parents:
diff changeset
43 id foo;
anatofuz
parents:
diff changeset
44 double bar = [foo bar];
anatofuz
parents:
diff changeset
45 return 0;
anatofuz
parents:
diff changeset
46 }
anatofuz
parents:
diff changeset
47
anatofuz
parents:
diff changeset
48 // PR3932
anatofuz
parents:
diff changeset
49 typedef id BYObjectIdentifier;
anatofuz
parents:
diff changeset
50 @interface Foo1 {
anatofuz
parents:
diff changeset
51 void *isa;
anatofuz
parents:
diff changeset
52 }
anatofuz
parents:
diff changeset
53 @property(copy) BYObjectIdentifier identifier;
anatofuz
parents:
diff changeset
54 @end
anatofuz
parents:
diff changeset
55
anatofuz
parents:
diff changeset
56 @interface Foo2
anatofuz
parents:
diff changeset
57 {
anatofuz
parents:
diff changeset
58 int ivar;
anatofuz
parents:
diff changeset
59 }
anatofuz
parents:
diff changeset
60 @property int treeController; // expected-note {{property declared here}}
anatofuz
parents:
diff changeset
61 @property int ivar; // OK
anatofuz
parents:
diff changeset
62 @property int treeController; // expected-error {{property has a previous declaration}}
anatofuz
parents:
diff changeset
63 @end
anatofuz
parents:
diff changeset
64
anatofuz
parents:
diff changeset
65 // rdar://10127639
anatofuz
parents:
diff changeset
66 @synthesize window; // expected-error {{missing context for property implementation declaration}}
anatofuz
parents:
diff changeset
67
anatofuz
parents:
diff changeset
68 // rdar://10408414
anatofuz
parents:
diff changeset
69 Class test6_getClass();
anatofuz
parents:
diff changeset
70 @interface Test6
anatofuz
parents:
diff changeset
71 @end
anatofuz
parents:
diff changeset
72 @implementation Test6
anatofuz
parents:
diff changeset
73 + (float) globalValue { return 5.0f; }
anatofuz
parents:
diff changeset
74 + (float) gv { return test6_getClass().globalValue; }
anatofuz
parents:
diff changeset
75 @end
anatofuz
parents:
diff changeset
76
anatofuz
parents:
diff changeset
77 @interface Test7
anatofuz
parents:
diff changeset
78 @property unsigned length;
anatofuz
parents:
diff changeset
79 @end
anatofuz
parents:
diff changeset
80 void test7(Test7 *t) {
anatofuz
parents:
diff changeset
81 char data[t.length] = {}; // expected-error {{variable-sized object may not be initialized}}
anatofuz
parents:
diff changeset
82 }