memory models, except when arc is accessing a weak
ivar (which is an error). // rdar://
6505197
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161458
91177308-0d34-0410-b5e6-
96231b3b80d8
return ExprError();
MarkAnyDeclReferenced(Loc, IV);
- if (IV->getType()->isObjCObjectPointerType() &&
- getLangOpts().getGC() == LangOptions::NonGC &&
- !getLangOpts().ObjCAutoRefCount) {
+ if (IV->getType()->isObjCObjectPointerType()) {
ObjCMethodFamily MF = CurMethod->getMethodFamily();
if (MF != OMF_init && MF != OMF_dealloc && MF != OMF_finalize)
Diag(Loc, diag::warn_direct_ivar_access) << IV->getDeclName();
<< IV->getDeclName();
}
}
+ bool warn = true;
if (getLangOpts().ObjCAutoRefCount) {
Expr *BaseExp = BaseExpr.get()->IgnoreParenImpCasts();
if (UnaryOperator *UO = dyn_cast<UnaryOperator>(BaseExp))
BaseExp = UO->getSubExpr()->IgnoreParenCasts();
if (DeclRefExpr *DE = dyn_cast<DeclRefExpr>(BaseExp))
- if (DE->getType().getObjCLifetime() == Qualifiers::OCL_Weak)
+ if (DE->getType().getObjCLifetime() == Qualifiers::OCL_Weak) {
Diag(DE->getLocation(), diag::error_arc_weak_ivar_access);
+ warn = false;
+ }
}
- if (IV->getType()->isObjCObjectPointerType() &&
- getLangOpts().getGC() == LangOptions::NonGC &&
- !getLangOpts().ObjCAutoRefCount) {
- bool warn = true;
+ if (warn && IV->getType()->isObjCObjectPointerType()) {
if (ObjCMethodDecl *MD = getCurMethodDecl()) {
ObjCMethodFamily MF = MD->getMethodFamily();
warn = (MF != OMF_init && MF != OMF_dealloc &&
-// RUN: %clang_cc1 -fsyntax-only -Wdirect-ivar-access -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -Wdirect-ivar-access -verify -Wno-objc-root-class %s
// rdar://6505197
__attribute__((objc_root_class)) @interface MyObject {
id _isTickledPink;
}
@property(retain) id myMaster;
-@property(assign) id isTickledPink;
+@property(assign) id isTickledPink; // expected-note {{property declared here}}
@end
@implementation MyObject
@synthesize myMaster = _myMaster;
-@synthesize isTickledPink = _isTickledPink;
+@synthesize isTickledPink = _isTickledPink; // expected-error {{existing ivar '_isTickledPink' for property 'isTickledPink'}}
- (void) doSomething {
_myMaster = _isTickledPink; // expected-warning {{instance variable '_myMaster' is being directly accessed}} \
return p->_isTickledPink; // expected-warning {{instance variable '_isTickledPink' is being directly accessed}}
}
+@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}}
+}
+