[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Parser / altivec.c
blob9291b9b69160f644a72ec98588d3ae0e7bab0e61
1 // RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -target-feature +altivec -target-feature +vsx -fsyntax-only -verify=expected,nonaix %s
2 // RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-feature +altivec -target-feature -vsx -fsyntax-only -verify=expected,novsx %s
3 // RUN: %clang_cc1 -triple=powerpc-ibm-aix -target-feature +altivec -fsyntax-only -verify=expected,aix %s
4 // fRUN: %clang_cc1 -triple=powerpc64-ibm-aix -target-feature +altivec -target-feature -vsx -fsyntax-only -verify=expected,aix %s
6 __vector char vv_c;
7 __vector signed char vv_sc;
8 __vector unsigned char vv_uc;
9 __vector short vv_s;
10 __vector signed short vv_ss;
11 __vector unsigned short vv_us;
12 __vector short int vv_si;
13 __vector signed short int vv_ssi;
14 __vector unsigned short int vv_usi;
15 __vector int vv_i;
16 __vector signed int vv_sint;
17 __vector unsigned int vv_ui;
18 __vector float vv_f;
19 __vector bool char vv_bc;
20 __vector bool short vv_bs;
21 __vector bool int vv_bi;
22 __vector __bool char vv___bc;
23 __vector __bool short vv___bs;
24 __vector __bool int vv___bi;
25 __vector __pixel vv_p;
26 __vector pixel vv__p;
27 __vector int vf__r(void);
28 void vf__a(__vector int a);
29 void vf__a2(int b, __vector int a);
31 vector char v_c;
32 vector signed char v_sc;
33 vector unsigned char v_uc;
34 vector short v_s;
35 vector signed short v_ss;
36 vector unsigned short v_us;
37 vector short int v_si;
38 vector signed short int v_ssi;
39 vector unsigned short int v_usi;
40 vector int v_i;
41 vector signed int v_sint;
42 vector unsigned int v_ui;
43 vector float v_f;
44 vector bool char v_bc;
45 vector bool short v_bs;
46 vector bool int v_bi;
47 vector __bool char v___bc;
48 vector __bool short v___bs;
49 vector __bool int v___bi;
50 vector __pixel v_p;
51 vector pixel v__p;
52 vector int f__r(void);
53 void f_a(vector int a);
54 void f_a2(int b, vector int a);
56 vector int v = (vector int)(-1);
58 // These should have errors on AIX and warnings otherwise.
59 __vector long vv_l; // nonaix-warning {{use of 'long' with '__vector' is deprecated}}
60 // aix-error@-1 {{cannot use 'long' with '__vector'}}
61 // novsx-error@-2 {{cannot use 'long' with '__vector'}}
62 __vector signed long vv_sl; // nonaix-warning {{use of 'long' with '__vector' is deprecated}}
63 // aix-error@-1 {{cannot use 'long' with '__vector'}}
64 // novsx-error@-2 {{cannot use 'long' with '__vector'}}
65 __vector unsigned long vv_ul; // nonaix-warning {{use of 'long' with '__vector' is deprecated}}
66 // aix-error@-1 {{cannot use 'long' with '__vector'}}
67 // novsx-error@-2 {{cannot use 'long' with '__vector'}}
68 __vector long int vv_li; // nonaix-warning {{use of 'long' with '__vector' is deprecated}}
69 // aix-error@-1 {{cannot use 'long' with '__vector'}}
70 // novsx-error@-2 {{cannot use 'long' with '__vector'}}
71 __vector signed long int vv_sli; // nonaix-warning {{use of 'long' with '__vector' is deprecated}}
72 // aix-error@-1 {{cannot use 'long' with '__vector'}}
73 // novsx-error@-2 {{cannot use 'long' with '__vector'}}
74 __vector unsigned long int vv_uli; // nonaix-warning {{use of 'long' with '__vector' is deprecated}}
75 // aix-error@-1 {{cannot use 'long' with '__vector'}}
76 // novsx-error@-2 {{cannot use 'long' with '__vector'}}
77 vector long v_l; // nonaix-warning {{use of 'long' with '__vector' is deprecated}}
78 // aix-error@-1 {{cannot use 'long' with '__vector'}}
79 // novsx-error@-2 {{cannot use 'long' with '__vector'}}
80 vector signed long v_sl; // nonaix-warning {{use of 'long' with '__vector' is deprecated}}
81 // aix-error@-1 {{cannot use 'long' with '__vector'}}
82 // novsx-error@-2 {{cannot use 'long' with '__vector'}}
83 vector unsigned long v_ul; // nonaix-warning {{use of 'long' with '__vector' is deprecated}}
84 // aix-error@-1 {{cannot use 'long' with '__vector'}}
85 // novsx-error@-2 {{cannot use 'long' with '__vector'}}
86 vector long int v_li; // nonaix-warning {{use of 'long' with '__vector' is deprecated}}
87 // aix-error@-1 {{cannot use 'long' with '__vector'}}
88 // novsx-error@-2 {{cannot use 'long' with '__vector'}}
89 vector signed long int v_sli; // nonaix-warning {{use of 'long' with '__vector' is deprecated}}
90 // aix-error@-1 {{cannot use 'long' with '__vector'}}
91 // novsx-error@-2 {{cannot use 'long' with '__vector'}}
92 vector unsigned long int v_uli; // nonaix-warning {{use of 'long' with '__vector' is deprecated}}
93 // aix-error@-1 {{cannot use 'long' with '__vector'}}
94 // novsx-error@-2 {{cannot use 'long' with '__vector'}}
96 // These should have warnings.
97 __vector long double vv_ld; // expected-error {{cannot use 'long double' with '__vector'}}
98 vector long double v_ld; // expected-error {{cannot use 'long double' with '__vector'}}
99 vector bool v_b; // expected-error {{type specifier missing, defaults to 'int'}}
100 vector __bool v___b; // expected-error {{type specifier missing, defaults to 'int'}}
102 // These should have errors.
103 #ifndef __VSX__
104 __vector double vv_d1; // expected-error {{use of 'double' with '__vector' requires VSX support to be enabled (available on POWER7 or later)}}
105 vector double v_d2; // expected-error {{use of 'double' with '__vector' requires VSX support to be enabled (available on POWER7 or later)}}
106 __vector bool long long v_bll1; // expected-error {{use of 'long long' with '__vector' requires VSX support (available on POWER7 or later) to be enabled}}
107 __vector __bool long long v_bll2; // expected-error {{use of 'long long' with '__vector' requires VSX support (available on POWER7 or later) to be enabled}}
108 vector bool long long v_bll3; // expected-error {{use of 'long long' with '__vector' requires VSX support (available on POWER7 or later) to be enabled}}
109 vector __bool long long v_bll4; // expected-error {{use of 'long long' with '__vector' requires VSX support (available on POWER7 or later) to be enabled}}
110 #endif
111 __vector long double vv_ld3; // expected-error {{cannot use 'long double' with '__vector'}}
112 vector long double v_ld4; // expected-error {{cannot use 'long double' with '__vector'}}
113 vector float _Complex v_cf; // expected-error {{cannot use '_Complex' with '__vector'}}
114 vector double _Complex v_cd; // expected-error {{cannot use '_Complex' with '__vector'}}
115 vector long double _Complex v_cld; // expected-error {{cannot use '_Complex' with '__vector'}}
116 __vector float _Complex v_cf2; // expected-error {{cannot use '_Complex' with '__vector'}}
117 __vector double _Complex v_cd2; // expected-error {{cannot use '_Complex' with '__vector'}}
118 __vector long double _Complex v_cld2;// expected-error {{cannot use '_Complex' with '__vector'}}
119 vector bool float v_bf; // expected-error {{cannot use 'float' with '__vector bool'}}
120 vector bool double v_bd; // expected-error {{cannot use 'double' with '__vector bool'}}
121 vector bool pixel v_bp; // expected-error {{cannot use '__pixel' with '__vector bool'}}
122 vector bool signed char v_bsc; // expected-error {{cannot use 'signed' with '__vector bool'}}
123 vector bool unsigned int v_bsc2; // expected-error {{cannot use 'unsigned' with '__vector bool'}}
124 vector bool long v_bl; // expected-error {{cannot use 'long' with '__vector bool'}}
125 vector __bool float v___bf; // expected-error {{cannot use 'float' with '__vector bool'}}
126 vector __bool double v___bd; // expected-error {{cannot use 'double' with '__vector bool'}}
127 vector __bool pixel v___bp; // expected-error {{cannot use '__pixel' with '__vector bool'}}
128 vector __bool signed char v___bsc; // expected-error {{cannot use 'signed' with '__vector bool'}}
129 vector __bool unsigned int v___bsc2; // expected-error {{cannot use 'unsigned' with '__vector bool'}}
130 vector __bool long v___bl; // expected-error {{cannot use 'long' with '__vector bool'}}
132 #ifdef __VSX__
133 // vector long is deprecated, but vector long long is not.
134 vector long long v_ll;
135 vector signed long long v_sll;
136 vector unsigned long long v_ull;
137 #else
138 // vector long long is not supported without vsx.
139 vector long long v_ll; // expected-error {{use of 'long long' with '__vector' requires VSX support (available on POWER7 or later) to be enabled}}
140 vector signed long long v_sll; // expected-error {{use of 'long long' with '__vector' requires VSX support (available on POWER7 or later) to be enabled}}
141 vector unsigned long long v_ull; // expected-error {{use of 'long long' with '__vector' requires VSX support (available on POWER7 or later) to be enabled}}
142 #endif
144 typedef char i8;
145 typedef short i16;
146 typedef int i32;
147 struct S {
148 // i8, i16, i32 here are field names, not type names.
149 vector bool i8; // expected-error {{requires a specifier or qualifier}}
150 vector pixel i16;
151 vector short i32;
154 void f(void) {
155 __vector unsigned int v = {0,0,0,0};
156 __vector int v__cast = (__vector int)v;
157 __vector int v_cast = (vector int)v;
158 __vector char vb_cast = (vector char)v;
160 // Check some casting between gcc and altivec vectors.
161 #define gccvector __attribute__((vector_size(16)))
162 gccvector unsigned int gccv = {0,0,0,0};
163 gccvector unsigned int gccv1 = gccv;
164 gccvector int gccv2 = (gccvector int)gccv;
165 gccvector unsigned int gccv3 = v;
166 __vector unsigned int av = gccv;
167 __vector int avi = (__vector int)gccv;
168 gccvector unsigned int gv = v;
169 gccvector int gvi = (gccvector int)v;
170 __attribute__((vector_size(8))) unsigned int gv8;
171 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)}}
172 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)}}
174 v = gccv;
175 __vector unsigned int tv = gccv;
176 gccv = v;
177 gccvector unsigned int tgv = v;
179 int res_i;
180 // bug 7553 - Problem with '==' and vectors
181 res_i = (vv_sc == vv_sc);
182 res_i = (vv_uc != vv_uc);
183 res_i = (vv_s > vv_s);
184 res_i = (vv_us >= vv_us);
185 res_i = (vv_i < vv_i);
186 res_i = (vv_ui <= vv_ui);
187 res_i = (vv_f <= vv_f);
190 // bug 6895 - Vectorl literal casting confusion.
191 vector char v1 = (vector char)((vector int)(1, 2, 3, 4));
192 vector char v2 = (vector char)((vector float)(1.0f, 2.0f, 3.0f, 4.0f));
193 vector char v3 = (vector char)((vector int)('a', 'b', 'c', 'd'));
194 vector int v4 = (vector int)(1, 2, 3, 4);
195 vector float v5 = (vector float)(1.0f, 2.0f, 3.0f, 4.0f);
196 vector char v6 = (vector char)((vector int)(1+2, -2, (int)(2.0 * 3), -(5-3)));