diff options
| author | John McCall <rjmccall@apple.com> | 2018-09-05 19:02:00 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2018-09-05 19:02:00 +0000 |
| commit | 52a503d4f333d7f8ccfde50fa7a2fb5fe11c4b1d (patch) | |
| tree | d376cfc3279240d0d073b1c8fbf91b2c7e7cb2f8 /clang/lib | |
| parent | d2eb03aec831f2990ffb05e6a1421aaa6c3eb612 (diff) | |
| download | bcm5719-llvm-52a503d4f333d7f8ccfde50fa7a2fb5fe11c4b1d.tar.gz bcm5719-llvm-52a503d4f333d7f8ccfde50fa7a2fb5fe11c4b1d.zip | |
Add -Wobjc-property-assign-on-object-type.
This is a warning about using 'assign' instead of 'unsafe_unretained'
in Objective-C property declarations. It's off by default because there
isn't consensus in the Objective-C steering group that this is the right
thing to do, but we're nonetheless okay with adding it because there's a
substantial pool of Objective-C programmers who will appreciate the warning.
Patch by Alfred Zien!
llvm-svn: 341489
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaObjCProperty.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp index ab7b83c4c33..d0000279722 100644 --- a/clang/lib/Sema/SemaObjCProperty.cpp +++ b/clang/lib/Sema/SemaObjCProperty.cpp @@ -2557,6 +2557,14 @@ void Sema::CheckObjCPropertyAttributes(Decl *PDecl, PropertyDecl->setInvalidDecl(); } + // Check for assign on object types. + if ((Attributes & ObjCDeclSpec::DQ_PR_assign) && + !(Attributes & ObjCDeclSpec::DQ_PR_unsafe_unretained) && + PropertyTy->isObjCRetainableType() && + !PropertyTy->isObjCARCImplicitlyUnretainedType()) { + Diag(Loc, diag::warn_objc_property_assign_on_object); + } + // Check for more than one of { assign, copy, retain }. if (Attributes & ObjCDeclSpec::DQ_PR_assign) { if (Attributes & ObjCDeclSpec::DQ_PR_copy) { |

