vector_conv_invalid.cl 1.3 KB

12345678910111213141516171819202122
  1. // RUN: %clang_cc1 -verify %s
  2. typedef unsigned int uint4 __attribute((ext_vector_type(4)));
  3. typedef int int4 __attribute((ext_vector_type(4)));
  4. typedef int int3 __attribute((ext_vector_type(3)));
  5. typedef unsigned uint3 __attribute((ext_vector_type(3)));
  6. void vector_conv_invalid(const global int4 *const_global_ptr) {
  7. uint4 u = (uint4)(1);
  8. int4 i = u; // expected-error{{initializing 'int4' (vector of 4 'int' values) with an expression of incompatible type 'uint4' (vector of 4 'unsigned int' values)}}
  9. int4 e = (int4)u; // expected-error{{invalid conversion between ext-vector type 'int4' (vector of 4 'int' values) and 'uint4' (vector of 4 'unsigned int' values)}}
  10. uint3 u4 = (uint3)u; // expected-error{{invalid conversion between ext-vector type 'uint3' (vector of 3 'unsigned int' values) and 'uint4' (vector of 4 'unsigned int' values)}}
  11. e = (const int4)i;
  12. e = (constant int4)i;
  13. e = (private int4)i;
  14. private int4 *private_ptr = (const private int4 *)const_global_ptr; // expected-error{{casting 'const __global int4 *' to type 'const int4 *' changes address space of pointer}}
  15. global int4 *global_ptr = const_global_ptr; // expected-warning {{initializing '__global int4 *' with an expression of type 'const __global int4 *' discards qualifiers}}
  16. global_ptr = (global int4 *)const_global_ptr;
  17. }