Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp =================================================================== --- cfe/trunk/lib/Sema/SemaExprCXX.cpp +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp @@ -4216,7 +4216,20 @@ break; case ICK_Block_Pointer_Conversion: { - From = ImpCastExprToType(From, ToType.getUnqualifiedType(), CK_BitCast, + QualType LHSType = Context.getCanonicalType(ToType).getUnqualifiedType(); + QualType RHSType = Context.getCanonicalType(FromType).getUnqualifiedType(); + + // Assumptions based on Sema::IsBlockPointerConversion. + assert(isa(LHSType) && "BlockPointerType expected"); + assert(isa(RHSType) && "BlockPointerType expected"); + + LangAS AddrSpaceL = + LHSType->getAs()->getPointeeType().getAddressSpace(); + LangAS AddrSpaceR = + RHSType->getAs()->getPointeeType().getAddressSpace(); + CastKind Kind = + AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast; + From = ImpCastExprToType(From, ToType.getUnqualifiedType(), Kind, VK_RValue, /*BasePath=*/nullptr, CCK).get(); break; }