[Sema][ObjC] Avoid the "type of property does not match type of accessor"

warning for methods that resemble the setters of readonly properties

rdar://30415679


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@299078 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Alex Lorenz 2017-03-30 13:33:51 +00:00
parent 4b446668ab
commit 225e636cbc
2 changed files with 8 additions and 6 deletions

View File

@ -2185,12 +2185,9 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property) {
DiagnosePropertyAccessorMismatch(property, GetterMethod,
property->getLocation());
if (SetterMethod) {
ObjCPropertyDecl::PropertyAttributeKind CAttr =
property->getPropertyAttributes();
if ((!(CAttr & ObjCPropertyDecl::OBJC_PR_readonly)) &&
Context.getCanonicalType(SetterMethod->getReturnType()) !=
Context.VoidTy)
if (!property->isReadOnly() && SetterMethod) {
if (Context.getCanonicalType(SetterMethod->getReturnType()) !=
Context.VoidTy)
Diag(SetterMethod->getLocation(), diag::err_setter_type_void);
if (SetterMethod->param_size() != 1 ||
!Context.hasSameUnqualifiedType(

View File

@ -78,6 +78,11 @@ typedef void (F)(void);
- (NSMutableArray*) pieces; // expected-note 2 {{declared here}}
- (NSArray*) first;
// Don't warn about setter-like methods for readonly properties.
- (void)setFirst:(char)val;
- (void)setPieces:(char)val;
@end
@interface Class2 {