blob: ed144573fcd296c9d7a259020bf0e6fc71043e04 [file] [log] [blame]
Chris Lattnerdd173942010-04-14 03:54:58 +00001// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -faltivec -fsyntax-only -verify %s
John Thompson82287d12010-02-05 00:12:22 +00002
3__vector char vv_c;
4__vector signed char vv_sc;
5__vector unsigned char vv_uc;
6__vector short vv_s;
7__vector signed short vv_ss;
8__vector unsigned short vv_us;
9__vector short int vv_si;
10__vector signed short int vv_ssi;
11__vector unsigned short int vv_usi;
12__vector int vv_i;
13__vector signed int vv_sint;
14__vector unsigned int vv_ui;
15__vector float vv_f;
16__vector bool vv_b;
17__vector __pixel vv_p;
18__vector pixel vv__p;
19__vector int vf__r();
20void vf__a(__vector int a);
21void vf__a2(int b, __vector int a);
22
23vector char v_c;
24vector signed char v_sc;
25vector unsigned char v_uc;
26vector short v_s;
27vector signed short v_ss;
28vector unsigned short v_us;
29vector short int v_si;
30vector signed short int v_ssi;
31vector unsigned short int v_usi;
32vector int v_i;
33vector signed int v_sint;
34vector unsigned int v_ui;
35vector float v_f;
36vector bool v_b;
37vector __pixel v_p;
38vector pixel v__p;
39vector int f__r();
40void f_a(vector int a);
41void f_a2(int b, vector int a);
42
Chris Lattnere12a7792010-04-20 05:19:10 +000043vector int v = (vector int)(-1);
44
John Thompson82287d12010-02-05 00:12:22 +000045// 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_d; // expected-error {{cannot use 'double' with '__vector'}}
63__vector double vv_d; // expected-error {{cannot use 'double' with '__vector'}}
64vector double v_d; // expected-error {{cannot use 'double' with '__vector'}}
65vector double v_d; // expected-error {{cannot use 'double' with '__vector'}}
66__vector long double vv_ld; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
67vector 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 +000068
69void f() {
70 __vector unsigned int v = {0,0,0,0};
71 __vector int v__cast = (__vector int)v;
72 __vector int v_cast = (vector int)v;
73 __vector char vb_cast = (vector char)v;
74
75 // Check some casting between gcc and altivec vectors.
76 #define gccvector __attribute__((vector_size(16)))
77 gccvector unsigned int gccv = {0,0,0,0};
78 gccvector unsigned int gccv1 = gccv;
79 gccvector int gccv2 = (gccvector int)gccv;
80 gccvector unsigned int gccv3 = v;
81 __vector unsigned int av = gccv;
82 __vector int avi = (__vector int)gccv;
83 gccvector unsigned int gv = v;
84 gccvector int gvi = (gccvector int)v;
85 __attribute__((vector_size(8))) unsigned int gv8;
Douglas Gregord4eea832010-04-09 00:35:39 +000086 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'}}
87 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 +000088
89 v = gccv;
90 __vector unsigned int tv = gccv;
91 gccv = v;
92 gccvector unsigned int tgv = v;
93}