1 // RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -Wdirect-ivar-access -verify -Wno-objc-root-class %s
4 __attribute__((objc_root_class)) @interface MyObject {
7 id _isTickledPink; // expected-error {{existing instance variable '_isTickledPink' for property 'isTickledPink'}}
10 @property(retain) id myMaster;
11 @property(assign) id isTickledPink; // expected-note {{property declared here}}
12 @property int myIntProp;
15 @implementation MyObject
17 @synthesize myMaster = _myMaster;
18 @synthesize isTickledPink = _isTickledPink; // expected-note {{property synthesized here}}
19 @synthesize myIntProp = _myIntProp;
21 - (void) doSomething {
22 _myMaster = _isTickledPink; // expected-warning {{instance variable '_myMaster' is being directly accessed}} \
23 // expected-warning {{instance variable '_isTickledPink' is being directly accessed}}
30 - (void) dealloc { _myMaster = 0; }
36 p.isTickledPink = p.myMaster; // ok
37 p->_isTickledPink = (*p)._myMaster; // expected-warning {{instance variable '_isTickledPink' is being directly accessed}} \
38 // expected-warning {{instance variable '_myMaster' is being directly accessed}}
39 if (p->_myIntProp) // expected-warning {{instance variable '_myIntProp' is being directly accessed}}
40 p->_myIntProp = 0; // expected-warning {{instance variable '_myIntProp' is being directly accessed}}
41 return p->_isTickledPink; // expected-warning {{instance variable '_isTickledPink' is being directly accessed}}
50 id Test32(__weak ITest32 *x) {
52 x->ivar = 0; // expected-error {{dereferencing a __weak pointer is not allowed}}
53 return y ? y->ivar // expected-error {{dereferencing a __weak pointer is not allowed}}
54 : (*x).ivar; // expected-error {{dereferencing a __weak pointer is not allowed}}
59 @property (copy, nonatomic) id property_in_protocol;
62 __attribute__((objc_root_class)) @interface INTF <PROTOCOL>
63 @property (copy, nonatomic) id foo;
68 @property (copy, nonatomic) id foo1;
73 - (id) foo { return _foo; }
74 - (id) property_in_protocol { return _property_in_protocol; } // expected-warning {{instance variable '_property_in_protocol' is being directly accessed}}
75 - (id) foo1 { return _foo1; }
76 @synthesize property_in_protocol = _property_in_protocol;