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
This commit is contained in:
Ted Kremenek 2014-02-27 01:28:58 +00:00
parent e4200a291b
commit 294c08265d
1 changed files with 17 additions and 2 deletions

View File

@ -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 <ProtocolB_Explicit> @end
@interface Shoggoth_2_Explicit : Lovecraft_2 <ProtocolB_Explicit> @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) <Protocol>
@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;