1a5728872c7702ddd09537c95bc3cbd20e1f2fb09Daniel Dunbar// RUN: %clang_cc1 -fsyntax-only -verify %s 2455acd9452f5b2a69d7ab8e53f733e46b500473aFariborz Jahanian 39a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCallnamespace test0 { 49a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall struct BASE { 59a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall operator int &(); // expected-note {{candidate function}} 69a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall }; 79a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall struct BASE1 { 89a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall operator int &(); // expected-note {{candidate function}} 99a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall }; 109a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall 119a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall struct B : public BASE, BASE1 {}; 129a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall 139a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall extern B f(); 149a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall B b1; 159a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall 169a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall void func(const int ci, const char cc); // expected-note {{candidate function}} 179a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall void func(const char ci, const B b); // expected-note {{candidate function}} 189a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall void func(const B b, const int ci); // expected-note {{candidate function}} 199a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall 205495f37302f7c82192dab1ce8d9c9fe76ed0ee37Chandler Carruth const int Test1() { 215291c3cec0dbe8ad1d8e7e67e93af2b1586d5400Douglas Gregor 229a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall func(b1, f()); // expected-error {{call to 'func' is ambiguous}} 2358f9e13e87e57236fee4b914eea9be6f92a1c345Chris Lattner return f(); // expected-error {{conversion from 'test0::B' to 'const int' is ambiguous}} 249a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall } 251d31833450e6d2947a33cb0840d87661d92eec07John McCall 261d31833450e6d2947a33cb0840d87661d92eec07John McCall // This used to crash when comparing the two operands. 271d31833450e6d2947a33cb0840d87661d92eec07John McCall void func2(const char cc); // expected-note {{candidate function}} 281d31833450e6d2947a33cb0840d87661d92eec07John McCall void func2(const int ci); // expected-note {{candidate function}} 291d31833450e6d2947a33cb0840d87661d92eec07John McCall void Test2() { 301d31833450e6d2947a33cb0840d87661d92eec07John McCall func2(b1); // expected-error {{call to 'func2' is ambiguous}} 311d31833450e6d2947a33cb0840d87661d92eec07John McCall } 32455acd9452f5b2a69d7ab8e53f733e46b500473aFariborz Jahanian} 33455acd9452f5b2a69d7ab8e53f733e46b500473aFariborz Jahanian 349a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCallnamespace test1 { 359a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall struct E; 369a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall struct A { 379a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall A (E&); 389a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall }; 399a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall 409a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall struct E { 419a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall operator A (); 429a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall }; 439a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall 449a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall struct C { 459a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall C (E&); 469a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall }; 479a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall 489a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall void f1(A); // expected-note {{candidate function}} 499a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall void f1(C); // expected-note {{candidate function}} 509a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall 519a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall void Test2() 529a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall { 539a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall E b; 549a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall f1(b); // expected-error {{call to 'f1' is ambiguous}} 559a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall // ambiguous because b -> C via constructor and 56ddddd48da72bc29d1c3f388ed91ea5549328129eNAKAMURA Takumi // b -> A via constructor or conversion function. 579a0e530ba8ea87a6478e166daecc847eec91cecfJohn McCall } 5899d6c445cc968bdf08c53a6bd4e9044bde43bdd1Fariborz Jahanian} 5999d6c445cc968bdf08c53a6bd4e9044bde43bdd1Fariborz Jahanian 60f2ae52605a49e5fc7a581f2c1ae02f1811034578Douglas Gregornamespace rdar8876150 { 61f2ae52605a49e5fc7a581f2c1ae02f1811034578Douglas Gregor struct A { operator bool(); }; 62f2ae52605a49e5fc7a581f2c1ae02f1811034578Douglas Gregor struct B : A { }; 63f2ae52605a49e5fc7a581f2c1ae02f1811034578Douglas Gregor struct C : A { }; 64f2ae52605a49e5fc7a581f2c1ae02f1811034578Douglas Gregor struct D : B, C { }; 65f2ae52605a49e5fc7a581f2c1ae02f1811034578Douglas Gregor 66f2ae52605a49e5fc7a581f2c1ae02f1811034578Douglas Gregor bool f(D d) { return !d; } // expected-error{{ambiguous conversion from derived class 'rdar8876150::D' to base class 'rdar8876150::A':}} 67f2ae52605a49e5fc7a581f2c1ae02f1811034578Douglas Gregor} 68