MarkAnyDeclReferenced(Loc, IV);
if (IV->getType()->isObjCObjectPointerType() &&
- getLangOpts().getGC() == LangOptions::NonGC)
- Diag(Loc, diag::warn_direct_ivar_access) << IV->getDeclName();
+ getLangOpts().getGC() == LangOptions::NonGC &&
+ !getLangOpts().ObjCAutoRefCount) {
+ ObjCMethodFamily MF = CurMethod->getMethodFamily();
+ if (MF != OMF_init && MF != OMF_dealloc && MF != OMF_finalize)
+ Diag(Loc, diag::warn_direct_ivar_access) << IV->getDeclName();
+ }
return Owned(new (Context)
ObjCIvarRefExpr(IV, IV->getType(), Loc,
SelfExpr.take(), true, true));
Diag(DE->getLocation(), diag::error_arc_weak_ivar_access);
}
if (IV->getType()->isObjCObjectPointerType() &&
- getLangOpts().getGC() == LangOptions::NonGC)
- Diag(MemberLoc, diag::warn_direct_ivar_access) << IV->getDeclName();
+ getLangOpts().getGC() == LangOptions::NonGC &&
+ !getLangOpts().ObjCAutoRefCount) {
+ bool warn = true;
+ if (ObjCMethodDecl *MD = getCurMethodDecl()) {
+ ObjCMethodFamily MF = MD->getMethodFamily();
+ warn = (MF != OMF_init && MF != OMF_dealloc &&
+ MF != OMF_finalize);
+ }
+ if (warn)
+ Diag(MemberLoc, diag::warn_direct_ivar_access) << IV->getDeclName();
+ }
return Owned(new (Context) ObjCIvarRefExpr(IV, IV->getType(),
MemberLoc, BaseExpr.take(),
IsArrow));
// expected-warning {{instance variable '_isTickledPink' is being directly accessed}}
}
+- (id) init {
+ _myMaster=0;
+ return _myMaster;
+}
+- (void) dealloc { _myMaster = 0; }
@end
MyObject * foo ()