[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Sema / fp16vec-sema.c
blob80936cd622f7cd8ff63b2929259b82aff7bf2e79
1 // RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %s
3 typedef __fp16 half4 __attribute__ ((vector_size (8)));
4 typedef float float4 __attribute__ ((vector_size (16)));
5 typedef short short4 __attribute__ ((vector_size (8)));
6 typedef int int4 __attribute__ ((vector_size (16)));
7 typedef __fp16 exthalf4 __attribute__((ext_vector_type(4)));
9 half4 hv0, hv1;
10 float4 fv0, fv1;
11 short4 sv0;
12 int4 iv0;
14 void testFP16Vec(int c) {
15 hv0 = hv0 + hv1;
16 hv0 = hv0 - hv1;
17 hv0 = hv0 * hv1;
18 hv0 = hv0 / hv1;
19 hv0 = c ? hv0 : hv1;
20 hv0 += hv1;
21 hv0 -= hv1;
22 hv0 *= hv1;
23 hv0 /= hv1;
24 sv0 = 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; // expected-error{{logical expression with vector types 'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}}
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 hv0, 1;
33 1, hv0;
35 // Implicit conversion between half vectors and float vectors are not allowed.
36 hv0 = fv0; // expected-error{{assigning to}}
37 fv0 = hv0; // expected-error{{assigning to}}
38 hv0 = (half4)fv0; // expected-error{{invalid conversion between}}
39 fv0 = (float4)hv0; // expected-error{{invalid conversion between}}
40 hv0 = fv0 + fv1; // expected-error{{assigning to}}
41 fv0 = hv0 + hv1; // expected-error{{assigning to}}
42 hv0 = hv0 + fv1; // expected-error{{cannot convert between vector}}
43 hv0 = c ? hv0 : fv1; // expected-error{{cannot convert between vector}}
44 sv0 = 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}} expected-error{{invalid operands to binary expression}}
47 iv0 = hv0 == hv1; // expected-error{{assigning to}}
49 // FIXME: clang currently disallows using these operators on vectors, which is
50 // allowed by gcc.
51 sv0 = !hv0; // expected-error{{invalid argument type}}
52 hv0++; // expected-error{{cannot increment value of type}}
53 ++hv0; // expected-error{{cannot increment value of type}}
56 void testExtVec(exthalf4 a) {
57 // Check that the type of "(-a)" is exthalf4.
58 __fp16 t0 = (-a).z;