[cfe-commits] r111940 - in /cfe/trunk: lib/Sema/SemaObjCProperty.cpp test/SemaObjC/property-and-ivar-use.m

Fariborz Jahanian fjahanian at apple.com
Tue Aug 24 11:48:05 PDT 2010


Author: fjahanian
Date: Tue Aug 24 13:48:05 2010
New Revision: 111940

URL: http://llvm.org/viewvc/llvm-project?rev=111940&view=rev
Log:
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.


Added:
    cfe/trunk/test/SemaObjC/property-and-ivar-use.m
Modified:
    cfe/trunk/lib/Sema/SemaObjCProperty.cpp

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=111940&r1=111939&r2=111940&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Tue Aug 24 13:48:05 2010
@@ -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();

Added: cfe/trunk/test/SemaObjC/property-and-ivar-use.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-and-ivar-use.m?rev=111940&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/property-and-ivar-use.m (added)
+++ cfe/trunk/test/SemaObjC/property-and-ivar-use.m Tue Aug 24 13:48:05 2010
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi2 -verify %s
+// Do not issue error if 'ivar' used previously belongs to the inherited class
+// and has same name as @dynalic property in current class.
+
+typedef signed char BOOL;
+
+ at protocol IDEBuildable
+ at property (readonly) BOOL hasRecursiveDependencyCycle;
+ at end
+
+ at protocol IDEBuildableProduct <IDEBuildable>
+ at end
+
+ at interface IDEBuildableSupportMixIn 
+ at property (readonly) BOOL hasRecursiveDependencyCycle;
+ at end
+
+ at interface Xcode3TargetBuildable <IDEBuildable>
+{
+  IDEBuildableSupportMixIn *_buildableMixIn;
+}
+ at end
+
+ at interface Xcode3TargetProduct : Xcode3TargetBuildable <IDEBuildableProduct>
+ at end
+
+ at implementation Xcode3TargetBuildable
+- (BOOL)hasRecursiveDependencyCycle
+{
+    return [_buildableMixIn hasRecursiveDependencyCycle];
+}
+ at end
+
+ at implementation Xcode3TargetProduct
+ at dynamic hasRecursiveDependencyCycle;
+ at end





More information about the cfe-commits mailing list