зеркало из https://github.com/microsoft/clang-1.git
Switch the checking of implicit casts for static_cast, C-style, and
functional casts over to InitializationSequence, eliminating a caller of Sema::TryImplicitConversion. We also get access and ambiguity checking "for free". More cleanups to come in this routine. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101526 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
0ade808e0a
Коммит
f0e43e5c46
|
@ -953,26 +953,24 @@ TryStaticImplicitCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
|
|||
return TC_NotApplicable;
|
||||
}
|
||||
|
||||
// FIXME: To get a proper error from invalid conversions here, we need to
|
||||
// reimplement more of this.
|
||||
// FIXME: This does not actually perform the conversion, and thus does not
|
||||
// check for ambiguity or access.
|
||||
ImplicitConversionSequence ICS =
|
||||
Self.TryImplicitConversion(SrcExpr, DestType,
|
||||
/*SuppressUserConversions=*/false,
|
||||
/*AllowExplicit=*/true,
|
||||
/*InOverloadResolution=*/false,
|
||||
/*one of user provided casts*/true);
|
||||
|
||||
if (ICS.isBad())
|
||||
InitializedEntity Entity = InitializedEntity::InitializeTemporary(DestType);
|
||||
InitializationKind InitKind
|
||||
= InitializationKind::CreateCast(/*FIXME:*/OpRange, CStyle);
|
||||
InitializationSequence InitSeq(Self, Entity, InitKind, &SrcExpr, 1);
|
||||
if (InitSeq.getKind() == InitializationSequence::FailedSequence)
|
||||
return TC_NotApplicable;
|
||||
|
||||
// The conversion is possible, so commit to it.
|
||||
Sema::OwningExprResult Result
|
||||
= InitSeq.Perform(Self, Entity, InitKind,
|
||||
Action::MultiExprArg(Self, (void **)&SrcExpr, 1));
|
||||
Kind = CastExpr::CK_NoOp;
|
||||
msg = 0;
|
||||
return Self.PerformImplicitConversion(SrcExpr, DestType, ICS, Sema::AA_Casting,
|
||||
/*IgnoreBaseAccess*/CStyle) ?
|
||||
TC_Failed : TC_Success;
|
||||
if (Result.isInvalid()) {
|
||||
msg = 0;
|
||||
return TC_Failed;
|
||||
}
|
||||
|
||||
SrcExpr = Result.takeAs<Expr>();
|
||||
return TC_Success;
|
||||
}
|
||||
|
||||
/// TryConstCast - See if a const_cast from source to destination is allowed,
|
||||
|
|
|
@ -3486,15 +3486,18 @@ InitializationSequence::Perform(Sema &S,
|
|||
CurInit = S.Owned(CurInitExpr);
|
||||
break;
|
||||
|
||||
case SK_ConversionSequence:
|
||||
if (S.PerformImplicitConversion(CurInitExpr, Step->Type, Sema::AA_Converting,
|
||||
false, *Step->ICS))
|
||||
case SK_ConversionSequence: {
|
||||
bool IgnoreBaseAccess = Kind.isCStyleOrFunctionalCast();
|
||||
|
||||
if (S.PerformImplicitConversion(CurInitExpr, Step->Type, *Step->ICS,
|
||||
Sema::AA_Converting, IgnoreBaseAccess))
|
||||
return S.ExprError();
|
||||
|
||||
CurInit.release();
|
||||
CurInit = S.Owned(CurInitExpr);
|
||||
CurInit = S.Owned(CurInitExpr);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case SK_ListInitialization: {
|
||||
InitListExpr *InitList = cast<InitListExpr>(CurInitExpr);
|
||||
QualType Ty = Step->Type;
|
||||
|
|
Загрузка…
Ссылка в новой задаче