blob: 1381968751af45e18517aa2a3e55f9f740ac082c [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Chandler Carruth23a370f2010-02-25 07:20:54 +00002char *foo(float);
Douglas Gregor5cdf8212009-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);
7 // Note: GCC and EDG reject these two, but they are valid C99 conversions
8 char *cp3 = foo(fc);
9 char *cp4 = foo(dc);
10}
11
Chandler Carruth23a370f2010-02-25 07:20:54 +000012int *foo(float _Complex);
Douglas Gregor5cdf8212009-02-12 00:15:05 +000013
14void test_foo_2(float fv, double dv, float _Complex fc, double _Complex dc) {
15 char *cp1 = foo(fv);
Chandler Carruth23a370f2010-02-25 07:20:54 +000016 char *cp2 = foo(dv);
Douglas Gregor5cdf8212009-02-12 00:15:05 +000017 int *ip = foo(fc);
Chandler Carruth23a370f2010-02-25 07:20:54 +000018 int *lp = foo(dc);
Douglas Gregor5cdf8212009-02-12 00:15:05 +000019}
20
Chandler Carruth23a370f2010-02-25 07:20:54 +000021long *foo(double _Complex);
Douglas Gregor5cdf8212009-02-12 00:15:05 +000022
23void test_foo_3(float fv, double dv, float _Complex fc, double _Complex dc) {
24 char *cp1 = foo(fv);
Chandler Carruth23a370f2010-02-25 07:20:54 +000025 char *cp2 = foo(dv);
Douglas Gregor5cdf8212009-02-12 00:15:05 +000026 int *ip = foo(fc);
27 long *lp = foo(dc);
28}
29
30char *promote_or_convert(double _Complex); // expected-note{{candidate function}}
31int *promote_or_convert(long double _Complex); // expected-note{{candidate function}}
32
33void test_promote_or_convert(float f, float _Complex fc) {
34 char *cp = promote_or_convert(fc);
Richard Trieu2fe9b7f2011-12-15 00:38:15 +000035 int *ip2 = promote_or_convert(f); // expected-error{{call to 'promote_or_convert' is ambiguous}}
Douglas Gregor5cdf8212009-02-12 00:15:05 +000036}
37
38char *promote_or_convert2(float);
39int *promote_or_convert2(double _Complex);
40
Douglas Gregorb7b5d132009-02-12 00:26:06 +000041void test_promote_or_convert2(float _Complex fc) {
Douglas Gregor5cdf8212009-02-12 00:15:05 +000042 int *cp = promote_or_convert2(fc);
43}
Douglas Gregorb7b5d132009-02-12 00:26:06 +000044
Richard Smith42860f12013-05-10 20:29:50 +000045char *promote_or_convert3(int _Complex); // expected-note {{candidate}}
46int *promote_or_convert3(long _Complex); // expected-note {{candidate}}
Douglas Gregorb7b5d132009-02-12 00:26:06 +000047
48void test_promote_or_convert3(short _Complex sc) {
Richard Smith42860f12013-05-10 20:29:50 +000049 char *cp1 = promote_or_convert3(sc);
50 char *cp2 = promote_or_convert3(1i);
51 int *cp3 = promote_or_convert3(1il);
52 int *cp4 = promote_or_convert3(1ill); // expected-error {{ambiguous}}
Douglas Gregorb7b5d132009-02-12 00:26:06 +000053}
Richard Smith42860f12013-05-10 20:29:50 +000054
55char &convert4(short _Complex);
56char &test_convert4 = convert4(1i);