Home | History | Annotate | Download | only in Sema
      1 // RUN: %clang_cc1 -fsyntax-only %s -verify -Wvector-conversion
      2 
      3 typedef long long t1 __attribute__ ((vector_size (8)));
      4 typedef char t2 __attribute__ ((vector_size (16)));
      5 typedef float t3 __attribute__ ((vector_size (16)));
      6 
      7 void f()
      8 {
      9   t1 v1;
     10   t2 v2;
     11   t3 v3;
     12 
     13   v2 = (t2)v1; // expected-error {{invalid conversion between vector type \
     14 't2' and 't1' of different size}}
     15   v1 = (t1)v2; // expected-error {{invalid conversion between vector type \
     16 't1' and 't2' of different size}}
     17   v3 = (t3)v2;
     18 
     19   v1 = (t1)(char *)10; // expected-error {{invalid conversion between vector \
     20 type 't1' and scalar type 'char *'}}
     21   v1 = (t1)(long long)10;
     22   v1 = (t1)(short)10; // expected-error {{invalid conversion between vector \
     23 type 't1' and integer type 'short' of different size}}
     24 
     25   long long r1 = (long long)v1;
     26   short r2 = (short)v1; // expected-error {{invalid conversion between vector \
     27 type 't1' and integer type 'short' of different size}}
     28   char *r3 = (char *)v1; // expected-error {{invalid conversion between vector\
     29  type 't1' and scalar type 'char *'}}
     30 }
     31 
     32 
     33 void f2(t2 X); // expected-note{{passing argument to parameter 'X' here}}
     34 
     35 void f3(t3 Y) {
     36   f2(Y);  // expected-warning {{incompatible vector types passing 't3' to parameter of type 't2'}}
     37 }
     38 
     39