// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -verify %s -Wno-objc-root-class
// Mark this protocol as requiring all of its methods and properties
// to be explicitly implemented in the adopting class.
@protocol - theBestOfTimes; // expected-note {{method 'theBestOfTimes' declared here}}
@ id theWorstOfTimes; // expected-note {{property declared here}}
@end
// In this example, ClassA adopts the protocol. We won't
// provide the implementation here, but this protocol will
// be adopted later by a subclass.
// This class subclasses ClassA (which also adopts 'Protocol').
// Default synthesis acts as if @dynamic
// had been written for 'theWorstOfTimes' because
// it is declared in ClassA. This is okay, since
// the author of ClassB_AlsoGood needs explicitly
// write @property in the @interface.
// Test that inherited protocols do not get the explicit conformance requirement.
@protocol Derived <Inherited>
- foulIsFair; // expected-note {{method 'foulIsFair' declared here}}
@end
// Test that the attribute is used correctly.
// expected-error {{attribute takes no arguments}}
@protocol AnotherProtocol @end
// Cannot put the attribute on classes or other non-protocol declarations.
// expected-error {{attribute only applies to Objective-C protocols}}
// expected-error {{attribute only applies to Objective-C protocols}}
int x;
// Test that inherited protocols with the attribute
// are treated properly.
@protocol @required
- rlyeh; // expected-note 2 {{method 'rlyeh' declared here}}
- innsmouth; // expected-note 2 {{method 'innsmouth' declared here}}
@end
@protocol ProtocolB_Explicit <ProtocolA>
@required
- dunwich;
- innsmouth; // expected-note 2 {{method 'innsmouth' declared here}}
@end
// Provide two variants of a base class, one that adopts ProtocolA and
// one that does not.
// Provide two variants of a subclass that conform to ProtocolB. One
// subclasses from a class that conforms to ProtocolA, the other that
// does not.
//
// From those, provide two variants that conformat to ProtocolB_Explicit
// instead.
// Categories adopting a protocol with explicit conformance need to implement that protocol.
// expected-error{{attribute 'objc_protocol_requires_explicit_implementation' can only be applied to @protocol definitions, not forward declarations}}
@protocol NotDefined;
// Another complete hierarchy.
@protocol - methodA;
@end
@protocol - methodB;
@end
@protocol Ex2ProtocolB <Ex2ProtocolA>
- methodA; // expected-note {{method 'methodA' declared here}}
@end
// NOT required