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