1 // RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only
3 typedef int int2 __attribute__((ext_vector_type(2)));
4 typedef int int3 __attribute__((ext_vector_type(3)));
5 typedef int int4 __attribute__((ext_vector_type(4)));
10 __global int *__global g_ptr = &g;
13 // Testing conversions between vectors and vectors/scalars
15 auto l_to_i2 = reinterpret_cast<int2>(l1);
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);
21 // Testing reinterpret_cast with address spaces.
23 auto s2 = reinterpret_cast<__private short>(s);
24 auto s3 = reinterpret_cast<decltype(s)>(s);
25 auto s4 = reinterpret_cast<__global short>(s);
28 auto x2 = reinterpret_cast<__private X>(x); // expected-error{{reinterpret_cast from '__private X' to '__private X' is not allowed}}
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}}
33 // Only integral types (and pointer/references) can be reinterpret casted to themselves.
34 // Currently this does not include any opencl types.
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}}