bool& IncompleteImpl,
const Sema::SelectorSet &InsMap,
const Sema::SelectorSet &ClsMap,
- ObjCContainerDecl *CDecl) {
+ ObjCContainerDecl *CDecl,
+ bool isExplicitProtocol = true) {
ObjCCategoryDecl *C = dyn_cast<ObjCCategoryDecl>(CDecl);
ObjCInterfaceDecl *IDecl = C ? C->getClassInterface()
: dyn_cast<ObjCInterfaceDecl>(CDecl);
// the method was implemented by a base class or an inherited
// protocol. This lookup is slow, but occurs rarely in correct code
// and otherwise would terminate in a warning.
- if (PDecl->hasAttr<ObjCExplicitProtocolImplAttr>())
+ if (isExplicitProtocol && PDecl->hasAttr<ObjCExplicitProtocolImplAttr>())
Super = NULL;
// check unimplemented instance methods.
for (ObjCProtocolDecl::protocol_iterator PI = PDecl->protocol_begin(),
E = PDecl->protocol_end(); PI != E; ++PI)
CheckProtocolMethodDefs(S, ImpLoc, *PI, IncompleteImpl, InsMap, ClsMap,
- CDecl);
+ CDecl, /* isExplicitProtocl */ false);
}
/// MatchAllMethodDeclarations - Check methods declared in interface
__attribute__((objc_protocol_requires_explicit_implementation)) // expected-error {{attribute only applies to Objective-C protocols}}
int x;
+// Test that inherited protocols with the attribute
+// are treated properly.
+__attribute__((objc_protocol_requires_explicit_implementation))
+@protocol ProtocolA
+@required
+- (void)rlyeh;
+- (void)innsmouth;
+@end
+
+@protocol ProtocolB <ProtocolA>
+@required
+- (void)dunwich;
+- (id)innsmouth;
+@end
+
+@protocol ProtocolC
+@required
+- (void)rlyeh;
+- (void)innsmouth;
+- (void)dunwich;
+@end
+
+@interface MyObject <ProtocolC>
+@end
+
+@interface MyLovecraft <ProtocolA>
+@end
+
+@interface MyShoggoth : MyLovecraft <ProtocolB>
+@end
+
+@implementation MyObject
+- (void)innsmouth {}
+- (void)rlyeh {}
+- (void)dunwich {}
+@end
+
+@implementation MyLovecraft
+- (void)innsmouth {}
+- (void)rlyeh {}
+@end
+
+@implementation MyShoggoth
+- (void)dunwich {}
+@end
+