forked from OSchip/llvm-project
objc: warn if a readonly property has a setter attribute too.
// rdar://10357768 llvm-svn: 143518
This commit is contained in:
parent
49ea5bf562
commit
3018b95093
|
@ -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">;
|
||||
|
|
|
@ -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">,
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue