if (getStmtClass() == ObjCPropertyRefExprClass) {
const ObjCPropertyRefExpr* PropExpr = cast<ObjCPropertyRefExpr>(this);
if (ObjCPropertyDecl *PDecl = PropExpr->getProperty()) {
- ObjCPropertyDecl::PropertyAttributeKind Pkind =
- PDecl->getPropertyAttributes();
- if (Pkind == ObjCPropertyDecl::OBJC_PR_readonly)
+ if (PDecl->isReadOnly()) {
+ // Main class has the property as 'readyonly'. Must search
+ // through the category list to see if the property's
+ // attribute has been over-ridden to 'readwrite'.
+ const Expr *BaseExpr = PropExpr->getBase();
+ QualType BaseType = BaseExpr->getType();
+ const PointerType *PTy = BaseType->getAsPointerType();
+ const ObjCInterfaceType *IFTy =
+ PTy->getPointeeType()->getAsObjCInterfaceType();
+ ObjCInterfaceDecl *IFace = IFTy->getDecl();
+ for (ObjCCategoryDecl *Category = IFace->getCategoryList();
+ Category; Category = Category->getNextClassCategory()) {
+ PDecl= Category->FindPropertyDeclaration(PDecl->getIdentifier());
+ if (PDecl && !PDecl->isReadOnly())
+ return MLV_Valid;
+ }
return MLV_ReadonlyProperty;
+ }
}
}
// Assigning to an 'implicit' property?
- if (getStmtClass() == ObjCKVCRefExprClass) {
+ else if (getStmtClass() == ObjCKVCRefExprClass) {
const ObjCKVCRefExpr* KVCExpr = cast<ObjCKVCRefExpr>(this);
if (KVCExpr->getSetterMethod() == 0)
return MLV_NoSetterProperty;
--- /dev/null
+// RUN: clang -fsyntax-only -verify %s
+
+@interface Object
+- (id)new;
+@end
+
+@interface ReadOnly : Object
+{
+ int _object;
+ int _Anotherobject;
+}
+@property(readonly) int object;
+@property(readonly) int Anotherobject;
+@end
+
+@interface ReadOnly ()
+@property(readwrite) int object;
+@property(readwrite, setter = myAnotherobjectSetter:) int Anotherobject;
+@end
+
+@implementation ReadOnly
+@synthesize object = _object;
+@synthesize Anotherobject = _Anotherobject;
+- (void) myAnotherobjectSetter : (int)val {
+ _Anotherobject = val;
+}
+@end
+
+int main(int argc, char **argv) {
+ ReadOnly *test = [ReadOnly new];
+ test.object = 12345;
+ test.Anotherobject = 200;
+ return test.object - 12345 + test.Anotherobject - 200;
+}
+