diff options
| author | Alex Lorenz <arphaman@gmail.com> | 2017-03-30 13:33:51 +0000 |
|---|---|---|
| committer | Alex Lorenz <arphaman@gmail.com> | 2017-03-30 13:33:51 +0000 |
| commit | 535571a2a1538d4ccb6285810f32ff3755e3cf85 (patch) | |
| tree | c3d18482f9fb5d9281bc4ce5e9d99eb6a36de717 | |
| parent | 41ca83f8114013894b5f4b97be597f2f0e7ae02d (diff) | |
| download | bcm5719-llvm-535571a2a1538d4ccb6285810f32ff3755e3cf85.tar.gz bcm5719-llvm-535571a2a1538d4ccb6285810f32ff3755e3cf85.zip | |
[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
llvm-svn: 299078
| -rw-r--r-- | clang/lib/Sema/SemaObjCProperty.cpp | 9 | ||||
| -rw-r--r-- | clang/test/SemaObjC/property-typecheck-1.m | 5 |
2 files changed, 8 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp index b9506152104..6c571645487 100644 --- a/clang/lib/Sema/SemaObjCProperty.cpp +++ b/clang/lib/Sema/SemaObjCProperty.cpp @@ -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( diff --git a/clang/test/SemaObjC/property-typecheck-1.m b/clang/test/SemaObjC/property-typecheck-1.m index 5fb05c8bd38..85e8d4624be 100644 --- a/clang/test/SemaObjC/property-typecheck-1.m +++ b/clang/test/SemaObjC/property-typecheck-1.m @@ -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 { |

