blob: 94598f0e8ef2ff16e185e58731641e23e07e7151 [file] [log] [blame]
Fariborz Jahanian455acd92009-09-22 19:53:15 +00001// RUN: clang-cc -fsyntax-only -verify %s
2
Fariborz Jahanian99d6c442009-09-28 19:06:58 +00003// Test1
Fariborz Jahanian455acd92009-09-22 19:53:15 +00004struct BASE {
Fariborz Jahanian99d6c442009-09-28 19:06:58 +00005 operator int &(); // expected-note {{candidate function}}
Fariborz Jahanian455acd92009-09-22 19:53:15 +00006};
7struct BASE1 {
Fariborz Jahanian99d6c442009-09-28 19:06:58 +00008 operator int &(); // expected-note {{candidate function}}
Fariborz Jahanian455acd92009-09-22 19:53:15 +00009};
10
11struct B : public BASE, BASE1 {
12
13};
14
15extern B f();
16
Fariborz Jahanianb1663d02009-09-23 00:58:07 +000017B b1;
Fariborz Jahanian99d6c442009-09-28 19:06:58 +000018void func(const int ci, const char cc); // expected-note {{candidate function}}
19void func(const char ci, const B b); // expected-note {{candidate function}}
20void func(const B b, const int ci); // expected-note {{candidate function}}
Fariborz Jahanianb1663d02009-09-23 00:58:07 +000021
Fariborz Jahanian99d6c442009-09-28 19:06:58 +000022const int Test1() {
23 func(b1, f()); // expected-error {{call to 'func' is ambiguous}}
Fariborz Jahanian455acd92009-09-22 19:53:15 +000024 return f(); // expected-error {{conversion from 'struct B' to 'int const' is ambiguous}}
25}
26
Fariborz Jahanian99d6c442009-09-28 19:06:58 +000027
28// Test2
29struct E;
30struct A {
31 A (E&);
32};
33
34struct E {
35 operator A ();
36};
37
38struct C {
39 C (E&);
40};
41
42void f1(A); // expected-note {{candidate function}}
43void f1(C); // expected-note {{candidate function}}
44
45void 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