1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <complex>
10 
11 // Test that UDT's convertible to an integral or floating point type do not
12 // participate in overload resolution.
13 
14 #include <complex>
15 #include <type_traits>
16 #include <cassert>
17 
18 template <class IntT>
19 struct UDT {
operator IntTUDT20   operator IntT() const { return 1; }
21 };
22 
23 UDT<float> ft;
24 UDT<double> dt;
25 UDT<long double> ldt;
26 UDT<int> it;
27 UDT<unsigned long> uit;
28 
main(int,char **)29 int main(int, char**)
30 {
31     {
32         std::real(ft); // expected-error {{no matching function}}
33         std::real(dt); // expected-error {{no matching function}}
34         std::real(ldt); // expected-error {{no matching function}}
35         std::real(it); // expected-error {{no matching function}}
36         std::real(uit); // expected-error {{no matching function}}
37     }
38     {
39         std::imag(ft); // expected-error {{no matching function}}
40         std::imag(dt); // expected-error {{no matching function}}
41         std::imag(ldt); // expected-error {{no matching function}}
42         std::imag(it); // expected-error {{no matching function}}
43         std::imag(uit); // expected-error {{no matching function}}
44     }
45     {
46         std::arg(ft); // expected-error {{no matching function}}
47         std::arg(dt); // expected-error {{no matching function}}
48         std::arg(ldt); // expected-error {{no matching function}}
49         std::arg(it); // expected-error {{no matching function}}
50         std::arg(uit); // expected-error {{no matching function}}
51     }
52     {
53         std::norm(ft); // expected-error {{no matching function}}
54         std::norm(dt); // expected-error {{no matching function}}
55         std::norm(ldt); // expected-error {{no matching function}}
56         std::norm(it); // expected-error {{no matching function}}
57         std::norm(uit); // expected-error {{no matching function}}
58     }
59     {
60         std::conj(ft); // expected-error {{no matching function}}
61         std::conj(dt); // expected-error {{no matching function}}
62         std::conj(ldt); // expected-error {{no matching function}}
63         std::conj(it); // expected-error {{no matching function}}
64         std::conj(uit); // expected-error {{no matching function}}
65     }
66     {
67         std::proj(ft); // expected-error {{no matching function}}
68         std::proj(dt); // expected-error {{no matching function}}
69         std::proj(ldt); // expected-error {{no matching function}}
70         std::proj(it); // expected-error {{no matching function}}
71         std::proj(uit); // expected-error {{no matching function}}
72     }
73 
74   return 0;
75 }
76