summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaCXXCast.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-01-22 00:19:52 +0000
committerDouglas Gregor <dgregor@apple.com>2011-01-22 00:19:52 +0000
commitc1ed20cfbab3fb124125e2292b2c16f6ae00ed8d (patch)
tree5c922ece01b9af456956225b6c7921919472198a /clang/lib/Sema/SemaCXXCast.cpp
parent465184ae10e9ab0532cfe043d8a6b84d95c28b7f (diff)
downloadbcm5719-llvm-c1ed20cfbab3fb124125e2292b2c16f6ae00ed8d.tar.gz
bcm5719-llvm-c1ed20cfbab3fb124125e2292b2c16f6ae00ed8d.zip
Update const_cast semantics for rvalue references. Add tests for
reinterpret_cast and const_cast using rvalue references. llvm-svn: 124007
Diffstat (limited to 'clang/lib/Sema/SemaCXXCast.cpp')
-rw-r--r--clang/lib/Sema/SemaCXXCast.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaCXXCast.cpp b/clang/lib/Sema/SemaCXXCast.cpp
index 7badc7a7971..075deda4dd9 100644
--- a/clang/lib/Sema/SemaCXXCast.cpp
+++ b/clang/lib/Sema/SemaCXXCast.cpp
@@ -1050,9 +1050,8 @@ static TryCastResult TryConstCast(Sema &Self, Expr *SrcExpr, QualType DestType,
bool CStyle, unsigned &msg) {
DestType = Self.Context.getCanonicalType(DestType);
QualType SrcType = SrcExpr->getType();
- if (const LValueReferenceType *DestTypeTmp =
- DestType->getAs<LValueReferenceType>()) {
- if (!SrcExpr->isLValue()) {
+ if (const ReferenceType *DestTypeTmp =DestType->getAs<ReferenceType>()) {
+ if (DestTypeTmp->isLValueReferenceType() && !SrcExpr->isLValue()) {
// Cannot const_cast non-lvalue to lvalue reference type. But if this
// is C-style, static_cast might find a way, so we simply suggest a
// message and tell the parent to keep searching.
@@ -1156,8 +1155,8 @@ static TryCastResult TryReinterpretCast(Sema &Self, Expr *SrcExpr,
if (const ReferenceType *DestTypeTmp = DestType->getAs<ReferenceType>()) {
bool LValue = DestTypeTmp->isLValueReferenceType();
if (LValue && !SrcExpr->isLValue()) {
- // Cannot cast non-lvalue to reference type. See the similar comment in
- // const_cast.
+ // Cannot cast non-lvalue to lvalue reference type. See the similar
+ // comment in const_cast.
msg = diag::err_bad_cxx_cast_rvalue;
return TC_NotApplicable;
}
OpenPOWER on IntegriCloud