blob: 13a270b8e6fafafdbb906d688e5249509f0ff976 [file] [log] [blame]
John Thompson82287d12010-02-05 00:12:22 +00001// RUN: %clang_cc1 -faltivec -fsyntax-only -verify %s
2
3// This is the same as the C version:
4
5__vector char vv_c;
6__vector signed char vv_sc;
7__vector unsigned char vv_uc;
8__vector short vv_s;
9__vector signed short vv_ss;
10__vector unsigned short vv_us;
11__vector short int vv_si;
12__vector signed short int vv_ssi;
13__vector unsigned short int vv_usi;
14__vector int vv_i;
15__vector signed int vv_sint;
16__vector unsigned int vv_ui;
17__vector float vv_f;
18__vector bool vv_b;
19__vector __pixel vv_p;
20__vector pixel vv__p;
21__vector int vf__r();
22void vf__a(__vector int a);
23void vf__a2(int b, __vector int a);
24
25vector char v_c;
26vector signed char v_sc;
27vector unsigned char v_uc;
28vector short v_s;
29vector signed short v_ss;
30vector unsigned short v_us;
31vector short int v_si;
32vector signed short int v_ssi;
33vector unsigned short int v_usi;
34vector int v_i;
35vector signed int v_sint;
36vector unsigned int v_ui;
37vector float v_f;
38vector bool v_b;
39vector __pixel v_p;
40vector pixel v__p;
41vector int f__r();
42void f_a(vector int a);
43void f_a2(int b, vector int a);
44
45// These should have warnings.
Chris Lattnerffaf4c52010-03-07 18:50:21 +000046__vector long vv_l; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
47__vector signed long vv_sl; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
48__vector unsigned long vv_ul; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
49__vector long int vv_li; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
50__vector signed long int vv_sli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
51__vector unsigned long int vv_uli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
52vector long v_l; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
53vector signed long v_sl; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
54vector unsigned long v_ul; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
55vector long int v_li; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
56vector signed long int v_sli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
57vector unsigned long int v_uli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
58__vector long double vv_ld; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
59vector long double v_ld; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
John Thompson82287d12010-02-05 00:12:22 +000060
61// These should have errors.
Chris Lattnerffaf4c52010-03-07 18:50:21 +000062__vector double vv_d1; // expected-error {{cannot use 'double' with '__vector'}}
63vector double v_d2; // expected-error {{cannot use 'double' with '__vector'}}
64__vector long double vv_ld3; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
65vector long double v_ld4; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
John Thompson82287d12010-02-05 00:12:22 +000066
67void f() {
68 __vector unsigned int v = {0,0,0,0};
69 __vector int v__cast = (__vector int)v;
70 __vector int v_cast = (vector int)v;
71 __vector char vb_cast = (vector char)v;
72
73 // Check some casting between gcc and altivec vectors.
74 #define gccvector __attribute__((vector_size(16)))
75 gccvector unsigned int gccv = {0,0,0,0};
76 gccvector unsigned int gccv1 = gccv;
77 gccvector int gccv2 = (gccvector int)gccv;
78 gccvector unsigned int gccv3 = v;
79 __vector unsigned int av = gccv;
80 __vector int avi = (__vector int)gccv;
81 gccvector unsigned int gv = v;
82 gccvector int gvi = (gccvector int)v;
83 __attribute__((vector_size(8))) unsigned int gv8;
Douglas Gregord4eea832010-04-09 00:35:39 +000084 gv8 = gccv; // expected-error {{assigning to '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int' from incompatible type '__attribute__((__vector_size__(4 * sizeof(unsigned int)))) unsigned int'}}
85 av = gv8; // expected-error {{assigning to '__vector unsigned int' from incompatible type '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int'}}
John Thompson82287d12010-02-05 00:12:22 +000086
87 v = gccv;
88 __vector unsigned int tv = gccv;
89 gccv = v;
90 gccvector unsigned int tgv = v;
91}
92
93// Now for the C++ version:
94
95class vc__v {
96 __vector int v;
97 __vector int f__r();
98 void f__a(__vector int a);
99 void f__a2(int b, __vector int a);
100};
101
102class c_v {
103 vector int v;
104 vector int f__r();
105 void f__a(vector int a);
106 void f__a2(int b, vector int a);
107};
108