61 lines · c
1// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %s2// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fsyntax-only -Wno-unused-value -verify %s3 4typedef __fp16 half4 __attribute__ ((vector_size (8)));5typedef float float4 __attribute__ ((vector_size (16)));6typedef short short4 __attribute__ ((vector_size (8)));7typedef int int4 __attribute__ ((vector_size (16)));8typedef __fp16 exthalf4 __attribute__((ext_vector_type(4)));9 10half4 hv0, hv1;11float4 fv0, fv1;12short4 sv0;13int4 iv0;14 15void 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;35 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}}49 50 // FIXME: clang currently disallows using these operators on vectors, which is51 // 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}}55}56 57void testExtVec(exthalf4 a) {58 // Check that the type of "(-a)" is exthalf4.59 __fp16 t0 = (-a).z;60}61