summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaObjCProperty.cpp
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2018-05-02 22:40:19 +0000
committerAlex Lorenz <arphaman@gmail.com>2018-05-02 22:40:19 +0000
commit613725507cb2c5bb09c680a64b935447c99b0729 (patch)
tree01756a14e75c3ecec5b3c5cd0882c1b6d17488b9 /clang/lib/Sema/SemaObjCProperty.cpp
parent71c3a3fac521be022d493cd78e9ec00a7a42dae5 (diff)
downloadbcm5719-llvm-613725507cb2c5bb09c680a64b935447c99b0729.tar.gz
bcm5719-llvm-613725507cb2c5bb09c680a64b935447c99b0729.zip
[ObjC] The absence of ownership qualifiers on an ambiguous property leads
to synthesis of a valid property even when the selected protocol property has ownership qualifiers rdar://39024725 llvm-svn: 331409
Diffstat (limited to 'clang/lib/Sema/SemaObjCProperty.cpp')
-rw-r--r--clang/lib/Sema/SemaObjCProperty.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp
index 3b8ad3d7e11..7ff037018fa 100644
--- a/clang/lib/Sema/SemaObjCProperty.cpp
+++ b/clang/lib/Sema/SemaObjCProperty.cpp
@@ -897,14 +897,24 @@ SelectPropertyForSynthesisFromProtocols(Sema &S, SourceLocation AtLoc,
: HasUnexpectedAttribute;
Mismatches.push_back({Prop, Kind, AttributeName});
};
- if (isIncompatiblePropertyAttribute(OriginalAttributes, Attr,
+ // The ownership might be incompatible unless the property has no explicit
+ // ownership.
+ bool HasOwnership = (Attr & (ObjCPropertyDecl::OBJC_PR_retain |
+ ObjCPropertyDecl::OBJC_PR_strong |
+ ObjCPropertyDecl::OBJC_PR_copy |
+ ObjCPropertyDecl::OBJC_PR_assign |
+ ObjCPropertyDecl::OBJC_PR_unsafe_unretained |
+ ObjCPropertyDecl::OBJC_PR_weak)) != 0;
+ if (HasOwnership &&
+ isIncompatiblePropertyAttribute(OriginalAttributes, Attr,
ObjCPropertyDecl::OBJC_PR_copy)) {
Diag(OriginalAttributes & ObjCPropertyDecl::OBJC_PR_copy, "copy");
continue;
}
- if (areIncompatiblePropertyAttributes(
- OriginalAttributes, Attr, ObjCPropertyDecl::OBJC_PR_retain |
- ObjCPropertyDecl::OBJC_PR_strong)) {
+ if (HasOwnership && areIncompatiblePropertyAttributes(
+ OriginalAttributes, Attr,
+ ObjCPropertyDecl::OBJC_PR_retain |
+ ObjCPropertyDecl::OBJC_PR_strong)) {
Diag(OriginalAttributes & (ObjCPropertyDecl::OBJC_PR_retain |
ObjCPropertyDecl::OBJC_PR_strong),
"retain (or strong)");
OpenPOWER on IntegriCloud