Fariborz Jahanian | 455acd9 | 2009-09-22 19:53:15 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
| 2 | |
Fariborz Jahanian | 99d6c44 | 2009-09-28 19:06:58 +0000 | [diff] [blame] | 3 | // Test1 |
Fariborz Jahanian | 455acd9 | 2009-09-22 19:53:15 +0000 | [diff] [blame] | 4 | struct BASE { |
Fariborz Jahanian | 99d6c44 | 2009-09-28 19:06:58 +0000 | [diff] [blame] | 5 | operator int &(); // expected-note {{candidate function}} |
Fariborz Jahanian | 455acd9 | 2009-09-22 19:53:15 +0000 | [diff] [blame] | 6 | }; |
| 7 | struct BASE1 { |
Fariborz Jahanian | 99d6c44 | 2009-09-28 19:06:58 +0000 | [diff] [blame] | 8 | operator int &(); // expected-note {{candidate function}} |
Fariborz Jahanian | 455acd9 | 2009-09-22 19:53:15 +0000 | [diff] [blame] | 9 | }; |
| 10 | |
| 11 | struct B : public BASE, BASE1 { |
| 12 | |
| 13 | }; |
| 14 | |
| 15 | extern B f(); |
| 16 | |
Fariborz Jahanian | b1663d0 | 2009-09-23 00:58:07 +0000 | [diff] [blame] | 17 | B b1; |
Fariborz Jahanian | 99d6c44 | 2009-09-28 19:06:58 +0000 | [diff] [blame] | 18 | void func(const int ci, const char cc); // expected-note {{candidate function}} |
| 19 | void func(const char ci, const B b); // expected-note {{candidate function}} |
| 20 | void func(const B b, const int ci); // expected-note {{candidate function}} |
Fariborz Jahanian | b1663d0 | 2009-09-23 00:58:07 +0000 | [diff] [blame] | 21 | |
Fariborz Jahanian | 99d6c44 | 2009-09-28 19:06:58 +0000 | [diff] [blame] | 22 | const int Test1() { |
| 23 | func(b1, f()); // expected-error {{call to 'func' is ambiguous}} |
Fariborz Jahanian | 455acd9 | 2009-09-22 19:53:15 +0000 | [diff] [blame] | 24 | return f(); // expected-error {{conversion from 'struct B' to 'int const' is ambiguous}} |
| 25 | } |
| 26 | |
Fariborz Jahanian | 99d6c44 | 2009-09-28 19:06:58 +0000 | [diff] [blame] | 27 | |
| 28 | // Test2 |
| 29 | struct E; |
| 30 | struct A { |
| 31 | A (E&); |
| 32 | }; |
| 33 | |
| 34 | struct E { |
| 35 | operator A (); |
| 36 | }; |
| 37 | |
| 38 | struct C { |
| 39 | C (E&); |
| 40 | }; |
| 41 | |
| 42 | void f1(A); // expected-note {{candidate function}} |
| 43 | void f1(C); // expected-note {{candidate function}} |
| 44 | |
| 45 | void Test2() |
| 46 | { |
| 47 | E b; |
| 48 | f1(b); // expected-error {{call to 'f1' is ambiguous}} |
| 49 | // ambiguous because b -> C via constructor and |
| 50 | // b → A via constructor or conversion function. |
| 51 | } |
| 52 | |