[cfe-commits] r109406 - /cfe/trunk/lib/Sema/SemaInit.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Mon Jul 26 10:52:21 PDT 2010


Author: cornedbee
Date: Mon Jul 26 12:52:21 2010
New Revision: 109406

URL: http://llvm.org/viewvc/llvm-project?rev=109406&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=109406&r1=109405&r2=109406&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Jul 26 12:52:21 2010
@@ -2397,7 +2397,7 @@
     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 @@
 
   //       - [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 @@
       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;
     }
 





More information about the cfe-commits mailing list