diff options
-rw-r--r-- | lib/Sema/Sema.cpp | 12 | ||||
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 12 |
2 files changed, 17 insertions, 7 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 474ea16e57..5a31296781 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -230,10 +230,14 @@ void Sema::ImpCastExprToType(Expr *&Expr, QualType Ty, } if (ImplicitCastExpr *ImpCast = dyn_cast<ImplicitCastExpr>(Expr)) { - ImpCast->setType(Ty); - ImpCast->setLvalueCast(isLvalue); - } else - Expr = new (Context) ImplicitCastExpr(Ty, Kind, Expr, isLvalue); + if (ImpCast->getCastKind() == Kind) { + ImpCast->setType(Ty); + ImpCast->setLvalueCast(isLvalue); + return; + } + } + + Expr = new (Context) ImplicitCastExpr(Ty, Kind, Expr, isLvalue); } void Sema::DeleteExpr(ExprTy *E) { diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index a6bf82b590..bd58109193 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -991,9 +991,15 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, if (CastArg.isInvalid()) return true; - From = new (Context) ImplicitCastExpr(ToType.getNonReferenceType(), - CastKind, CastArg.takeAs<Expr>(), - ToType->isLValueReferenceType()); + QualType CastArgType = ((Expr *)CastArg.get())->getType(); + From = + new (Context) ImplicitCastExpr(CastArgType, CastKind, + CastArg.takeAs<Expr>(), + CastArgType->isLValueReferenceType()); + if (PerformImplicitConversion(From, ToType.getNonReferenceType(), + ICS.UserDefined.After, "converting")) + return true; + return false; } |