Home | History | Annotate | Download | only in Sema
      1 // RUN: %clang_cc1 -fsyntax-only -verify -fno-lax-vector-conversions %s
      2 
      3 typedef __attribute__(( ext_vector_type(2) )) float float2;
      4 typedef __attribute__(( ext_vector_type(4) )) int int4;
      5 typedef __attribute__(( ext_vector_type(8) )) short short8;
      6 typedef __attribute__(( ext_vector_type(4) )) float float4;
      7 typedef float t3 __attribute__ ((vector_size (16)));
      8 
      9 static void test() {
     10     float2 vec2;
     11     float4 vec4, vec4_2;
     12     int4 ivec4;
     13     short8 ish8;
     14     t3 vec4_3;
     15     int *ptr;
     16     int i;
     17 
     18     vec4 = 5.0f;
     19     vec4 = (float4)5.0f;
     20     vec4 = (float4)5;
     21     vec4 = (float4)vec4_3;
     22 
     23     ivec4 = (int4)5.0f;
     24     ivec4 = (int4)5;
     25     ivec4 = (int4)vec4_3;
     26 
     27     i = (int)ivec4; // expected-error {{invalid conversion between vector type 'int4' and integer type 'int' of different size}}
     28     i = ivec4; // expected-error {{assigning to 'int' from incompatible type 'int4'}}
     29 
     30     ivec4 = (int4)ptr; // expected-error {{invalid conversion between vector type 'int4' and scalar type 'int *'}}
     31 
     32     vec4 = (float4)vec2; // expected-error {{invalid conversion between ext-vector type 'float4' and 'float2'}}
     33 
     34     ish8 += 5; // expected-error {{can't convert between vector values of different size ('short8' and 'int')}}
     35     ish8 += (short)5;
     36     ivec4 *= 5;
     37      vec4 /= 5.2f;
     38      vec4 %= 4; // expected-error {{invalid operands to binary expression ('float4' and 'int')}}
     39     ivec4 %= 4;
     40     ivec4 += vec4; // expected-error {{can't convert between vector values of different size ('int4' and 'float4')}}
     41     ivec4 += (int4)vec4;
     42     ivec4 -= ivec4;
     43     ivec4 |= ivec4;
     44     ivec4 += ptr; // expected-error {{can't convert between vector values of different size ('int4' and 'int *')}}
     45 }
     46 
     47 typedef __attribute__(( ext_vector_type(2) )) float2 vecfloat2; // expected-error{{invalid vector element type 'float2'}}
     48 
     49 void inc(float2 f2) {
     50   f2++; // expected-error{{cannot increment value of type 'float2'}}
     51   __real f2; // expected-error{{invalid type 'float2' to __real operator}}
     52 }
     53