xref: /llvm-project/clang/test/SemaCXX/user-defined-conversions.cpp (revision f52cdd0124ab47724e193a2ff022e0b767e138e9)
1 // RUN: clang -fsyntax-only -verify %s
2 struct X {
3   operator bool();
4 };
5 
6 int& f(bool);
7 float& f(int);
8 
9 void f_test(X x) {
10   int& i1 = f(x);
11 }
12 
13 struct Y {
14   operator short();
15   operator float();
16 };
17 
18 void g(int);
19 
20 void g_test(Y y) {
21   g(y);
22   short s;
23   s = y;
24 }
25 
26 struct A { };
27 struct B : A { };
28 
29 struct C {
30   operator B&();
31 };
32 
33 // Test reference binding via an lvalue conversion function.
34 void h(volatile A&);
35 void h_test(C c) {
36   h(c);
37 }
38