Clang Project

clang_source_code/test/Sema/altivec-generic-overload.c
1// RUN: %clang_cc1 %s -triple=powerpc64le-unknown-linux -target-feature +altivec -target-feature +vsx -verify -verify-ignore-unexpected=note -pedantic -fsyntax-only
2
3typedef signed char __v16sc __attribute__((__vector_size__(16)));
4typedef unsigned char __v16uc __attribute__((__vector_size__(16)));
5typedef signed short __v8ss __attribute__((__vector_size__(16)));
6typedef unsigned short __v8us __attribute__((__vector_size__(16)));
7typedef signed int __v4si __attribute__((__vector_size__(16)));
8typedef unsigned int __v4ui __attribute__((__vector_size__(16)));
9typedef signed long long __v2sll __attribute__((__vector_size__(16)));
10typedef unsigned long long __v2ull __attribute__((__vector_size__(16)));
11typedef signed __int128 __v1slll __attribute__((__vector_size__(16)));
12typedef unsigned __int128 __v1ulll __attribute__((__vector_size__(16)));
13typedef float __v4f __attribute__((__vector_size__(16)));
14typedef double __v2d __attribute__((__vector_size__(16)));
15
16__v16sc *__attribute__((__overloadable__)) convert1(vector signed char);
17__v16uc *__attribute__((__overloadable__)) convert1(vector unsigned char);
18__v8ss *__attribute__((__overloadable__)) convert1(vector signed short);
19__v8us *__attribute__((__overloadable__)) convert1(vector unsigned short);
20__v4si *__attribute__((__overloadable__)) convert1(vector signed int);
21__v4ui *__attribute__((__overloadable__)) convert1(vector unsigned int);
22__v2sll *__attribute__((__overloadable__)) convert1(vector signed long long);
23__v2ull *__attribute__((__overloadable__)) convert1(vector unsigned long long);
24__v1slll *__attribute__((__overloadable__)) convert1(vector signed __int128);
25__v1ulll *__attribute__((__overloadable__)) convert1(vector unsigned __int128);
26__v4f *__attribute__((__overloadable__)) convert1(vector float);
27__v2d *__attribute__((__overloadable__)) convert1(vector double);
28void __attribute__((__overloadable__)) convert1(vector bool int);
29void __attribute__((__overloadable__)) convert1(vector pixel short);
30
31vector signed char *__attribute__((__overloadable__)) convert2(__v16sc);
32vector unsigned char *__attribute__((__overloadable__)) convert2(__v16uc);
33vector signed short *__attribute__((__overloadable__)) convert2(__v8ss);
34vector unsigned short *__attribute__((__overloadable__)) convert2(__v8us);
35vector signed int *__attribute__((__overloadable__)) convert2(__v4si);
36vector unsigned int *__attribute__((__overloadable__)) convert2(__v4ui);
37vector signed long long *__attribute__((__overloadable__)) convert2(__v2sll);
38vector unsigned long long *__attribute__((__overloadable__)) convert2(__v2ull);
39vector signed __int128 *__attribute__((__overloadable__)) convert2(__v1slll);
40vector unsigned __int128 *__attribute__((__overloadable__)) convert2(__v1ulll);
41vector float *__attribute__((__overloadable__)) convert2(__v4f);
42vector double *__attribute__((__overloadable__)) convert2(__v2d);
43
44void test() {
45  __v16sc gv1;
46  __v16uc gv2;
47  __v8ss gv3;
48  __v8us gv4;
49  __v4si gv5;
50  __v4ui gv6;
51  __v2sll gv7;
52  __v2ull gv8;
53  __v1slll gv9;
54  __v1ulll gv10;
55  __v4f gv11;
56  __v2d gv12;
57
58  vector signed char av1;
59  vector unsigned char av2;
60  vector signed short av3;
61  vector unsigned short av4;
62  vector signed int av5;
63  vector unsigned int av6;
64  vector signed long long av7;
65  vector unsigned long long av8;
66  vector signed __int128 av9;
67  vector unsigned __int128 av10;
68  vector float av11;
69  vector double av12;
70  vector bool int av13;
71  vector pixel short av14;
72
73  __v16sc *gv1_p = convert1(gv1);
74  __v16uc *gv2_p = convert1(gv2);
75  __v8ss *gv3_p = convert1(gv3);
76  __v8us *gv4_p = convert1(gv4);
77  __v4si *gv5_p = convert1(gv5);
78  __v4ui *gv6_p = convert1(gv6);
79  __v2sll *gv7_p = convert1(gv7);
80  __v2ull *gv8_p = convert1(gv8);
81  __v1slll *gv9_p = convert1(gv9);
82  __v1ulll *gv10_p = convert1(gv10);
83  __v4f *gv11_p = convert1(gv11);
84  __v2d *gv12_p = convert1(gv12);
85
86  vector signed char *av1_p = convert2(av1);
87  vector unsigned char *av2_p = convert2(av2);
88  vector signed short *av3_p = convert2(av3);
89  vector unsigned short *av4_p = convert2(av4);
90  vector signed int *av5_p = convert2(av5);
91  vector unsigned int *av6_p = convert2(av6);
92  vector signed long long *av7_p = convert2(av7);
93  vector unsigned long long *av8_p = convert2(av8);
94  vector signed __int128 *av9_p = convert2(av9);
95  vector unsigned __int128 *av10_p = convert2(av10);
96  vector float *av11_p = convert2(av11);
97  vector double *av12_p = convert2(av12);
98  convert2(av13); // expected-error {{call to 'convert2' is ambiguous}}
99  convert2(av14); // expected-error {{call to 'convert2' is ambiguous}}
100}
101