diff options
author | Anders Carlsson <andersca@mac.com> | 2009-10-18 20:31:03 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-10-18 20:31:03 +0000 |
commit | bb378cbf04e343fb15ae3611a153dde60671b514 (patch) | |
tree | 95c53e77a65e5f87b9e19a07595f28efeb69b9ef /lib | |
parent | 5ffe14ca96bd662de7820f6875d3f04789a640c1 (diff) |
Use CK_BitCast for member function pointer casts. Fixes PR5138.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84438 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/CGExprAgg.cpp | 6 | ||||
-rw-r--r-- | lib/CodeGen/CGExprConstant.cpp | 6 | ||||
-rw-r--r-- | lib/Sema/SemaCXXCast.cpp | 6 |
3 files changed, 16 insertions, 2 deletions
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index 88fdb542f3..066029f9a5 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -215,6 +215,12 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) { break; } + case CastExpr::CK_BitCast: { + // This must be a member function pointer cast. + Visit(E->getSubExpr()); + break; + } + case CastExpr::CK_BaseToDerivedMemberPointer: { QualType SrcType = E->getSubExpr()->getType(); diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index 7f540c3c06..fc3748c8e3 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -542,7 +542,11 @@ public: return CS; } } - + + case CastExpr::CK_BitCast: + // This must be a member function pointer cast. + return Visit(E->getSubExpr()); + default: { // FIXME: This should be handled by the CK_NoOp cast kind. // Explicit and implicit no-op casts diff --git a/lib/Sema/SemaCXXCast.cpp b/lib/Sema/SemaCXXCast.cpp index 69d1f92a08..ef1d128f63 100644 --- a/lib/Sema/SemaCXXCast.cpp +++ b/lib/Sema/SemaCXXCast.cpp @@ -943,6 +943,7 @@ static TryCastResult TryReinterpretCast(Sema &Self, Expr *SrcExpr, } // A valid member pointer cast. + Kind = CastExpr::CK_BitCast; return TC_Success; } @@ -1044,6 +1045,7 @@ static TryCastResult TryReinterpretCast(Sema &Self, Expr *SrcExpr, // Not casting away constness, so the only remaining check is for compatible // pointer categories. + Kind = CastExpr::CK_BitCast; if (SrcType->isFunctionPointerType()) { if (DestType->isFunctionPointerType()) { @@ -1085,8 +1087,10 @@ bool Sema::CXXCheckCStyleCast(SourceRange R, QualType CastTy, Expr *&CastExpr, // This test is outside everything else because it's the only case where // a non-lvalue-reference target type does not lead to decay. // C++ 5.2.9p4: Any expression can be explicitly converted to type "cv void". - if (CastTy->isVoidType()) + if (CastTy->isVoidType()) { + Kind = CastExpr::CK_ToVoid; return false; + } // If the type is dependent, we won't do any other semantic analysis now. if (CastTy->isDependentType() || CastExpr->isTypeDependent()) |