1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify %s 2*67e74705SXin Li 3*67e74705SXin Li namespace test0 { 4*67e74705SXin Li struct BASE { 5*67e74705SXin Li operator int &(); // expected-note {{candidate function}} 6*67e74705SXin Li }; 7*67e74705SXin Li struct BASE1 { 8*67e74705SXin Li operator int &(); // expected-note {{candidate function}} 9*67e74705SXin Li }; 10*67e74705SXin Li 11*67e74705SXin Li struct B : public BASE, BASE1 {}; 12*67e74705SXin Li 13*67e74705SXin Li extern B f(); 14*67e74705SXin Li B b1; 15*67e74705SXin Li 16*67e74705SXin Li void func(const int ci, const char cc); // expected-note {{candidate function}} 17*67e74705SXin Li void func(const char ci, const B b); // expected-note {{candidate function}} 18*67e74705SXin Li void func(const B b, const int ci); // expected-note {{candidate function}} 19*67e74705SXin Li Test1()20*67e74705SXin Li const int Test1() { 21*67e74705SXin Li 22*67e74705SXin Li func(b1, f()); // expected-error {{call to 'func' is ambiguous}} 23*67e74705SXin Li return f(); // expected-error {{conversion from 'test0::B' to 'const int' is ambiguous}} 24*67e74705SXin Li } 25*67e74705SXin Li 26*67e74705SXin Li // This used to crash when comparing the two operands. 27*67e74705SXin Li void func2(const char cc); // expected-note {{candidate function}} 28*67e74705SXin Li void func2(const int ci); // expected-note {{candidate function}} Test2()29*67e74705SXin Li void Test2() { 30*67e74705SXin Li func2(b1); // expected-error {{call to 'func2' is ambiguous}} 31*67e74705SXin Li } 32*67e74705SXin Li } 33*67e74705SXin Li 34*67e74705SXin Li namespace test1 { 35*67e74705SXin Li struct E; 36*67e74705SXin Li struct A { 37*67e74705SXin Li A (E&); 38*67e74705SXin Li }; 39*67e74705SXin Li 40*67e74705SXin Li struct E { 41*67e74705SXin Li operator A (); 42*67e74705SXin Li }; 43*67e74705SXin Li 44*67e74705SXin Li struct C { 45*67e74705SXin Li C (E&); 46*67e74705SXin Li }; 47*67e74705SXin Li 48*67e74705SXin Li void f1(A); // expected-note {{candidate function}} 49*67e74705SXin Li void f1(C); // expected-note {{candidate function}} 50*67e74705SXin Li Test2()51*67e74705SXin Li void Test2() 52*67e74705SXin Li { 53*67e74705SXin Li E b; 54*67e74705SXin Li f1(b); // expected-error {{call to 'f1' is ambiguous}} 55*67e74705SXin Li // ambiguous because b -> C via constructor and 56*67e74705SXin Li // b -> A via constructor or conversion function. 57*67e74705SXin Li } 58*67e74705SXin Li } 59*67e74705SXin Li 60*67e74705SXin Li namespace rdar8876150 { 61*67e74705SXin Li struct A { operator bool(); }; 62*67e74705SXin Li struct B : A { }; 63*67e74705SXin Li struct C : A { }; 64*67e74705SXin Li struct D : B, C { }; 65*67e74705SXin Li f(D d)66*67e74705SXin Li bool f(D d) { return !d; } // expected-error{{ambiguous conversion from derived class 'rdar8876150::D' to base class 'rdar8876150::A':}} 67*67e74705SXin Li } 68