[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / SemaCXX / ambig-user-defined-conversions.cpp
blob0fa09b0b722867f92e0163e17b9945cafbe4187c
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
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 };
11 struct B : public BASE, BASE1 {};
13 extern B f();
14 B b1;
16 void func(const int ci, const char cc);
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}}
20 const int Test1() {
22 func(b1, f()); // expected-error {{call to 'func' is ambiguous}}
23 return f(); // expected-error {{conversion from 'B' to 'const int' is ambiguous}}
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}}
34 namespace test1 {
35 struct E;
36 struct A {
37 A (E&);
40 struct E {
41 operator A ();
44 struct C {
45 C (E&);
48 void f1(A); // expected-note {{candidate function}}
49 void f1(C); // expected-note {{candidate function}}
51 void Test2()
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.
60 namespace rdar8876150 {
61 struct A { operator bool(); };
62 struct B : A { };
63 struct C : A { };
64 struct D : B, C { };
66 bool f(D d) { return !d; } // expected-error{{ambiguous conversion from derived class 'D' to base class 'rdar8876150::A':}}
69 namespace assignment {
70 struct A { operator short(); operator bool(); }; // expected-note 2{{candidate}}
71 void f(int n, A a) { n = a; } // expected-error{{ambiguous}}