From 50efe0483563b12dc8e005068c85d68dc1f7d9ae Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Mon, 6 Apr 2009 16:59:10 +0000 Subject: [PATCH] writable property in a category of class's superclass makes the property writable in the current class. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68446 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclObjC.cpp | 3 +++ test/SemaObjC/writable-property-in-superclass.m | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 test/SemaObjC/writable-property-in-superclass.m diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 299f101bdb..80d46bcabb 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -835,6 +835,9 @@ bool Sema::isPropertyReadonly(ObjCPropertyDecl *PDecl, ObjCImplementations[IDecl->getIdentifier()]) if (ImpDecl->getInstanceMethod(PDecl->getSetterName())) return false; + // If all fails, look at the super class. + if (ObjCInterfaceDecl *SIDecl = IDecl->getSuperClass()) + return isPropertyReadonly(PDecl, SIDecl); return true; } diff --git a/test/SemaObjC/writable-property-in-superclass.m b/test/SemaObjC/writable-property-in-superclass.m new file mode 100644 index 0000000000..182b1c47bb --- /dev/null +++ b/test/SemaObjC/writable-property-in-superclass.m @@ -0,0 +1,17 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +@interface MessageStore +@property (assign, readonly) int P; +@end + +@interface MessageStore (CAT) +@property (assign) int P; +@end + +@interface NeXTMbox : MessageStore +@end + +@implementation NeXTMbox +- (void) Meth { self.P = 1; } +@end + -- 2.40.0