mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-11 02:16:50 +00:00
Warn on weak properties declared in protocols as well.
Previously this caused a crash, since protocols are not interfaces. llvm-svn: 159357
This commit is contained in:
parent
181d67ecb1
commit
ee3d99f6be
@ -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();
|
||||
}
|
||||
|
@ -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}}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user