[cfe-commits] r62515 - in /cfe/trunk: lib/AST/DeclObjC.cpp test/SemaObjC/property-category-2.m
Fariborz Jahanian
fjahanian at apple.com
Mon Jan 19 10:16:20 PST 2009
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.
+
+ at protocol MyProtocol
+ at property float myFloat;
+ at property float anotherFloat;
+ at end
+
+ at interface MyObject { float anotherFloat; }
+ at end
+
+ at interface MyObject (CAT) <MyProtocol>
+ at end
+
+ at implementation MyObject (CAT)
+ at dynamic myFloat; // OK
+ at synthesize anotherFloat; // expected-error {{@synthesize not allowed in a category's implementation}}
+ at end
More information about the cfe-commits
mailing list