summaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaExprObjC.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema/SemaExprObjC.cpp')
-rw-r--r--clang/lib/Sema/SemaExprObjC.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp
index 3505d9f38d23..395f2f340dbd 100644
--- a/clang/lib/Sema/SemaExprObjC.cpp
+++ b/clang/lib/Sema/SemaExprObjC.cpp
@@ -4390,7 +4390,7 @@ SemaObjC::ARCConversionResult
SemaObjC::CheckObjCConversion(SourceRange castRange, QualType castType,
Expr *&castExpr, CheckedConversionKind CCK,
bool Diagnose, bool DiagnoseCFAudited,
- BinaryOperatorKind Opc) {
+ BinaryOperatorKind Opc, bool IsReinterpretCast) {
ASTContext &Context = getASTContext();
QualType castExprType = castExpr->getType();
@@ -4450,13 +4450,17 @@ SemaObjC::CheckObjCConversion(SourceRange castRange, QualType castType,
// must be explicit.
// Allow conversions between pointers to lifetime types and coreFoundation
// pointers too, but only when the conversions are explicit.
+ // Allow conversions requested with a reinterpret_cast that converts an
+ // expression of type T* to type U*.
if (exprACTC == ACTC_indirectRetainable &&
(castACTC == ACTC_voidPtr ||
- (castACTC == ACTC_coreFoundation && SemaRef.isCast(CCK))))
+ (castACTC == ACTC_coreFoundation && SemaRef.isCast(CCK)) ||
+ (IsReinterpretCast && effCastType->isAnyPointerType())))
return ACR_okay;
if (castACTC == ACTC_indirectRetainable &&
- (exprACTC == ACTC_voidPtr || exprACTC == ACTC_coreFoundation) &&
- SemaRef.isCast(CCK))
+ (((exprACTC == ACTC_voidPtr || exprACTC == ACTC_coreFoundation) &&
+ SemaRef.isCast(CCK)) ||
+ (IsReinterpretCast && castExprType->isAnyPointerType())))
return ACR_okay;
switch (ARCCastChecker(Context, exprACTC, castACTC, false).Visit(castExpr)) {