[Clang/AMDGPU] Zero sized arrays not allowed in HIP device code. (#113470)
[llvm-project.git] / clang / test / SemaCXX / user-defined-conversions.cpp
blobfed1cc6eabef4adad899b023c49413d53b2f3a60
1 // RUN: %clang_cc1 -fsyntax-only -verify=expected,precxx17 %std_cxx98-14 %s
2 // RUN: %clang_cc1 -fsyntax-only -verify=expected %std_cxx17- %s
3 struct X {
4 operator bool();
5 };
7 int& f(bool);
8 float& f(int);
10 void f_test(X x) {
11 int& i1 = f(x);
14 struct Y {
15 operator short();
16 operator float();
19 void g(int);
21 void g_test(Y y) {
22 g(y);
23 short s;
24 s = y;
27 struct A { };
28 struct B : A { };
30 struct C {
31 operator B&();
34 // Test reference binding via an lvalue conversion function.
35 void h(volatile A&);
36 void h_test(C c) {
37 h(c);
40 // Test conversion followed by copy-construction
41 struct FunkyDerived;
43 struct Base {
44 Base(const FunkyDerived&);
47 struct Derived : Base { };
49 struct FunkyDerived : Base { };
51 struct ConvertibleToBase {
52 operator Base();
55 struct ConvertibleToDerived {
56 operator Derived();
59 struct ConvertibleToFunkyDerived {
60 operator FunkyDerived();
63 void test_conversion(ConvertibleToBase ctb, ConvertibleToDerived ctd,
64 ConvertibleToFunkyDerived ctfd) {
65 Base b1 = ctb;
66 Base b2(ctb);
67 Base b3 = ctd;
68 Base b4(ctd);
69 Base b5 = ctfd;
72 struct X1 {
73 X1(X1&); // precxx17-note{{candidate constructor not viable: expects an lvalue for 1st argument}}
76 struct X2 {
77 operator X1();
80 int &f(X1);
81 float &f(...);
83 void g(X2 b) {
84 int &ir = f(b); // precxx17-error{{no viable constructor copying parameter of type 'X1'}}
87 namespace rdar10202900 {
88 class A {
89 public:
90 A();
92 private:
93 A(int i); // expected-note{{declared private here}}
96 void testA(A a) {
97 int b = 10;
98 a = b; // expected-error{{calling a private constructor of class 'rdar10202900::A'}}