[cfe-commits] r56785 - in /cfe/trunk: lib/Sema/SemaDeclObjC.cpp test/SemaObjC/property-1.m

Steve Naroff snaroff at apple.com
Mon Sep 29 07:20:56 PDT 2008


Author: snaroff
Date: Mon Sep 29 09:20:56 2008
New Revision: 56785

URL: http://llvm.org/viewvc/llvm-project?rev=56785&view=rev
Log:
Fix <rdar://problem/6253149> property declaration doesn't declare getter and setter.

Modified:
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/test/SemaObjC/property-1.m

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=56785&r1=56784&r2=56785&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Mon Sep 29 09:20:56 2008
@@ -874,6 +874,9 @@
       }
     }
   }
+  // Save the size so we can detect if we've added any property methods.
+  unsigned int insMethodsSizePriorToPropAdds = insMethods.size();
+  unsigned int clsMethodsSizePriorToPropAdds = clsMethods.size();
   
   if (ObjCInterfaceDecl *I = dyn_cast<ObjCInterfaceDecl>(ClassDecl)) {
     // Compares properties declared in this class to those of its 
@@ -925,6 +928,24 @@
       }
     }
   }
+  // Add any synthesized methods to the global pool. This allows us to 
+  // handle the following, which is supported by GCC (and part of the design).
+  //
+  // @interface Foo
+  // @property double bar;
+  // @end
+  //
+  // void thisIsUnfortunate() {
+  //   id foo;
+  //   double bar = [foo bar];
+  // }
+  //
+  if (insMethodsSizePriorToPropAdds < insMethods.size())
+    for (unsigned i = insMethodsSizePriorToPropAdds; i < insMethods.size(); i++)
+      AddInstanceMethodToGlobalPool(insMethods[i]);     
+  if (clsMethodsSizePriorToPropAdds < clsMethods.size())
+    for (unsigned i = clsMethodsSizePriorToPropAdds; i < clsMethods.size(); i++)
+      AddFactoryMethodToGlobalPool(clsMethods[i]);     
 }
 
 

Modified: cfe/trunk/test/SemaObjC/property-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-1.m?rev=56785&r1=56784&r2=56785&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/property-1.m (original)
+++ cfe/trunk/test/SemaObjC/property-1.m Mon Sep 29 09:20:56 2008
@@ -35,5 +35,13 @@
 @dynamic d;		// expected-error {{property implementation in a category with no category declaration}}
 @end
 
+ at interface Foo
+ at property double bar;
+ at end
 
+int main() {
+   id foo;
+   double bar = [foo bar];
+   return 0;
+}
 





More information about the cfe-commits mailing list