John Thompson | 82287d1 | 2010-02-05 00:12:22 +0000 | [diff] [blame] | 1 | // 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(); |
| 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 v_b; |
| 39 | vector __pixel v_p; |
| 40 | vector pixel v__p; |
| 41 | vector int f__r(); |
| 42 | void f_a(vector int a); |
| 43 | void f_a2(int b, vector int a); |
| 44 | |
| 45 | // These should have warnings. |
Chris Lattner | ffaf4c5 | 2010-03-07 18:50:21 +0000 | [diff] [blame] | 46 | __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}} |
| 52 | vector long v_l; // expected-warning {{Use of 'long' with '__vector' is deprecated}} |
| 53 | vector signed long v_sl; // expected-warning {{Use of 'long' with '__vector' is deprecated}} |
| 54 | vector unsigned long v_ul; // expected-warning {{Use of 'long' with '__vector' is deprecated}} |
| 55 | vector long int v_li; // expected-warning {{Use of 'long' with '__vector' is deprecated}} |
| 56 | vector signed long int v_sli; // expected-warning {{Use of 'long' with '__vector' is deprecated}} |
| 57 | vector 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'}} |
| 59 | vector long double v_ld; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}} |
John Thompson | 82287d1 | 2010-02-05 00:12:22 +0000 | [diff] [blame] | 60 | |
| 61 | // These should have errors. |
Chris Lattner | ffaf4c5 | 2010-03-07 18:50:21 +0000 | [diff] [blame] | 62 | __vector double vv_d1; // expected-error {{cannot use 'double' with '__vector'}} |
| 63 | vector 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'}} |
| 65 | vector long double v_ld4; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}} |
John Thompson | 82287d1 | 2010-02-05 00:12:22 +0000 | [diff] [blame] | 66 | |
| 67 | void 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 Gregor | d4eea83 | 2010-04-09 00:35:39 +0000 | [diff] [blame^] | 84 | 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 Thompson | 82287d1 | 2010-02-05 00:12:22 +0000 | [diff] [blame] | 86 | |
| 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 | |
| 95 | class 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 | |
| 102 | class 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 | |