xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/complex-overload.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc char *foo(float);
3*f4a2713aSLionel Sambuc 
test_foo_1(float fv,double dv,float _Complex fc,double _Complex dc)4*f4a2713aSLionel Sambuc void test_foo_1(float fv, double dv, float _Complex fc, double _Complex dc) {
5*f4a2713aSLionel Sambuc   char *cp1 = foo(fv);
6*f4a2713aSLionel Sambuc   char *cp2 = foo(dv);
7*f4a2713aSLionel Sambuc   // Note: GCC and EDG reject these two, but they are valid C99 conversions
8*f4a2713aSLionel Sambuc   char *cp3 = foo(fc);
9*f4a2713aSLionel Sambuc   char *cp4 = foo(dc);
10*f4a2713aSLionel Sambuc }
11*f4a2713aSLionel Sambuc 
12*f4a2713aSLionel Sambuc int *foo(float _Complex);
13*f4a2713aSLionel Sambuc 
test_foo_2(float fv,double dv,float _Complex fc,double _Complex dc)14*f4a2713aSLionel Sambuc void test_foo_2(float fv, double dv, float _Complex fc, double _Complex dc) {
15*f4a2713aSLionel Sambuc   char *cp1 = foo(fv);
16*f4a2713aSLionel Sambuc   char *cp2 = foo(dv);
17*f4a2713aSLionel Sambuc   int *ip = foo(fc);
18*f4a2713aSLionel Sambuc   int *lp = foo(dc);
19*f4a2713aSLionel Sambuc }
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc long *foo(double _Complex);
22*f4a2713aSLionel Sambuc 
test_foo_3(float fv,double dv,float _Complex fc,double _Complex dc)23*f4a2713aSLionel Sambuc void test_foo_3(float fv, double dv, float _Complex fc, double _Complex dc) {
24*f4a2713aSLionel Sambuc   char *cp1 = foo(fv);
25*f4a2713aSLionel Sambuc   char *cp2 = foo(dv);
26*f4a2713aSLionel Sambuc   int *ip = foo(fc);
27*f4a2713aSLionel Sambuc   long *lp = foo(dc);
28*f4a2713aSLionel Sambuc }
29*f4a2713aSLionel Sambuc 
30*f4a2713aSLionel Sambuc char *promote_or_convert(double _Complex);  // expected-note{{candidate function}}
31*f4a2713aSLionel Sambuc int *promote_or_convert(long double _Complex); // expected-note{{candidate function}}
32*f4a2713aSLionel Sambuc 
test_promote_or_convert(float f,float _Complex fc)33*f4a2713aSLionel Sambuc void test_promote_or_convert(float f, float _Complex fc) {
34*f4a2713aSLionel Sambuc   char *cp = promote_or_convert(fc);
35*f4a2713aSLionel Sambuc   int *ip2 = promote_or_convert(f); // expected-error{{call to 'promote_or_convert' is ambiguous}}
36*f4a2713aSLionel Sambuc }
37*f4a2713aSLionel Sambuc 
38*f4a2713aSLionel Sambuc char *promote_or_convert2(float);
39*f4a2713aSLionel Sambuc int *promote_or_convert2(double _Complex);
40*f4a2713aSLionel Sambuc 
test_promote_or_convert2(float _Complex fc)41*f4a2713aSLionel Sambuc void test_promote_or_convert2(float _Complex fc) {
42*f4a2713aSLionel Sambuc   int *cp = promote_or_convert2(fc);
43*f4a2713aSLionel Sambuc }
44*f4a2713aSLionel Sambuc 
45*f4a2713aSLionel Sambuc char *promote_or_convert3(int _Complex); // expected-note {{candidate}}
46*f4a2713aSLionel Sambuc int *promote_or_convert3(long _Complex); // expected-note {{candidate}}
47*f4a2713aSLionel Sambuc 
test_promote_or_convert3(short _Complex sc)48*f4a2713aSLionel Sambuc void test_promote_or_convert3(short _Complex sc) {
49*f4a2713aSLionel Sambuc   char *cp1 = promote_or_convert3(sc);
50*f4a2713aSLionel Sambuc   char *cp2 = promote_or_convert3(1i);
51*f4a2713aSLionel Sambuc   int *cp3 = promote_or_convert3(1il);
52*f4a2713aSLionel Sambuc   int *cp4 = promote_or_convert3(1ill); // expected-error {{ambiguous}}
53*f4a2713aSLionel Sambuc }
54*f4a2713aSLionel Sambuc 
55*f4a2713aSLionel Sambuc char &convert4(short _Complex);
56*f4a2713aSLionel Sambuc char &test_convert4 = convert4(1i);
57