Author: fjahanian
Date: Mon Jan 19 12:16:19 2009
New Revision: 62515

URL: http://llvm.org/viewvc/llvm-project?rev=62515&view=rev
Log:
Patch to allow @dynamic synthesis of property in a category,
with @synthesize being illegal.

Added:
    cfe/trunk/test/SemaObjC/property-category-2.m
Modified:
    cfe/trunk/lib/AST/DeclObjC.cpp

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=62515&r1=62514&r2=62515&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Mon Jan 19 12:16:19 2009
@@ -364,8 +364,7 @@
         return property;
   }
   
-  const ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(this);
-  if (OID) {
+  if (const ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(this)) {
     // Look through categories.
     for (ObjCCategoryDecl *Category = OID->getCategoryList();
          Category; Category = Category->getNextClassCategory()) {
@@ -384,6 +383,16 @@
     if (OID->getSuperClass())
       return OID->getSuperClass()->FindPropertyDeclaration(PropertyId);
   }
+  else if (const ObjCCategoryDecl *OCD = dyn_cast<ObjCCategoryDecl>(this)) {
+    // Look through protocols.
+    for (ObjCInterfaceDecl::protocol_iterator I = OCD->protocol_begin(),
+         E = OCD->protocol_end(); I != E; ++I) {
+      ObjCProtocolDecl *Protocol = *I;
+      ObjCPropertyDecl *property = 
Protocol->FindPropertyDeclaration(PropertyId);
+      if (property)
+        return property;
+    }
+  }
   return 0;
 }
 

Added: cfe/trunk/test/SemaObjC/property-category-2.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-category-2.m?rev=62515&view=auto

==============================================================================
--- cfe/trunk/test/SemaObjC/property-category-2.m (added)
+++ cfe/trunk/test/SemaObjC/property-category-2.m Mon Jan 19 12:16:19 2009
@@ -0,0 +1,19 @@
+// RUN: clang -fsyntax-only -verify %s
+// Test that a property can be synthesize in a category
+// implementation with no error.
+
+...@protocol MyProtocol
+...@property float  myFloat;
+...@property float  anotherFloat;
+...@end
+
+...@interface MyObject { float anotherFloat; }
+...@end
+
+...@interface MyObject (CAT) <MyProtocol>
+...@end
+
+...@implementation MyObject (CAT)
+...@dynamic myFloat;   // OK
+...@synthesize anotherFloat; // expected-error {...@synthesize not allowed in 
a category's implementation}}
+...@end


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to