1 // RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -faltivec -fsyntax-only -verify %s 2 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 char vv_bc; 17 __vector bool short vv_bs; 18 __vector bool int vv_bi; 19 __vector __pixel vv_p; 20 __vector pixel vv__p; 21 __vector int vf__r(); 22 void vf__a(__vector int a); 23 void vf__a2(int b, __vector int a); 24 25 vector char v_c; 26 vector signed char v_sc; 27 vector unsigned char v_uc; 28 vector short v_s; 29 vector signed short v_ss; 30 vector unsigned short v_us; 31 vector short int v_si; 32 vector signed short int v_ssi; 33 vector unsigned short int v_usi; 34 vector int v_i; 35 vector signed int v_sint; 36 vector unsigned int v_ui; 37 vector float v_f; 38 vector bool char v_bc; 39 vector bool short v_bs; 40 vector bool int v_bi; 41 vector __pixel v_p; 42 vector pixel v__p; 43 vector int f__r(); 44 void f_a(vector int a); 45 void f_a2(int b, vector int a); 46 47 vector int v = (vector int)(-1); 48 49 // These should have warnings. 50 __vector long vv_l; // expected-warning {{Use of 'long' with '__vector' is deprecated}} 51 __vector signed long vv_sl; // expected-warning {{Use of 'long' with '__vector' is deprecated}} 52 __vector unsigned long vv_ul; // expected-warning {{Use of 'long' with '__vector' is deprecated}} 53 __vector long int vv_li; // expected-warning {{Use of 'long' with '__vector' is deprecated}} 54 __vector signed long int vv_sli; // expected-warning {{Use of 'long' with '__vector' is deprecated}} 55 __vector unsigned long int vv_uli; // expected-warning {{Use of 'long' with '__vector' is deprecated}} 56 vector long v_l; // expected-warning {{Use of 'long' with '__vector' is deprecated}} 57 vector signed long v_sl; // expected-warning {{Use of 'long' with '__vector' is deprecated}} 58 vector unsigned long v_ul; // expected-warning {{Use of 'long' with '__vector' is deprecated}} 59 vector long int v_li; // expected-warning {{Use of 'long' with '__vector' is deprecated}} 60 vector signed long int v_sli; // expected-warning {{Use of 'long' with '__vector' is deprecated}} 61 vector unsigned long int v_uli; // expected-warning {{Use of 'long' with '__vector' is deprecated}} 62 __vector long double vv_ld; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}} 63 vector long double v_ld; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}} 64 vector bool v_b; // expected-warning {{type specifier missing, defaults to 'int'}} 65 66 // These should have errors. 67 __vector double vv_d1; // expected-error {{cannot use 'double' with '__vector'}} 68 vector double v_d2; // expected-error {{cannot use 'double' with '__vector'}} 69 __vector long double vv_ld3; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}} 70 vector long double v_ld4; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}} 71 vector bool float v_bf; // expected-error {{cannot use 'float' with '__vector bool'}} 72 vector bool double v_bd; // expected-error {{cannot use 'double' with '__vector bool'}} 73 vector bool pixel v_bp; // expected-error {{cannot use '__pixel' with '__vector bool'}} 74 vector bool signed char v_bsc; // expected-error {{cannot use 'signed' with '__vector bool'}} 75 vector bool unsigned int v_bsc2; // expected-error {{cannot use 'unsigned' with '__vector bool'}} 76 vector bool long v_bl; // expected-error {{cannot use 'long' with '__vector bool'}} 77 vector bool long long v_bll; // expected-error {{cannot use 'long long' with '__vector bool'}} 78 79 typedef char i8; 80 typedef short i16; 81 typedef int i32; 82 struct S { 83 // i8, i16, i32 here are field names, not type names. 84 vector bool i8; // expected-error {{requires a specifier or qualifier}} 85 vector pixel i16; 86 vector long i32; // expected-warning {{deprecated}} 87 }; 88 89 void f() { 90 __vector unsigned int v = {0,0,0,0}; 91 __vector int v__cast = (__vector int)v; 92 __vector int v_cast = (vector int)v; 93 __vector char vb_cast = (vector char)v; 94 95 // Check some casting between gcc and altivec vectors. 96 #define gccvector __attribute__((vector_size(16))) 97 gccvector unsigned int gccv = {0,0,0,0}; 98 gccvector unsigned int gccv1 = gccv; 99 gccvector int gccv2 = (gccvector int)gccv; 100 gccvector unsigned int gccv3 = v; 101 __vector unsigned int av = gccv; 102 __vector int avi = (__vector int)gccv; 103 gccvector unsigned int gv = v; 104 gccvector int gvi = (gccvector int)v; 105 __attribute__((vector_size(8))) unsigned int gv8; 106 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'}} 107 av = gv8; // expected-error {{assigning to '__vector unsigned int' from incompatible type '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int'}} 108 109 v = gccv; 110 __vector unsigned int tv = gccv; 111 gccv = v; 112 gccvector unsigned int tgv = v; 113 114 int res_i; 115 // bug 7553 - Problem with '==' and vectors 116 res_i = (vv_sc == vv_sc); 117 res_i = (vv_uc != vv_uc); 118 res_i = (vv_s > vv_s); 119 res_i = (vv_us >= vv_us); 120 res_i = (vv_i < vv_i); 121 res_i = (vv_ui <= vv_ui); 122 res_i = (vv_f <= vv_f); 123 } 124 125 // bug 6895 - Vectorl literal casting confusion. 126 vector char v1 = (vector char)((vector int)(1, 2, 3, 4)); 127 vector char v2 = (vector char)((vector float)(1.0f, 2.0f, 3.0f, 4.0f)); 128 vector char v3 = (vector char)((vector int)('a', 'b', 'c', 'd')); 129 vector int v4 = (vector int)(1, 2, 3, 4); 130 vector float v5 = (vector float)(1.0f, 2.0f, 3.0f, 4.0f); 131 vector char v6 = (vector char)((vector int)(1+2, -2, (int)(2.0 * 3), -(5-3))); 132