From 294c08265dbd9ba80e0e8fda22dbe93775b25b11 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 27 Feb 2014 01:28:58 +0000 Subject: [PATCH] Add category test case for attribute 'objc_protocol_requires_explicit_implementation'. This test also illustrates that checking for properties is not working properly with this attribute, as we are missing a diagnostic for a property not being implemented. llvm-svn: 202335 --- .../SemaObjC/protocols-suppress-conformance.m | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/clang/test/SemaObjC/protocols-suppress-conformance.m b/clang/test/SemaObjC/protocols-suppress-conformance.m index 9ec2a1ae8b78..460b78fff37b 100644 --- a/clang/test/SemaObjC/protocols-suppress-conformance.m +++ b/clang/test/SemaObjC/protocols-suppress-conformance.m @@ -4,7 +4,7 @@ // to be explicitly implemented in the adopting class. __attribute__((objc_protocol_requires_explicit_implementation)) @protocol Protocol -- (void) theBestOfTimes; // expected-note {{method 'theBestOfTimes' declared here}} +- (void) theBestOfTimes; // expected-note 2 {{method 'theBestOfTimes' declared here}} @property (readonly) id theWorstOfTimes; // expected-note {{property declared here}} @end @@ -122,7 +122,6 @@ __attribute__((objc_protocol_requires_explicit_implementation)) @interface Shoggoth_Explicit : Lovecraft @end @interface Shoggoth_2_Explicit : Lovecraft_2 @end - @implementation MyObject - (void)innsmouth {} - (void)rlyeh {} @@ -154,6 +153,22 @@ __attribute__((objc_protocol_requires_explicit_implementation)) - (void)dunwich {} @end +// Categories adopting a protocol with explicit conformance need to implement that protocol. +@interface Parent +- (void) theBestOfTimes; +@property (readonly) id theWorstOfTimes; +@end + +@interface Derived : Parent +@end + +@interface Derived (MyCat) +@end + +@implementation Derived (MyCat) // expected-warning {{method 'theBestOfTimes' in protocol 'Protocol' not implemented}} +@end + __attribute__((objc_protocol_requires_explicit_implementation)) // expected-error{{attribute 'objc_protocol_requires_explicit_implementation' can only be applied to @protocol definitions, not forward declarations}} @protocol NotDefined; +