diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-01-26 22:19:12 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-01-26 22:19:12 +0000 |
commit | f20269b42843d10c930886ee661ee1dd37a4248b (patch) | |
tree | 091708b2165201afa376beeac470f69d44cb8741 /lib/Sema/SemaNamedCast.cpp | |
parent | 4adc71ae2cfc190f8d2cf58876e2a7893aa74ee0 (diff) |
Add support for member pointers to const_cast.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63055 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaNamedCast.cpp')
-rw-r--r-- | lib/Sema/SemaNamedCast.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Sema/SemaNamedCast.cpp b/lib/Sema/SemaNamedCast.cpp index 06fc9d83ba..2aeab44db3 100644 --- a/lib/Sema/SemaNamedCast.cpp +++ b/lib/Sema/SemaNamedCast.cpp @@ -133,7 +133,10 @@ CheckConstCast(Sema &Self, Expr *&SrcExpr, QualType DestType, SrcType = SrcExpr->getType(); } - if (!DestType->isPointerType()) { + // C++ 5.2.11p5: For a const_cast involving pointers to data members [...] + // the rules for const_cast are the same as those used for pointers. + + if (!DestType->isPointerType() && !DestType->isMemberPointerType()) { // Cannot cast to non-pointer, non-reference type. Note that, if DestType // was a reference type, we converted it to a pointer above. // C++ 5.2.11p3: For two pointer types [...] @@ -141,7 +144,8 @@ CheckConstCast(Sema &Self, Expr *&SrcExpr, QualType DestType, << OrigDestType << DestRange; return; } - if (DestType->isFunctionPointerType()) { + if (DestType->isFunctionPointerType() || + DestType->isMemberFunctionPointerType()) { // Cannot cast direct function pointers. // C++ 5.2.11p2: [...] where T is any object type or the void type [...] // T is the ultimate pointee of source and target type. |