@@ -263,7 +263,7 @@ static void DiagnoseCastQual(Sema &Self, const ExprResult &SrcExpr,
263263// %2: Destination Type
264264static TryCastResult TryLValueToRValueCast (Sema &Self, Expr *SrcExpr,
265265 QualType DestType, bool CStyle,
266- CastKind &Kind,
266+ SourceRange OpRange, CastKind &Kind,
267267 CXXCastPath &BasePath,
268268 unsigned &msg);
269269static TryCastResult
@@ -1425,8 +1425,8 @@ static TryCastResult TryStaticCast(Sema &Self, ExprResult &SrcExpr,
14251425 // C++11 [expr.static.cast]p3:
14261426 // A glvalue of type "cv1 T1" can be cast to type "rvalue reference to cv2
14271427 // T2" if "cv2 T2" is reference-compatible with "cv1 T1".
1428- tcr = TryLValueToRValueCast (Self, SrcExpr.get (), DestType, CStyle, Kind ,
1429- BasePath, msg);
1428+ tcr = TryLValueToRValueCast (Self, SrcExpr.get (), DestType, CStyle, OpRange ,
1429+ Kind, BasePath, msg);
14301430 if (tcr != TC_NotApplicable)
14311431 return tcr;
14321432
@@ -1602,8 +1602,8 @@ static TryCastResult TryStaticCast(Sema &Self, ExprResult &SrcExpr,
16021602// / Tests whether a conversion according to N2844 is valid.
16031603TryCastResult TryLValueToRValueCast (Sema &Self, Expr *SrcExpr,
16041604 QualType DestType, bool CStyle,
1605- CastKind &Kind, CXXCastPath &BasePath ,
1606- unsigned &msg) {
1605+ SourceRange OpRange, CastKind &Kind ,
1606+ CXXCastPath &BasePath, unsigned &msg) {
16071607 // C++11 [expr.static.cast]p3:
16081608 // A glvalue of type "cv1 T1" can be cast to type "rvalue reference to
16091609 // cv2 T2" if "cv2 T2" is reference-compatible with "cv1 T1".
@@ -1616,7 +1616,6 @@ TryCastResult TryLValueToRValueCast(Sema &Self, Expr *SrcExpr,
16161616
16171617 // Because we try the reference downcast before this function, from now on
16181618 // this is the only cast possibility, so we issue an error if we fail now.
1619- // FIXME: Should allow casting away constness if CStyle.
16201619 QualType FromType = SrcExpr->getType ();
16211620 QualType ToType = R->getPointeeType ();
16221621 if (CStyle) {
@@ -1640,13 +1639,12 @@ TryCastResult TryLValueToRValueCast(Sema &Self, Expr *SrcExpr,
16401639
16411640 if (RefConv & Sema::ReferenceConversions::DerivedToBase) {
16421641 Kind = CK_DerivedToBase;
1643- CXXBasePaths Paths (/* FindAmbiguities=*/ true , /* RecordPaths=*/ true ,
1644- /* DetectVirtual=*/ true );
1645- if (!Self.IsDerivedFrom (SrcExpr->getBeginLoc (), SrcExpr->getType (),
1646- R->getPointeeType (), Paths))
1647- return TC_NotApplicable;
1648-
1649- Self.BuildBasePathArray (Paths, BasePath);
1642+ if (Self.CheckDerivedToBaseConversion (FromType, ToType,
1643+ SrcExpr->getBeginLoc (), OpRange,
1644+ &BasePath, CStyle)) {
1645+ msg = 0 ;
1646+ return TC_Failed;
1647+ }
16501648 } else
16511649 Kind = CK_NoOp;
16521650
0 commit comments