[cfe-commits] r86996 - /cfe/trunk/lib/Sema/SemaCXXCast.cpp
Anders Carlsson
andersca at mac.com
Thu Nov 12 08:53:16 PST 2009
Author: andersca
Date: Thu Nov 12 10:53:16 2009
New Revision: 86996
URL: http://llvm.org/viewvc/llvm-project?rev=86996&view=rev
Log:
Set CK_BaseToDerived in TryStaticDowncast.
Modified:
cfe/trunk/lib/Sema/SemaCXXCast.cpp
Modified: cfe/trunk/lib/Sema/SemaCXXCast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXCast.cpp?rev=86996&r1=86995&r2=86996&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCXXCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCXXCast.cpp Thu Nov 12 10:53:16 2009
@@ -70,16 +70,19 @@
static TryCastResult TryStaticReferenceDowncast(Sema &Self, Expr *SrcExpr,
QualType DestType, bool CStyle,
const SourceRange &OpRange,
- unsigned &msg);
+ unsigned &msg,
+ CastExpr::CastKind &Kind);
static TryCastResult TryStaticPointerDowncast(Sema &Self, QualType SrcType,
QualType DestType, bool CStyle,
const SourceRange &OpRange,
- unsigned &msg);
+ unsigned &msg,
+ CastExpr::CastKind &Kind);
static TryCastResult TryStaticDowncast(Sema &Self, QualType SrcType,
QualType DestType, bool CStyle,
const SourceRange &OpRange,
QualType OrigSrcType,
- QualType OrigDestType, unsigned &msg);
+ QualType OrigDestType, unsigned &msg,
+ CastExpr::CastKind &Kind);
static TryCastResult TryStaticMemberPointerUpcast(Sema &Self, QualType SrcType,
QualType DestType,bool CStyle,
const SourceRange &OpRange,
@@ -427,7 +430,8 @@
// C++ 5.2.9p5, reference downcast.
// See the function for details.
// DR 427 specifies that this is to be applied before paragraph 2.
- tcr = TryStaticReferenceDowncast(Self, SrcExpr, DestType, CStyle,OpRange,msg);
+ tcr = TryStaticReferenceDowncast(Self, SrcExpr, DestType, CStyle, OpRange,
+ msg, Kind);
if (tcr != TC_NotApplicable)
return tcr;
@@ -473,7 +477,8 @@
// Reverse pointer upcast. C++ 4.10p3 specifies pointer upcast.
// C++ 5.2.9p8 additionally disallows a cast path through virtual inheritance.
- tcr = TryStaticPointerDowncast(Self, SrcType, DestType, CStyle, OpRange, msg);
+ tcr = TryStaticPointerDowncast(Self, SrcType, DestType, CStyle, OpRange, msg,
+ Kind);
if (tcr != TC_NotApplicable)
return tcr;
@@ -544,7 +549,7 @@
TryCastResult
TryStaticReferenceDowncast(Sema &Self, Expr *SrcExpr, QualType DestType,
bool CStyle, const SourceRange &OpRange,
- unsigned &msg) {
+ unsigned &msg, CastExpr::CastKind &Kind) {
// C++ 5.2.9p5: An lvalue of type "cv1 B", where B is a class type, can be
// cast to type "reference to cv2 D", where D is a class derived from B,
// if a valid standard conversion from "pointer to D" to "pointer to B"
@@ -568,14 +573,14 @@
QualType DestPointee = DestReference->getPointeeType();
return TryStaticDowncast(Self, SrcExpr->getType(), DestPointee, CStyle,
- OpRange, SrcExpr->getType(), DestType, msg);
+ OpRange, SrcExpr->getType(), DestType, msg, Kind);
}
/// Tests whether a conversion according to C++ 5.2.9p8 is valid.
TryCastResult
TryStaticPointerDowncast(Sema &Self, QualType SrcType, QualType DestType,
bool CStyle, const SourceRange &OpRange,
- unsigned &msg) {
+ unsigned &msg, CastExpr::CastKind &Kind) {
// C++ 5.2.9p8: An rvalue of type "pointer to cv1 B", where B is a class
// type, can be converted to an rvalue of type "pointer to cv2 D", where D
// is a class derived from B, if a valid standard conversion from "pointer
@@ -597,7 +602,7 @@
return TryStaticDowncast(Self, SrcPointer->getPointeeType(),
DestPointer->getPointeeType(), CStyle,
- OpRange, SrcType, DestType, msg);
+ OpRange, SrcType, DestType, msg, Kind);
}
/// TryStaticDowncast - Common functionality of TryStaticReferenceDowncast and
@@ -606,7 +611,8 @@
TryCastResult
TryStaticDowncast(Sema &Self, QualType SrcType, QualType DestType,
bool CStyle, const SourceRange &OpRange, QualType OrigSrcType,
- QualType OrigDestType, unsigned &msg) {
+ QualType OrigDestType, unsigned &msg,
+ CastExpr::CastKind &Kind) {
// We can only work with complete types. But don't complain if it doesn't work
if (Self.RequireCompleteType(OpRange.getBegin(), SrcType, PDiag(0)) ||
Self.RequireCompleteType(OpRange.getBegin(), DestType, PDiag(0)))
@@ -695,6 +701,7 @@
return TC_Failed;
}
+ Kind = CastExpr::CK_BaseToDerived;
return TC_Success;
}
More information about the cfe-commits
mailing list