diff options
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 9 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExprMember.cpp | 2 | ||||
-rw-r--r-- | clang/test/SemaObjC/warn-direct-ivar-access.m | 5 |
3 files changed, 10 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 5bc82c7394c..bfe72423e1e 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1961,11 +1961,10 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S, return ExprError(); MarkAnyDeclReferenced(Loc, IV); - 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(); - } + + 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)); diff --git a/clang/lib/Sema/SemaExprMember.cpp b/clang/lib/Sema/SemaExprMember.cpp index 0258b2a158f..53f22f65ddf 100644 --- a/clang/lib/Sema/SemaExprMember.cpp +++ b/clang/lib/Sema/SemaExprMember.cpp @@ -1263,7 +1263,7 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr, warn = false; } } - if (warn && IV->getType()->isObjCObjectPointerType()) { + if (warn) { if (ObjCMethodDecl *MD = getCurMethodDecl()) { ObjCMethodFamily MF = MD->getMethodFamily(); warn = (MF != OMF_init && MF != OMF_dealloc && diff --git a/clang/test/SemaObjC/warn-direct-ivar-access.m b/clang/test/SemaObjC/warn-direct-ivar-access.m index d380ebf5aec..d2295f47655 100644 --- a/clang/test/SemaObjC/warn-direct-ivar-access.m +++ b/clang/test/SemaObjC/warn-direct-ivar-access.m @@ -5,15 +5,18 @@ __attribute__((objc_root_class)) @interface MyObject { @public id _myMaster; id _isTickledPink; + int _myIntProp; } @property(retain) id myMaster; @property(assign) id isTickledPink; // expected-note {{property declared here}} +@property int myIntProp; @end @implementation MyObject @synthesize myMaster = _myMaster; @synthesize isTickledPink = _isTickledPink; // expected-error {{existing ivar '_isTickledPink' for property 'isTickledPink'}} +@synthesize myIntProp = _myIntProp; - (void) doSomething { _myMaster = _isTickledPink; // expected-warning {{instance variable '_myMaster' is being directly accessed}} \ @@ -33,6 +36,8 @@ MyObject * foo () p.isTickledPink = p.myMaster; // ok p->_isTickledPink = (*p)._myMaster; // expected-warning {{instance variable '_isTickledPink' is being directly accessed}} \ // expected-warning {{instance variable '_myMaster' is being directly accessed}} + if (p->_myIntProp) // expected-warning {{instance variable '_myIntProp' is being directly accessed}} + p->_myIntProp = 0; // expected-warning {{instance variable '_myIntProp' is being directly accessed}} return p->_isTickledPink; // expected-warning {{instance variable '_isTickledPink' is being directly accessed}} } |