r202335 - Add category test case for attribute 'objc_protocol_requires_explicit_implementation'.

Ted Kremenek kremenek at apple.com
Wed Feb 26 17:28:58 PST 2014


Author: kremenek
Date: Wed Feb 26 19:28:58 2014
New Revision: 202335

URL: http://llvm.org/viewvc/llvm-project?rev=202335&view=rev
Log:
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.

Modified:
    cfe/trunk/test/SemaObjC/protocols-suppress-conformance.m

Modified: cfe/trunk/test/SemaObjC/protocols-suppress-conformance.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/protocols-suppress-conformance.m?rev=202335&r1=202334&r2=202335&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/protocols-suppress-conformance.m (original)
+++ cfe/trunk/test/SemaObjC/protocols-suppress-conformance.m Wed Feb 26 19:28:58 2014
@@ -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_ex
 @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_ex
 - (void)dunwich {}
 @end
 
+// Categories adopting a protocol with explicit conformance need to implement that protocol.
+ at interface Parent
+- (void) theBestOfTimes;
+ at property (readonly) id theWorstOfTimes;
+ at end
+
+ at interface Derived : Parent
+ at end
+
+ at interface Derived (MyCat) <Protocol>
+ at end
+
+ at implementation Derived (MyCat) // expected-warning {{method 'theBestOfTimes' in protocol 'Protocol' not implemented}}
+ at 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;
 
+





More information about the cfe-commits mailing list