]> granicus.if.org Git - clang/commitdiff
Add ObjCPropertyDecl::isReadOnly.
authorDaniel Dunbar <daniel@zuster.org>
Tue, 26 Aug 2008 07:16:44 +0000 (07:16 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 26 Aug 2008 07:16:44 +0000 (07:16 +0000)
Respect isReadOnly when generating synthesized method decls.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55364 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclObjC.h
lib/AST/DeclObjC.cpp
test/SemaObjC/property-5.m

index 84abdfd80283500305dd69032d048465c037bb4d..d985ce39626d8cd5a45ed62dd0397128874b6919 100644 (file)
@@ -1205,6 +1205,10 @@ public:
   void setPropertyAttributes(PropertyAttributeKind PRVal) { 
     PropertyAttributes |= PRVal;
   }
+
+  bool isReadOnly() const {
+    return (PropertyAttributes & OBJC_PR_readonly);
+  }
   
   Selector getGetterName() const { return GetterName; }
   void setGetterName(Selector Sel) { GetterName = Sel; }
index 2e038024363cffe4333b690440d9a2ab67828bbb..e74e21dbbca2555695b64b885dfaeef3fb940356 100644 (file)
@@ -433,6 +433,10 @@ void ObjCInterfaceDecl::addPropertyMethods(
   }
   property->setGetterMethodDecl(GetterDecl);
 
+  // Skip setter if property is read-only.
+  if (property->isReadOnly())
+    return;
+
   // Find the default setter and if one not found, add one.
   ObjCMethodDecl *SetterDecl = getInstanceMethod(property->getSetterName());
   if (!SetterDecl) {
index c467e634dcce64be283f9da579ea9be2a5e7b5ab..70ef315b22d7ccf8d30272b1def34e2451b83941 100644 (file)
@@ -29,3 +29,6 @@
 @property(readonly) ConstData *p_base; // expected-warning {{property type 'ConstData *' does not match property type inherited from 'Data'}}
 @end
 
+void foo(Base *b, id x) {
+  [ b setRef: x ]; // expected-warning {{method '-setRef:' not found}}
+}