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