From 617e49ad59a96eb972e270fda36981ced0acb57c Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Fri, 15 Nov 2013 17:48:00 +0000 Subject: ObjectiveC. Fixes a bogus warning of unused backing ivar when property belongs to a super class and currnt class happens to have a method with same name as property. // rdar//15473432 llvm-svn: 194830 --- clang/lib/Sema/SemaDeclObjC.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'clang/lib/Sema') diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 86979a1fe85..f44fb325114 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -3510,8 +3510,17 @@ Sema::GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method, Method = IDecl->lookupMethod(Method->getSelector(), true); if (!Method || !Method->isPropertyAccessor()) return 0; - if ((PDecl = Method->findPropertyDecl())) + if ((PDecl = Method->findPropertyDecl())) { + if (!PDecl->getDeclContext()) + return 0; + // Make sure property belongs to accessor's class and not to + // one of its super classes. + if (const ObjCInterfaceDecl *CID = + dyn_cast(PDecl->getDeclContext())) + if (CID != IDecl) + return 0; return PDecl->getPropertyIvarDecl(); + } return 0; } -- cgit v1.2.3