diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2014-03-11 17:10:51 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2014-03-11 17:10:51 +0000 |
commit | bf678e82e12dff0d5c9c0187fc75443a913fc2eb (patch) | |
tree | b089757b4f12bb8189c19e42ddeab70b6866b85a /clang/lib/Sema/SemaDeclObjC.cpp | |
parent | a6839aaa9bd7c75665263a558796d9d10ec89442 (diff) | |
download | bcm5719-llvm-bf678e82e12dff0d5c9c0187fc75443a913fc2eb.tar.gz bcm5719-llvm-bf678e82e12dff0d5c9c0187fc75443a913fc2eb.zip |
Objective-C. Diagose use of undefined protocols
when a class adopts a protocol that inherits from
undefined protocols. // rdar://16111182
llvm-svn: 203586
Diffstat (limited to 'clang/lib/Sema/SemaDeclObjC.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index e19432aea97..4de290b3eb8 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -760,6 +760,22 @@ Sema::ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc, return ActOnObjCContainerStartDefinition(PDecl); } +static bool NestedProtocolHasNoDefinition(ObjCProtocolDecl *PDecl, + ObjCProtocolDecl *&UndefinedProtocol) { + if (!PDecl->hasDefinition() || PDecl->getDefinition()->isHidden()) { + UndefinedProtocol = PDecl; + return true; + } + + for (ObjCProtocolDecl::protocol_iterator PI = PDecl->protocol_begin(), + E = PDecl->protocol_end(); PI != E; ++PI) + if (NestedProtocolHasNoDefinition((*PI), UndefinedProtocol)) { + UndefinedProtocol = (*PI); + return true; + } + return false; +} + /// FindProtocolDeclaration - This routine looks up protocols and /// issues an error if they are not declared. It returns list of /// protocol declarations in its 'Protocols' argument. @@ -795,10 +811,15 @@ Sema::FindProtocolDeclaration(bool WarnOnDeclarations, // If this is a forward declaration and we are supposed to warn in this // case, do it. // FIXME: Recover nicely in the hidden case. + ObjCProtocolDecl *UndefinedProtocol; + if (WarnOnDeclarations && - (!PDecl->hasDefinition() || PDecl->getDefinition()->isHidden())) + NestedProtocolHasNoDefinition(PDecl, UndefinedProtocol)) { Diag(ProtocolId[i].second, diag::warn_undef_protocolref) << ProtocolId[i].first; + Diag(UndefinedProtocol->getLocation(), diag::note_protocol_decl_undefined) + << UndefinedProtocol; + } Protocols.push_back(PDecl); } } |