diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 32b35ba7c32..3029861f230 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -4216,7 +4216,20 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, 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<BlockPointerType>(LHSType) && "BlockPointerType expected"); + assert(isa<BlockPointerType>(RHSType) && "BlockPointerType expected"); + + LangAS AddrSpaceL = + LHSType->getAs<BlockPointerType>()->getPointeeType().getAddressSpace(); + LangAS AddrSpaceR = + RHSType->getAs<BlockPointerType>()->getPointeeType().getAddressSpace(); + CastKind Kind = + AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast; + From = ImpCastExprToType(From, ToType.getUnqualifiedType(), Kind, VK_RValue, /*BasePath=*/nullptr, CCK).get(); break; } |