Index: clang/lib/Sema/SemaCast.cpp =================================================================== --- clang/lib/Sema/SemaCast.cpp +++ clang/lib/Sema/SemaCast.cpp @@ -2356,7 +2356,10 @@ return TC_Failed; } - if (SrcType == DestType) { + if (SrcType == DestType || + (Self.LangOpts.OpenCL && + Self.Context.removeAddrSpaceQualType(SrcType) == + Self.Context.removeAddrSpaceQualType(DestType))) { // C++ 5.2.10p2 has a note that mentions that, subject to all other // restrictions, a cast to the same type is allowed so long as it does not // cast away constness. In C++98, the intent was not entirely clear here, Index: clang/test/SemaOpenCLCXX/reinterpret-cast.clcpp =================================================================== --- clang/test/SemaOpenCLCXX/reinterpret-cast.clcpp +++ clang/test/SemaOpenCLCXX/reinterpret-cast.clcpp @@ -13,6 +13,11 @@ auto i2_to_i = reinterpret_cast(i2); // expected-error{{reinterpret_cast from vector 'int2' (vector of 2 'int' values) to scalar 'int' of different size}} auto i2_to_i2 = reinterpret_cast(i2); + __private short s; + auto s2 = reinterpret_cast<__private short>(s); + auto s3 = reinterpret_cast(s); + auto s4 = reinterpret_cast<__global short>(s); + // Only integral types (and pointer/references) can be reinterpret casted to themselves. // Currently this does not include any opencl types. reserve_id_t r_id1;