Debian Codegraph @

clang/test/SemaObjC/synthesized-ivar.m

raw
1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2 @interface I
3 {
4 }
5 @property int IP;
6 @end
7
8 @implementation I
9 @synthesize IP;
10 - (int) Meth {
11 return IP;
12 }
13 @end
14
15 int f0(I *a) { return a->IP; } // expected-error {{instance variable 'IP' is private}}
16
17 @interface I1 {
18 int protected_ivar;
19 }
20 @property int PROP_INMAIN;
21 @end
22
23 @interface I1() {
24 int private_ivar;
25 }
26 @property int PROP_INCLASSEXT;
27 @end
28
29 @implementation I1
30 - (int) Meth {
31 _PROP_INMAIN = 1;
32 _PROP_INCLASSEXT = 2;
33 protected_ivar = 1; // OK
34 return private_ivar; // OK
35 }
36 @end
37
38
39 @interface DER : I1
40 @end
41
42 @implementation DER
43 - (int) Meth {
44 protected_ivar = 1; // OK
45 _PROP_INMAIN = 1; // expected-error {{instance variable '_PROP_INMAIN' is private}}
46 _PROP_INCLASSEXT = 2; // expected-error {{instance variable '_PROP_INCLASSEXT' is private}}
47 return private_ivar; // expected-error {{instance variable 'private_ivar' is private}}
48 }
49 @end
50
51 @interface A
52 @property (weak) id testObjectWeakProperty; // expected-note {{declared here}}
53 @end
54
55 @implementation A
56 @synthesize testObjectWeakProperty; // expected-error {{cannot synthesize weak property because the current deployment target does not support weak references}}
57 @end