summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2009-01-26 22:19:12 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2009-01-26 22:19:12 +0000
commitb44ab5f25df06bd511caa2873727a1040d96761c (patch)
tree1d9cd107277252175119ac5efa6b26d2831c4a04 /clang/lib
parent327d00cd459b659fa88ffe81500480c5e57fcfa1 (diff)
downloadbcm5719-llvm-b44ab5f25df06bd511caa2873727a1040d96761c.tar.gz
bcm5719-llvm-b44ab5f25df06bd511caa2873727a1040d96761c.zip
Add support for member pointers to const_cast.
llvm-svn: 63055
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaNamedCast.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaNamedCast.cpp b/clang/lib/Sema/SemaNamedCast.cpp
index 06fc9d83bad..2aeab44db3d 100644
--- a/clang/lib/Sema/SemaNamedCast.cpp
+++ b/clang/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.
OpenPOWER on IntegriCloud