1f4a2713aSLionel Sambuc// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -verify 2f4a2713aSLionel Sambuc 3f4a2713aSLionel Sambuc@interface A 4f4a2713aSLionel Sambuc- knownMethod; 5f4a2713aSLionel Sambuc@end 6f4a2713aSLionel Sambuc 7f4a2713aSLionel Sambuc@interface B 8f4a2713aSLionel Sambuc- unknownMethod; 9f4a2713aSLionel Sambuc@end 10f4a2713aSLionel Sambuc 11*0a6a1f1dSLionel Sambuc@interface C : A 12*0a6a1f1dSLionel Sambuc- knownMethod; 13*0a6a1f1dSLionel Sambuc@end 14*0a6a1f1dSLionel Sambuc 15f4a2713aSLionel Sambuctemplate<typename T> struct RetainPtr { 16f4a2713aSLionel Sambuc explicit operator T*() const; 17f4a2713aSLionel Sambuc}; 18f4a2713aSLionel Sambuc 19f4a2713aSLionel Sambucvoid methodCallToSpecific(RetainPtr<A> a) { 20f4a2713aSLionel Sambuc [a knownMethod]; 21f4a2713aSLionel Sambuc [a unknownMethod]; // expected-warning{{'A' may not respond to 'unknownMethod'}} 22f4a2713aSLionel Sambuc} 23f4a2713aSLionel Sambuc 24*0a6a1f1dSLionel Sambucvoid explicitCast(RetainPtr<A> a, RetainPtr<B> b, RetainPtr<C> c) { 25*0a6a1f1dSLionel Sambuc (void)(A*)a; 26*0a6a1f1dSLionel Sambuc (void)(A*)b; // expected-error{{cannot convert 'RetainPtr<B>' to 'A *' without a conversion operator}} 27*0a6a1f1dSLionel Sambuc (void)(A*)c; 28*0a6a1f1dSLionel Sambuc (void)(C*)a; 29*0a6a1f1dSLionel Sambuc (void)static_cast<A*>(a); 30*0a6a1f1dSLionel Sambuc (void)static_cast<A*>(b); // expected-error{{cannot convert 'RetainPtr<B>' to 'A *' without a conversion operator}} 31*0a6a1f1dSLionel Sambuc (void)static_cast<A*>(c); 32*0a6a1f1dSLionel Sambuc} 33*0a6a1f1dSLionel Sambuc 34f4a2713aSLionel Sambucstruct Incomplete; // expected-note{{forward declaration}} 35f4a2713aSLionel Sambuc 36f4a2713aSLionel Sambucvoid methodCallToIncomplete(Incomplete &incomplete) { 37f4a2713aSLionel Sambuc [incomplete knownMethod]; // expected-error{{incomplete receiver type 'Incomplete'}} 38f4a2713aSLionel Sambuc} 39f4a2713aSLionel Sambuc 40f4a2713aSLionel Sambucstruct IdPtr { 41f4a2713aSLionel Sambuc explicit operator id() const; 42f4a2713aSLionel Sambuc}; 43f4a2713aSLionel Sambuc 44f4a2713aSLionel Sambucvoid methodCallToId(IdPtr a) { 45f4a2713aSLionel Sambuc [a knownMethod]; 46f4a2713aSLionel Sambuc [a unknownMethod]; 47f4a2713aSLionel Sambuc} 48*0a6a1f1dSLionel Sambuc 49*0a6a1f1dSLionel Sambucvoid explicitCast(IdPtr a) { 50*0a6a1f1dSLionel Sambuc (void)(A*)a; 51*0a6a1f1dSLionel Sambuc (void)static_cast<A*>(a); 52*0a6a1f1dSLionel Sambuc} 53