summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/AST/DeclObjC.h4
-rw-r--r--clang/lib/AST/DeclObjC.cpp4
-rw-r--r--clang/test/SemaObjC/property-5.m3
3 files changed, 11 insertions, 0 deletions
diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h
index 84abdfd8028..d985ce39626 100644
--- a/clang/include/clang/AST/DeclObjC.h
+++ b/clang/include/clang/AST/DeclObjC.h
@@ -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; }
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index 2e038024363..e74e21dbbca 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -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) {
diff --git a/clang/test/SemaObjC/property-5.m b/clang/test/SemaObjC/property-5.m
index c467e634dcc..70ef315b22d 100644
--- a/clang/test/SemaObjC/property-5.m
+++ b/clang/test/SemaObjC/property-5.m
@@ -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}}
+}
OpenPOWER on IntegriCloud