]> granicus.if.org Git - clang/commitdiff
PR12826: Converting an lvalue to an xvalue is a no-op conversion, not an lvalue-to...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 15 May 2012 05:04:02 +0000 (05:04 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 15 May 2012 05:04:02 +0000 (05:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156803 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaStmt.cpp
test/SemaCXX/constant-expression-cxx11.cpp

index 2e1cc7c60057555a4f2b04731c5367e73063a65d..2ea07efde840ac30d6ad3c1e3e6a6ab4ed90831c 100644 (file)
@@ -2033,8 +2033,7 @@ Sema::PerformMoveOrCopyInitialization(const InitializedEntity &Entity,
   if (AllowNRVO &&
       (NRVOCandidate || getCopyElisionCandidate(ResultType, Value, true))) {
     ImplicitCastExpr AsRvalue(ImplicitCastExpr::OnStack,
-                              Value->getType(), CK_LValueToRValue,
-                              Value, VK_XValue);
+                              Value->getType(), CK_NoOp, Value, VK_XValue);
 
     Expr *InitExpr = &AsRvalue;
     InitializationKind Kind
@@ -2069,8 +2068,7 @@ Sema::PerformMoveOrCopyInitialization(const InitializedEntity &Entity,
         // Promote "AsRvalue" to the heap, since we now need this
         // expression node to persist.
         Value = ImplicitCastExpr::Create(Context, Value->getType(),
-                                         CK_LValueToRValue, Value, 0,
-                                         VK_XValue);
+                                         CK_NoOp, Value, 0, VK_XValue);
 
         // Complete type-checking the initialization of the return type
         // using the constructor we found.
index a9e1008ec6db3225e92b32663423955785e628c4..263e8411b4d008fe8ed6f7fa1dfbb62a09e66fe2 100644 (file)
@@ -1258,3 +1258,11 @@ namespace InvalidClasses {
     auto& b = y.b;
   }
 }
+
+// Indirectly test that an implicit lvalue to xvalue conversion performed for
+// an NRVO move operation isn't implemented as CK_LValueToRValue.
+namespace PR12826 {
+  struct Foo {};
+  constexpr Foo id(Foo x) { return x; }
+  constexpr Foo res(id(Foo()));
+}