]> granicus.if.org Git - clang/commitdiff
Do not diagnose method disguised as property setter
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 6 Jan 2010 00:18:12 +0000 (00:18 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 6 Jan 2010 00:18:12 +0000 (00:18 +0000)
for a 'readonly' property. Fixes radar 7427072.

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

lib/Sema/SemaDeclObjC.cpp
test/SemaObjC/property-9.m

index fb2cc712dce9473508304e85c7684a400a0f0849..115a4333031856ba47442ecb1fb1b9b0aa387097 100644 (file)
@@ -1473,8 +1473,11 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
                                    property->getLocation());
 
   if (SetterMethod) {
-    if (Context.getCanonicalType(SetterMethod->getResultType())
-        != Context.VoidTy)
+    ObjCPropertyDecl::PropertyAttributeKind CAttr = 
+      property->getPropertyAttributes();
+    if ((!(CAttr & ObjCPropertyDecl::OBJC_PR_readonly)) &&
+        Context.getCanonicalType(SetterMethod->getResultType()) != 
+          Context.VoidTy)
       Diag(SetterMethod->getLocation(), diag::err_setter_type_void);
     if (SetterMethod->param_size() != 1 ||
         ((*SetterMethod->param_begin())->getType() != property->getType())) {
index 138f09953d5a82de8509f328413b3a7d81c4a96e..d527a9c9f30b634b954fae3eb1759bff063ae42b 100644 (file)
@@ -84,3 +84,15 @@ typedef signed char BOOL;
   view.inEyeDropperMode = 1;
 }
 @end
+
+// radar 7427072
+@interface MyStyleIntf 
+{
+    int _myStyle;
+}
+
+@property(readonly) int myStyle;
+
+- (float)setMyStyle:(int)style;
+@end
+