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