Index: lib/Sema/SemaCast.cpp =================================================================== --- lib/Sema/SemaCast.cpp +++ lib/Sema/SemaCast.cpp @@ -1078,7 +1078,9 @@ return TC_Failed; } } - Kind = CK_BitCast; + unsigned SrcAS = SrcPointee.getAddressSpace(); + unsigned DestAS = DestPointee.getAddressSpace(); + Kind = SrcAS != DestAS ? CK_AddressSpaceConversion : CK_BitCast; return TC_Success; } Index: test/CodeGenCXX/address-space-cast.cpp =================================================================== --- /dev/null +++ test/CodeGenCXX/address-space-cast.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -emit-llvm -o - %s + +typedef void *void_ptr; +typedef int __attribute__((address_space(1))) *int_ptr_1; + +void test_cstyle_cast_from_void_ptr(void_ptr vp) { + (void)(int_ptr_1)(vp); +}