diff options
-rw-r--r-- | include/clang/Basic/DiagnosticGroups.td | 1 | ||||
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 3 | ||||
-rw-r--r-- | lib/Sema/SemaObjCProperty.cpp | 5 | ||||
-rw-r--r-- | test/SemaObjC/property-10.m | 9 |
4 files changed, 18 insertions, 0 deletions
diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td index 343ffdab1a..33a66a467d 100644 --- a/include/clang/Basic/DiagnosticGroups.td +++ b/include/clang/Basic/DiagnosticGroups.td @@ -110,6 +110,7 @@ def OverlengthStrings : DiagGroup<"overlength-strings">; def OverloadedVirtual : DiagGroup<"overloaded-virtual">; def ObjCMissingSuperCalls : DiagGroup<"objc-missing-super-calls">; def ObjCRetainBlockProperty : DiagGroup<"objc-noncopy-retain-block-property">; +def ObjCReadonlyPropertyHasSetter : DiagGroup<"objc-readonly-with-setter-property">; def ObjCContinuationPropertyType :DiagGroup<"objc-continuation-property-type">; def Packed : DiagGroup<"packed">; def Padded : DiagGroup<"padded">; diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 9041a768a7..7bfd7fb32c 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -502,6 +502,9 @@ def warn_objc_property_copy_missing_on_block : Warning< def warn_objc_property_retain_of_block : Warning< "retain'ed block property does not copy the block " "- use copy attribute instead">, InGroup<ObjCRetainBlockProperty>; +def warn_objc_readonly_property_has_setter : Warning< + "setter cannot be specified for a readonly property">, + InGroup<ObjCReadonlyPropertyHasSetter>; def warn_atomic_property_rule : Warning< "writable atomic property %0 cannot pair a synthesized %select{getter|setter}1 " "with a user defined %select{getter|setter}2">, diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 617dbefada..ae054bc629 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -1798,4 +1798,9 @@ void Sema::CheckObjCPropertyAttributes(Decl *PDecl, !(Attributes & ObjCDeclSpec::DQ_PR_strong) && PropertyTy->isBlockPointerType()) Diag(Loc, diag::warn_objc_property_retain_of_block); + + if ((Attributes & ObjCDeclSpec::DQ_PR_readonly) && + (Attributes & ObjCDeclSpec::DQ_PR_setter)) + Diag(Loc, diag::warn_objc_readonly_property_has_setter); + } diff --git a/test/SemaObjC/property-10.m b/test/SemaObjC/property-10.m index e89d68e9d0..51eb39c9e7 100644 --- a/test/SemaObjC/property-10.m +++ b/test/SemaObjC/property-10.m @@ -37,3 +37,12 @@ @property(nonatomic,copy) int (*PROP1)(); // expected-error {{property with 'copy' attribute must be of object type}} @property(nonatomic,weak) int (*PROP2)(); // expected-error {{property with 'weak' attribute must be of object type}} @end + +// rdar://10357768 +@interface rdar10357768 +{ + int n1; +} +@property (readonly, setter=crushN1:) int n1; // expected-warning {{setter cannot be specified for a readonly property}} +@end + |