summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2010-07-26 17:52:21 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2010-07-26 17:52:21 +0000
commitae8cbb7220c6d5fa72d47429d4dd7cfeb69e6261 (patch)
treefa14820946a1d6cd43a7aed799ead89efdff0092
parent30005444fe7b6956db675db343e47613b19f8219 (diff)
downloadbcm5719-llvm-ae8cbb7220c6d5fa72d47429d4dd7cfeb69e6261.tar.gz
bcm5719-llvm-ae8cbb7220c6d5fa72d47429d4dd7cfeb69e6261.zip
Make sure that implicit qualification and derived-to-base conversions of xvalues preserve xvalue-ness. Unfortunately I have no idea how to test this property; there doesn't seem to be a syntactical construct that triggers such a conversion and still allows the distinction between prvalues and xvalues to be made.
llvm-svn: 109406
-rw-r--r--clang/lib/Sema/SemaInit.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 7a5c1459d6d..5aa649bdc92 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -2397,7 +2397,7 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S,
Category = ImplicitCastExpr::LValue;
else if (const RValueReferenceType *RRef = T2->getAs<RValueReferenceType>())
Category = RRef->getPointeeType()->isFunctionType() ?
- ImplicitCastExpr::LValue : ImplicitCastExpr::RValue;
+ ImplicitCastExpr::LValue : ImplicitCastExpr::XValue;
bool NewDerivedToBase = false;
Sema::ReferenceCompareResult NewRefRelationship
@@ -2555,6 +2555,7 @@ static void TryReferenceInitialization(Sema &S,
// - [If T1 is not a function type], if T2 is a class type and
if (!T1Function && T2->isRecordType()) {
+ bool isXValue = InitCategory.isXValue();
// - the initializer expression is an rvalue and "cv1 T1" is
// reference-compatible with "cv2 T2", or
if (InitCategory.isRValue() &&
@@ -2574,10 +2575,13 @@ static void TryReferenceInitialization(Sema &S,
if (DerivedToBase)
Sequence.AddDerivedToBaseCastStep(
S.Context.getQualifiedType(T1, T2Quals),
- ImplicitCastExpr::RValue);
+ isXValue ? ImplicitCastExpr::XValue
+ : ImplicitCastExpr::RValue);
if (T1Quals != T2Quals)
- Sequence.AddQualificationConversionStep(cv1T1,ImplicitCastExpr::RValue);
- Sequence.AddReferenceBindingStep(cv1T1, /*bindingTemporary=*/true);
+ Sequence.AddQualificationConversionStep(cv1T1,
+ isXValue ? ImplicitCastExpr::XValue
+ : ImplicitCastExpr::RValue);
+ Sequence.AddReferenceBindingStep(cv1T1, /*bindingTemporary=*/!isXValue);
return;
}
OpenPOWER on IntegriCloud