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()) {
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;
}
--- /dev/null
+// 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