1// RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only 2 3typedef int int2 __attribute__((ext_vector_type(2))); 4typedef int int3 __attribute__((ext_vector_type(3))); 5typedef int int4 __attribute__((ext_vector_type(4))); 6 7struct X {}; 8 9__global int g = 0; 10__global int *__global g_ptr = &g; 11 12kernel void foo() { 13 // Testing conversions between vectors and vectors/scalars 14 long l1; 15 auto l_to_i2 = reinterpret_cast<int2>(l1); 16 int2 i2; 17 auto i2_to_l = reinterpret_cast<long>(i2); 18 auto i2_to_i = reinterpret_cast<int>(i2); // expected-error{{reinterpret_cast from vector 'int2' (vector of 2 'int' values) to scalar 'int' of different size}} 19 auto i2_to_i2 = reinterpret_cast<int2>(i2); 20 21 // Testing reinterpret_cast with address spaces. 22 __private short s; 23 auto s2 = reinterpret_cast<__private short>(s); 24 auto s3 = reinterpret_cast<decltype(s)>(s); 25 auto s4 = reinterpret_cast<__global short>(s); 26 27 __private X x; 28 auto x2 = reinterpret_cast<__private X>(x); // expected-error{{reinterpret_cast from '__private X' to '__private X' is not allowed}} 29 30 auto ptr = reinterpret_cast<__global int* __private>(g_ptr); 31 (void)reinterpret_cast<__private int* __private>(g_ptr); // expected-error{{reinterpret_cast from '__global int *' to '__private int *' is not allowed}} 32 33 // Only integral types (and pointer/references) can be reinterpret casted to themselves. 34 // Currently this does not include any opencl types. 35 reserve_id_t r_id1; 36 auto r_id2 = reinterpret_cast<reserve_id_t>(r_id1); // expected-error{{reinterpret_cast from 'reserve_id_t' to 'reserve_id_t' is not allowed}} 37} 38