[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Sema / fp16vec-sema.c
blob89f01c6dcf47b6a535320f17e9c3ee27604a9a50
1 // RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %s
2 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fsyntax-only -Wno-unused-value -verify %s
4 typedef __fp16 half4 __attribute__ ((vector_size (8)));
5 typedef float float4 __attribute__ ((vector_size (16)));
6 typedef short short4 __attribute__ ((vector_size (8)));
7 typedef int int4 __attribute__ ((vector_size (16)));
8 typedef __fp16 exthalf4 __attribute__((ext_vector_type(4)));
10 half4 hv0, hv1;
11 float4 fv0, fv1;
12 short4 sv0;
13 int4 iv0;
15 void testFP16Vec(int c) {
16 hv0 = hv0 + hv1;
17 hv0 = hv0 - hv1;
18 hv0 = hv0 * hv1;
19 hv0 = hv0 / hv1;
20 hv0 = c ? hv0 : hv1;
21 hv0 += hv1;
22 hv0 -= hv1;
23 hv0 *= hv1;
24 hv0 /= hv1;
25 sv0 = hv0 == hv1;
26 sv0 = hv0 != hv1;
27 sv0 = hv0 < hv1;
28 sv0 = hv0 > hv1;
29 sv0 = hv0 <= hv1;
30 sv0 = hv0 >= hv1;
31 sv0 = hv0 || hv1; // expected-error{{logical expression with vector types 'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}}
32 sv0 = hv0 && hv1; // expected-error{{logical expression with vector types 'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}}
33 hv0, 1;
34 1, hv0;
36 // Implicit conversion between half vectors and float vectors are not allowed.
37 hv0 = fv0; // expected-error{{assigning to}}
38 fv0 = hv0; // expected-error{{assigning to}}
39 hv0 = (half4)fv0; // expected-error{{invalid conversion between}}
40 fv0 = (float4)hv0; // expected-error{{invalid conversion between}}
41 hv0 = fv0 + fv1; // expected-error{{assigning to}}
42 fv0 = hv0 + hv1; // expected-error{{assigning to}}
43 hv0 = hv0 + fv1; // expected-error{{cannot convert between vector}}
44 hv0 = c ? hv0 : fv1; // expected-error{{cannot convert between vector}}
45 sv0 = hv0 == fv1; // expected-error{{cannot convert between vector}}
46 sv0 = hv0 < fv1; // expected-error{{cannot convert between vector}}
47 sv0 = hv0 || fv1; // expected-error{{cannot convert between vector}} expected-error{{invalid operands to binary expression}}
48 iv0 = hv0 == hv1; // expected-error{{assigning to}}
50 // FIXME: clang currently disallows using these operators on vectors, which is
51 // allowed by gcc.
52 sv0 = !hv0; // expected-error{{invalid argument type}}
53 hv0++; // expected-error{{cannot increment value of type}}
54 ++hv0; // expected-error{{cannot increment value of type}}
57 void testExtVec(exthalf4 a) {
58 // Check that the type of "(-a)" is exthalf4.
59 __fp16 t0 = (-a).z;