xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/overloadable-complex.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc char *foo(float) __attribute__((__overloadable__));
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) __attribute__((__overloadable__));
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) __attribute__((__overloadable__));
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) __attribute__((__overloadable__));  // expected-note 2 {{candidate function}}
31*f4a2713aSLionel Sambuc int *promote_or_convert(long double _Complex) __attribute__((__overloadable__)); // expected-note 2 {{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); // expected-error{{call to 'promote_or_convert' is ambiguous}}
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) __attribute__((__overloadable__));
39*f4a2713aSLionel Sambuc int *promote_or_convert2(double _Complex) __attribute__((__overloadable__));
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) __attribute__((__overloadable__));
46*f4a2713aSLionel Sambuc int *promote_or_convert3(long _Complex) __attribute__((__overloadable__));
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 *cp = promote_or_convert3(sc);
50*f4a2713aSLionel Sambuc }
51