summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaExprObjC.cpp6
-rw-r--r--clang/test/SemaObjC/weak-receiver-warn.m12
2 files changed, 16 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp
index 598ad0b27ae..a3fe7d3bbef 100644
--- a/clang/lib/Sema/SemaExprObjC.cpp
+++ b/clang/lib/Sema/SemaExprObjC.cpp
@@ -1379,10 +1379,12 @@ static void DiagnoseARCUseOfWeakReceiver(Sema &S, Expr *Receiver) {
ObjCMethodDecl *Method = ME->getMethodDecl();
if (Method && Method->isSynthesized()) {
Selector Sel = Method->getSelector();
- if (Sel.getNumArgs() == 0)
+ if (Sel.getNumArgs() == 0) {
+ const DeclContext *Container = Method->getDeclContext();
PDecl =
- S.LookupPropertyDecl(Method->getClassInterface(),
+ S.LookupPropertyDecl(cast<ObjCContainerDecl>(Container),
Sel.getIdentifierInfoForSlot(0));
+ }
if (PDecl)
T = PDecl->getType();
}
diff --git a/clang/test/SemaObjC/weak-receiver-warn.m b/clang/test/SemaObjC/weak-receiver-warn.m
index 56d9bc10f97..e6f8eaba8c5 100644
--- a/clang/test/SemaObjC/weak-receiver-warn.m
+++ b/clang/test/SemaObjC/weak-receiver-warn.m
@@ -66,3 +66,15 @@ void test0(Test0 *x) {
}
@end
+
+
+// Weak properties on protocols can be synthesized by an adopting class.
+@protocol MyProtocol
+@property (weak) id object; // expected-note 2 {{property declared here}}
+@end
+
+void testProtocol(id <MyProtocol> input) {
+ [[input object] Meth]; // expected-warning {{weak property may be unpredictably null in ARC mode}}
+ [input.object Meth]; // expected-warning {{weak property may be unpredictably null in ARC mode}}
+}
+
OpenPOWER on IntegriCloud