1 // RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -Wdirect-ivar-access -verify -Wno-objc-root-class %s
3 __attribute__((objc_root_class)) @interface MyObject {
6 id _isTickledPink; // expected-error {{existing instance variable '_isTickledPink' for property 'isTickledPink'}}
9 @property(retain) id myLeader;
10 @property(assign) id isTickledPink; // expected-note {{property declared here}}
11 @property int myIntProp;
14 @implementation MyObject
16 @synthesize myLeader = _myLeader;
17 @synthesize isTickledPink = _isTickledPink; // expected-note {{property synthesized here}}
18 @synthesize myIntProp = _myIntProp;
20 - (void) doSomething {
21 _myLeader = _isTickledPink; // expected-warning {{instance variable '_myLeader' is being directly accessed}} \
22 // expected-warning {{instance variable '_isTickledPink' is being directly accessed}}
29 - (void) dealloc { _myLeader = 0; }
35 p.isTickledPink = p.myLeader; // ok
36 p->_isTickledPink = (*p)._myLeader; // expected-warning {{instance variable '_isTickledPink' is being directly accessed}} \
37 // expected-warning {{instance variable '_myLeader' is being directly accessed}}
38 if (p->_myIntProp) // expected-warning {{instance variable '_myIntProp' is being directly accessed}}
39 p->_myIntProp = 0; // expected-warning {{instance variable '_myIntProp' is being directly accessed}}
40 return p->_isTickledPink; // expected-warning {{instance variable '_isTickledPink' is being directly accessed}}
49 id Test32(__weak ITest32 *x) {
51 x->ivar = 0; // expected-error {{dereferencing a __weak pointer is not allowed}}
52 return y ? y->ivar // expected-error {{dereferencing a __weak pointer is not allowed}}
53 : (*x).ivar; // expected-error {{dereferencing a __weak pointer is not allowed}}
57 @property (copy, nonatomic) id property_in_protocol;
60 __attribute__((objc_root_class)) @interface INTF <PROTOCOL>
61 @property (copy, nonatomic) id foo;
66 @property (copy, nonatomic) id foo1;
71 - (id) foo { return _foo; }
72 - (id) property_in_protocol { return _property_in_protocol; } // expected-warning {{instance variable '_property_in_protocol' is being directly accessed}}
73 - (id) foo1 { return _foo1; }
74 @synthesize property_in_protocol = _property_in_protocol;