blob: 9373e44de9504acda7d42ef86be08ecd9d46bc6f [file] [log] [blame]
Daniel Dunbar8fbe78f2009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Chandler Carruth8fa1e7e2010-02-25 07:20:54 +00002char *foo(float);
Douglas Gregor78ca74d2009-02-12 00:15:05 +00003
4void test_foo_1(float fv, double dv, float _Complex fc, double _Complex dc) {
5 char *cp1 = foo(fv);
6 char *cp2 = foo(dv);
Tim Northover02416372017-08-08 23:18:05 +00007 // 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++}}
Douglas Gregor78ca74d2009-02-12 00:15:05 +000011}
12
Chandler Carruth8fa1e7e2010-02-25 07:20:54 +000013int *foo(float _Complex);
Douglas Gregor78ca74d2009-02-12 00:15:05 +000014
15void test_foo_2(float fv, double dv, float _Complex fc, double _Complex dc) {
16 char *cp1 = foo(fv);
Chandler Carruth8fa1e7e2010-02-25 07:20:54 +000017 char *cp2 = foo(dv);
Douglas Gregor78ca74d2009-02-12 00:15:05 +000018 int *ip = foo(fc);
Chandler Carruth8fa1e7e2010-02-25 07:20:54 +000019 int *lp = foo(dc);
Douglas Gregor78ca74d2009-02-12 00:15:05 +000020}
21
Chandler Carruth8fa1e7e2010-02-25 07:20:54 +000022long *foo(double _Complex);
Douglas Gregor78ca74d2009-02-12 00:15:05 +000023
24void test_foo_3(float fv, double dv, float _Complex fc, double _Complex dc) {
25 char *cp1 = foo(fv);
Chandler Carruth8fa1e7e2010-02-25 07:20:54 +000026 char *cp2 = foo(dv);
Douglas Gregor78ca74d2009-02-12 00:15:05 +000027 int *ip = foo(fc);
28 long *lp = foo(dc);
29}
30
31char *promote_or_convert(double _Complex); // expected-note{{candidate function}}
32int *promote_or_convert(long double _Complex); // expected-note{{candidate function}}
33
34void test_promote_or_convert(float f, float _Complex fc) {
35 char *cp = promote_or_convert(fc);
Richard Trieu553b2b22011-12-15 00:38:15 +000036 int *ip2 = promote_or_convert(f); // expected-error{{call to 'promote_or_convert' is ambiguous}}
Douglas Gregor78ca74d2009-02-12 00:15:05 +000037}
38
39char *promote_or_convert2(float);
40int *promote_or_convert2(double _Complex);
41
Douglas Gregor67525022009-02-12 00:26:06 +000042void test_promote_or_convert2(float _Complex fc) {
Douglas Gregor78ca74d2009-02-12 00:15:05 +000043 int *cp = promote_or_convert2(fc);
44}
Douglas Gregor67525022009-02-12 00:26:06 +000045
Richard Smithb8a98242013-05-10 20:29:50 +000046char *promote_or_convert3(int _Complex); // expected-note {{candidate}}
47int *promote_or_convert3(long _Complex); // expected-note {{candidate}}
Douglas Gregor67525022009-02-12 00:26:06 +000048
49void test_promote_or_convert3(short _Complex sc) {
Richard Smithb8a98242013-05-10 20:29:50 +000050 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}}
Douglas Gregor67525022009-02-12 00:26:06 +000054}
Richard Smithb8a98242013-05-10 20:29:50 +000055
56char &convert4(short _Complex);
57char &test_convert4 = convert4(1i);