Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Fariborz Jahanian | 455acd9 | 2009-09-22 19:53:15 +0000 | [diff] [blame] | 2 | |
John McCall | 9a0e530 | 2010-01-08 18:40:32 +0000 | [diff] [blame] | 3 | namespace test0 { |
| 4 | struct BASE { |
| 5 | operator int &(); // expected-note {{candidate function}} |
| 6 | }; |
| 7 | struct BASE1 { |
| 8 | operator int &(); // expected-note {{candidate function}} |
| 9 | }; |
Fariborz Jahanian | 455acd9 | 2009-09-22 19:53:15 +0000 | [diff] [blame] | 10 | |
John McCall | 9a0e530 | 2010-01-08 18:40:32 +0000 | [diff] [blame] | 11 | struct B : public BASE, BASE1 {}; |
Fariborz Jahanian | 455acd9 | 2009-09-22 19:53:15 +0000 | [diff] [blame] | 12 | |
John McCall | 9a0e530 | 2010-01-08 18:40:32 +0000 | [diff] [blame] | 13 | extern B f(); |
| 14 | B b1; |
Fariborz Jahanian | 455acd9 | 2009-09-22 19:53:15 +0000 | [diff] [blame] | 15 | |
John McCall | 9a0e530 | 2010-01-08 18:40:32 +0000 | [diff] [blame] | 16 | void func(const int ci, const char cc); // expected-note {{candidate function}} |
| 17 | void func(const char ci, const B b); // expected-note {{candidate function}} |
| 18 | void func(const B b, const int ci); // expected-note {{candidate function}} |
Fariborz Jahanian | 455acd9 | 2009-09-22 19:53:15 +0000 | [diff] [blame] | 19 | |
Chandler Carruth | 5495f37 | 2010-07-14 06:36:18 +0000 | [diff] [blame] | 20 | const int Test1() { |
Douglas Gregor | 5291c3c | 2010-07-13 08:18:22 +0000 | [diff] [blame] | 21 | |
John McCall | 9a0e530 | 2010-01-08 18:40:32 +0000 | [diff] [blame] | 22 | func(b1, f()); // expected-error {{call to 'func' is ambiguous}} |
Chris Lattner | 58f9e13 | 2010-09-05 00:04:01 +0000 | [diff] [blame] | 23 | return f(); // expected-error {{conversion from 'test0::B' to 'const int' is ambiguous}} |
John McCall | 9a0e530 | 2010-01-08 18:40:32 +0000 | [diff] [blame] | 24 | } |
John McCall | 1d31833 | 2010-01-12 00:44:57 +0000 | [diff] [blame] | 25 | |
| 26 | // This used to crash when comparing the two operands. |
| 27 | void func2(const char cc); // expected-note {{candidate function}} |
| 28 | void func2(const int ci); // expected-note {{candidate function}} |
| 29 | void Test2() { |
| 30 | func2(b1); // expected-error {{call to 'func2' is ambiguous}} |
| 31 | } |
Fariborz Jahanian | 455acd9 | 2009-09-22 19:53:15 +0000 | [diff] [blame] | 32 | } |
| 33 | |
John McCall | 9a0e530 | 2010-01-08 18:40:32 +0000 | [diff] [blame] | 34 | namespace test1 { |
| 35 | struct E; |
| 36 | struct A { |
| 37 | A (E&); |
| 38 | }; |
Fariborz Jahanian | 99d6c44 | 2009-09-28 19:06:58 +0000 | [diff] [blame] | 39 | |
John McCall | 9a0e530 | 2010-01-08 18:40:32 +0000 | [diff] [blame] | 40 | struct E { |
| 41 | operator A (); |
| 42 | }; |
Fariborz Jahanian | 99d6c44 | 2009-09-28 19:06:58 +0000 | [diff] [blame] | 43 | |
John McCall | 9a0e530 | 2010-01-08 18:40:32 +0000 | [diff] [blame] | 44 | struct C { |
| 45 | C (E&); |
| 46 | }; |
Fariborz Jahanian | 99d6c44 | 2009-09-28 19:06:58 +0000 | [diff] [blame] | 47 | |
John McCall | 9a0e530 | 2010-01-08 18:40:32 +0000 | [diff] [blame] | 48 | void f1(A); // expected-note {{candidate function}} |
| 49 | void f1(C); // expected-note {{candidate function}} |
Fariborz Jahanian | 99d6c44 | 2009-09-28 19:06:58 +0000 | [diff] [blame] | 50 | |
John McCall | 9a0e530 | 2010-01-08 18:40:32 +0000 | [diff] [blame] | 51 | void Test2() |
| 52 | { |
| 53 | E b; |
| 54 | f1(b); // expected-error {{call to 'f1' is ambiguous}} |
| 55 | // ambiguous because b -> C via constructor and |
| 56 | // b → A via constructor or conversion function. |
| 57 | } |
Fariborz Jahanian | 99d6c44 | 2009-09-28 19:06:58 +0000 | [diff] [blame] | 58 | } |
| 59 | |
Douglas Gregor | f2ae526 | 2011-01-20 00:18:04 +0000 | [diff] [blame] | 60 | namespace rdar8876150 { |
| 61 | struct A { operator bool(); }; |
| 62 | struct B : A { }; |
| 63 | struct C : A { }; |
| 64 | struct D : B, C { }; |
| 65 | |
| 66 | bool f(D d) { return !d; } // expected-error{{ambiguous conversion from derived class 'rdar8876150::D' to base class 'rdar8876150::A':}} |
| 67 | } |