Allow downcasts of pointers to Objective-C interfaces, with a
warning. This matches GCC's behavior and addresses
<rdar://problem/6458293>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61246 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 925a7bb..6c1af5f 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -744,7 +744,10 @@
// Get the type before calling CheckSingleAssignmentConstraints(), since
// it can promote the expression.
QualType InitType = Init->getType();
-
+
+ if (getLangOptions().CPlusPlus)
+ return PerformCopyInitialization(Init, DeclType, "initializing");
+
AssignConvertType ConvTy = CheckSingleAssignmentConstraints(DeclType, Init);
return DiagnoseAssignmentResult(ConvTy, Init->getLocStart(), DeclType,
InitType, Init, "initializing");
@@ -843,7 +846,7 @@
// destination type.
// FIXME: We're pretending to do copy elision here; return to
// this when we have ASTs for such things.
- if (!PerformImplicitConversion(Init, DeclType))
+ if (!PerformImplicitConversion(Init, DeclType, "initializing"))
return false;
return Diag(InitLoc, diag::err_typecheck_convert_incompatible)