The attached patch fixes pr11009 and introduces no regressions in make
check. Is the logic detecting when we have an xvalue correct? Is the
patch OK?

Thanks,
Rafael
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 0c518c7..749ac7f 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -4483,6 +4483,7 @@ InitializationSequence::Perform(Sema &S,
       DeclAccessPair FoundFn = Step->Function.FoundDecl;
       bool CreatedObject = false;
       bool IsLvalue = false;
+      bool IsRvalue = false;
       if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(Fn)) {
         // Build a call to the selected constructor.
         ASTOwningVector<Expr*> ConstructorArgs(S);
@@ -4521,6 +4522,7 @@ InitializationSequence::Perform(Sema &S,
         // Build a call to the conversion function.
         CXXConversionDecl *Conversion = cast<CXXConversionDecl>(Fn);
         IsLvalue = Conversion->getResultType()->isLValueReferenceType();
+        IsRvalue = Conversion->getResultType()->isRValueReferenceType();
         S.CheckMemberOperatorAccess(Kind.getLocation(), CurInit.get(), 0,
                                     FoundFn);
         S.DiagnoseUseOfDecl(FoundFn, Kind.getLocation());
@@ -4560,11 +4562,17 @@ InitializationSequence::Perform(Sema &S,
         }
       }
 
-      // FIXME: xvalues
+      ExprValueKind VK;
+      if (IsLvalue)
+        VK = VK_LValue;
+      else if (IsRvalue)
+        VK = VK_XValue;
+      else
+        VK = VK_RValue;
       CurInit = S.Owned(ImplicitCastExpr::Create(S.Context,
                                                  CurInit.get()->getType(),
                                                  CastKind, CurInit.get(), 0,
-                                           IsLvalue ? VK_LValue : VK_RValue));
+                                                 VK));
 
       if (RequiresCopy)
         CurInit = CopyObject(S, Entity.getType().getNonReferenceType(), Entity,
diff --git a/test/CodeGenCXX/rvalue-references.cpp b/test/CodeGenCXX/rvalue-references.cpp
index f8e3eb2..3d68d45 100644
--- a/test/CodeGenCXX/rvalue-references.cpp
+++ b/test/CodeGenCXX/rvalue-references.cpp
@@ -101,3 +101,13 @@ namespace test1 {
   // CHECK-NEXT: ret void
   B::B(int i) : a(move(i)) {}
 }
+
+namespace pr11009 {
+  struct MoveRef {
+    operator int&& ();
+  };
+  MoveRef Move(int t);
+  void moveConstruct() {
+    int(Move(0));
+  }
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to