2013-09-28 04:21:48 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -Wdirect-ivar-access -verify -Wno-objc-root-class %s
|
2012-08-07 07:50:51 +08:00
|
|
|
// rdar://6505197
|
|
|
|
|
|
|
|
__attribute__((objc_root_class)) @interface MyObject {
|
|
|
|
@public
|
2021-11-09 04:02:06 +08:00
|
|
|
id _myLeader;
|
2012-12-13 06:48:25 +08:00
|
|
|
id _isTickledPink; // expected-error {{existing instance variable '_isTickledPink' for property 'isTickledPink'}}
|
2012-08-09 00:41:04 +08:00
|
|
|
int _myIntProp;
|
2012-08-07 07:50:51 +08:00
|
|
|
}
|
2021-11-09 04:02:06 +08:00
|
|
|
@property(retain) id myLeader;
|
2012-08-08 07:48:10 +08:00
|
|
|
@property(assign) id isTickledPink; // expected-note {{property declared here}}
|
2012-08-09 00:41:04 +08:00
|
|
|
@property int myIntProp;
|
2012-08-07 07:50:51 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation MyObject
|
|
|
|
|
2021-11-09 04:02:06 +08:00
|
|
|
@synthesize myLeader = _myLeader;
|
2012-12-13 06:48:25 +08:00
|
|
|
@synthesize isTickledPink = _isTickledPink; // expected-note {{property synthesized here}}
|
2012-08-09 00:41:04 +08:00
|
|
|
@synthesize myIntProp = _myIntProp;
|
2012-08-07 07:50:51 +08:00
|
|
|
|
|
|
|
- (void) doSomething {
|
2021-11-09 04:02:06 +08:00
|
|
|
_myLeader = _isTickledPink; // expected-warning {{instance variable '_myLeader' is being directly accessed}} \
|
2012-08-07 07:50:51 +08:00
|
|
|
// expected-warning {{instance variable '_isTickledPink' is being directly accessed}}
|
|
|
|
}
|
|
|
|
|
2012-08-08 00:38:44 +08:00
|
|
|
- (id) init {
|
2021-11-09 04:02:06 +08:00
|
|
|
_myLeader=0;
|
|
|
|
return _myLeader;
|
2012-08-08 00:38:44 +08:00
|
|
|
}
|
2021-11-09 04:02:06 +08:00
|
|
|
- (void) dealloc { _myLeader = 0; }
|
2012-08-07 07:50:51 +08:00
|
|
|
@end
|
|
|
|
|
2022-02-08 04:28:35 +08:00
|
|
|
MyObject * foo (void)
|
2012-08-07 07:50:51 +08:00
|
|
|
{
|
|
|
|
MyObject* p=0;
|
2021-11-09 04:02:06 +08:00
|
|
|
p.isTickledPink = p.myLeader; // ok
|
|
|
|
p->_isTickledPink = (*p)._myLeader; // expected-warning {{instance variable '_isTickledPink' is being directly accessed}} \
|
|
|
|
// expected-warning {{instance variable '_myLeader' is being directly accessed}}
|
2012-08-09 00:41:04 +08:00
|
|
|
if (p->_myIntProp) // expected-warning {{instance variable '_myIntProp' is being directly accessed}}
|
|
|
|
p->_myIntProp = 0; // expected-warning {{instance variable '_myIntProp' is being directly accessed}}
|
2012-08-07 07:50:51 +08:00
|
|
|
return p->_isTickledPink; // expected-warning {{instance variable '_isTickledPink' is being directly accessed}}
|
|
|
|
}
|
|
|
|
|
2012-08-08 07:48:10 +08:00
|
|
|
@interface ITest32 {
|
|
|
|
@public
|
|
|
|
id ivar;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
id Test32(__weak ITest32 *x) {
|
|
|
|
__weak ITest32 *y;
|
|
|
|
x->ivar = 0; // expected-error {{dereferencing a __weak pointer is not allowed}}
|
|
|
|
return y ? y->ivar // expected-error {{dereferencing a __weak pointer is not allowed}}
|
|
|
|
: (*x).ivar; // expected-error {{dereferencing a __weak pointer is not allowed}}
|
|
|
|
}
|
|
|
|
|
2013-02-15 03:07:19 +08:00
|
|
|
// rdar://13142820
|
|
|
|
@protocol PROTOCOL
|
|
|
|
@property (copy, nonatomic) id property_in_protocol;
|
|
|
|
@end
|
|
|
|
|
|
|
|
__attribute__((objc_root_class)) @interface INTF <PROTOCOL>
|
|
|
|
@property (copy, nonatomic) id foo;
|
|
|
|
- (id) foo;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface INTF()
|
|
|
|
@property (copy, nonatomic) id foo1;
|
|
|
|
- (id) foo1;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation INTF
|
|
|
|
- (id) foo { return _foo; }
|
|
|
|
- (id) property_in_protocol { return _property_in_protocol; } // expected-warning {{instance variable '_property_in_protocol' is being directly accessed}}
|
|
|
|
- (id) foo1 { return _foo1; }
|
|
|
|
@synthesize property_in_protocol = _property_in_protocol;
|
|
|
|
@end
|
|
|
|
|