1a5728872c7702ddd09537c95bc3cbd20e1f2fb09Daniel Dunbar// RUN: %clang_cc1 -fsyntax-only -verify %s
223a370f9455698e5501101aea7ad8a884a8d4556Chandler Carruthchar *foo(float) __attribute__((__overloadable__));
3241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor
4241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregorvoid test_foo_1(float fv, double dv, float _Complex fc, double _Complex dc) {
5241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor  char *cp1 = foo(fv);
6241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor  char *cp2 = foo(dv);
7241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor  // Note: GCC and EDG reject these two, but they are valid C99 conversions
8241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor  char *cp3 = foo(fc);
9241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor  char *cp4 = foo(dc);
10241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor}
11241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor
1223a370f9455698e5501101aea7ad8a884a8d4556Chandler Carruthint *foo(float _Complex) __attribute__((__overloadable__));
13241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor
14241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregorvoid test_foo_2(float fv, double dv, float _Complex fc, double _Complex dc) {
15241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor  char *cp1 = foo(fv);
1623a370f9455698e5501101aea7ad8a884a8d4556Chandler Carruth  char *cp2 = foo(dv);
17241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor  int *ip = foo(fc);
1823a370f9455698e5501101aea7ad8a884a8d4556Chandler Carruth  int *lp = foo(dc);
19241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor}
20241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor
2123a370f9455698e5501101aea7ad8a884a8d4556Chandler Carruthlong *foo(double _Complex) __attribute__((__overloadable__));
22241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor
23241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregorvoid test_foo_3(float fv, double dv, float _Complex fc, double _Complex dc) {
24241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor  char *cp1 = foo(fv);
2523a370f9455698e5501101aea7ad8a884a8d4556Chandler Carruth  char *cp2 = foo(dv);
26241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor  int *ip = foo(fc);
27241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor  long *lp = foo(dc);
28241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor}
29241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor
30241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregorchar *promote_or_convert(double _Complex) __attribute__((__overloadable__));  // expected-note 2 {{candidate function}}
31241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregorint *promote_or_convert(long double _Complex) __attribute__((__overloadable__)); // expected-note 2 {{candidate function}}
32241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor
33241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregorvoid test_promote_or_convert(float f, float _Complex fc) {
342fe9b7fb07dff15dd15dd8755a9a9e6de0fe46fcRichard Trieu  char *cp = promote_or_convert(fc); // expected-error{{call to 'promote_or_convert' is ambiguous}}
352fe9b7fb07dff15dd15dd8755a9a9e6de0fe46fcRichard Trieu  int *ip2 = promote_or_convert(f); // expected-error{{call to 'promote_or_convert' is ambiguous}}
36241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor}
37241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor
38241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregorchar *promote_or_convert2(float) __attribute__((__overloadable__));
39241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregorint *promote_or_convert2(double _Complex) __attribute__((__overloadable__));
40241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor
41241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregorvoid test_promote_or_convert2(float _Complex fc) {
42241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor  int *cp = promote_or_convert2(fc);
43241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor}
44241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor
45241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregorchar *promote_or_convert3(int _Complex) __attribute__((__overloadable__));
46241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregorint *promote_or_convert3(long _Complex) __attribute__((__overloadable__));
47241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor
48241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregorvoid test_promote_or_convert3(short _Complex sc) {
49241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor  char *cp = promote_or_convert3(sc);
50241540eb1c46593a93870e20efe6a694444b5f47Douglas Gregor}
51