Fix a bug in nonfragile-abi2 when attempting to diagnose
previous use of a synthesized 'ivar' with property of same name
declared as @dynamic. In this case, 'ivar' is in the
inherited class and no diagnostics should be issued.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111940 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp
index ccb9a15..91f47ab 100644
--- a/lib/Sema/SemaObjCProperty.cpp
+++ b/lib/Sema/SemaObjCProperty.cpp
@@ -521,7 +521,7 @@
     if (getLangOptions().ObjCNonFragileABI2) {
       // Diagnose if an ivar was lazily synthesdized due to a previous
       // use and if 1) property is @dynamic or 2) property is synthesized
-      // but it requires a dirreferently named ivar.
+      // but it requires an ivar of different name.
       ObjCInterfaceDecl *ClassDeclared;
       ObjCIvarDecl *Ivar = 0;
       if (!Synthesize)
@@ -530,7 +530,9 @@
         if (PropertyIvar && PropertyIvar != PropertyId)
           Ivar = IDecl->lookupInstanceVariable(PropertyId, ClassDeclared);
       }
-      if (Ivar && Ivar->getSynthesize()) {
+      // Issue diagnostics only if Ivar belongs to current class.
+      if (Ivar && Ivar->getSynthesize() && 
+          IC->getClassInterface() == ClassDeclared) {
         Diag(Ivar->getLocation(), diag::err_undeclared_var_use) 
         << PropertyId;
         Ivar->setInvalidDecl();