blob: 5e0a2e3766f88144fcc4971ef1cc886f80800d50 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Fariborz Jahanian455acd92009-09-22 19:53:15 +00002
John McCall9a0e5302010-01-08 18:40:32 +00003namespace test0 {
4 struct BASE {
5 operator int &(); // expected-note {{candidate function}}
6 };
7 struct BASE1 {
8 operator int &(); // expected-note {{candidate function}}
9 };
Fariborz Jahanian455acd92009-09-22 19:53:15 +000010
John McCall9a0e5302010-01-08 18:40:32 +000011 struct B : public BASE, BASE1 {};
Fariborz Jahanian455acd92009-09-22 19:53:15 +000012
John McCall9a0e5302010-01-08 18:40:32 +000013 extern B f();
14 B b1;
Fariborz Jahanian455acd92009-09-22 19:53:15 +000015
John McCall9a0e5302010-01-08 18:40:32 +000016 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 Jahanian455acd92009-09-22 19:53:15 +000019
John McCall9a0e5302010-01-08 18:40:32 +000020 const int Test1() {
21 func(b1, f()); // expected-error {{call to 'func' is ambiguous}}
22 return f(); // expected-error {{conversion from 'struct test0::B' to 'int const' is ambiguous}}
23 }
John McCall1d318332010-01-12 00:44:57 +000024
25 // This used to crash when comparing the two operands.
26 void func2(const char cc); // expected-note {{candidate function}}
27 void func2(const int ci); // expected-note {{candidate function}}
28 void Test2() {
29 func2(b1); // expected-error {{call to 'func2' is ambiguous}}
30 }
Fariborz Jahanian455acd92009-09-22 19:53:15 +000031}
32
John McCall9a0e5302010-01-08 18:40:32 +000033namespace test1 {
34 struct E;
35 struct A {
36 A (E&);
37 };
Fariborz Jahanian99d6c442009-09-28 19:06:58 +000038
John McCall9a0e5302010-01-08 18:40:32 +000039 struct E {
40 operator A ();
41 };
Fariborz Jahanian99d6c442009-09-28 19:06:58 +000042
John McCall9a0e5302010-01-08 18:40:32 +000043 struct C {
44 C (E&);
45 };
Fariborz Jahanian99d6c442009-09-28 19:06:58 +000046
John McCall9a0e5302010-01-08 18:40:32 +000047 void f1(A); // expected-note {{candidate function}}
48 void f1(C); // expected-note {{candidate function}}
Fariborz Jahanian99d6c442009-09-28 19:06:58 +000049
John McCall9a0e5302010-01-08 18:40:32 +000050 void Test2()
51 {
52 E b;
53 f1(b); // expected-error {{call to 'f1' is ambiguous}}
54 // ambiguous because b -> C via constructor and
55 // b → A via constructor or conversion function.
56 }
Fariborz Jahanian99d6c442009-09-28 19:06:58 +000057}
58