Implement the preference for move-construction over copy-construction
when returning an NRVO candidate expression. For example, this
properly picks the move constructor when dealing with code such as

  MoveOnlyType f() { MoveOnlyType mot; return mot; }

The previously-XFAIL'd rvalue-references test case now works, and has
been moved into the appropriate paragraph-specific test case.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123992 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CXX/special/class.copy/p33-0x.cpp b/test/CXX/special/class.copy/p33-0x.cpp
new file mode 100644
index 0000000..a9ce589
--- /dev/null
+++ b/test/CXX/special/class.copy/p33-0x.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+class X {
+  X(const X&);
+
+public:
+  X();
+  X(X&&);
+};
+
+X return_by_move(int i, X x) {
+  X x2;
+  if (i == 0)
+    return x;
+  else if (i == 1)
+    return x2;
+  else
+    return x;
+}
+  
diff --git a/test/SemaCXX/rval-references-examples.cpp b/test/SemaCXX/rval-references-examples.cpp
index 1cde585..778924d 100644
--- a/test/SemaCXX/rval-references-examples.cpp
+++ b/test/SemaCXX/rval-references-examples.cpp
@@ -59,7 +59,7 @@
 
 template<typename T> void accept_unique_ptr(unique_ptr<T>); // expected-note{{passing argument to parameter here}}
 
-void test_unique_ptr() {
+unique_ptr<int> test_unique_ptr() {
   // Simple construction
   unique_ptr<int> p;
   unique_ptr<int> p1(new int);
@@ -85,4 +85,6 @@
 
   // Implicit copies (failures);
   accept_unique_ptr(p); // expected-error{{call to deleted constructor of 'unique_ptr<int>'}}
+
+  return p;
 }
diff --git a/test/SemaCXX/rval-references-xfail.cpp b/test/SemaCXX/rval-references-xfail.cpp
deleted file mode 100644
index d41f8f1..0000000
--- a/test/SemaCXX/rval-references-xfail.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
-// XFAIL: *
-struct MoveOnly {
-  MoveOnly();
-  MoveOnly(const MoveOnly&) = delete;	// expected-note {{candidate function}} \
-  // expected-note 3{{explicitly marked deleted here}}
-  MoveOnly(MoveOnly&&);	// expected-note {{candidate function}}
-  MoveOnly(int&&);	// expected-note {{candidate function}}
-};
-
-MoveOnly returning() {
-  MoveOnly mo;
-  return mo;
-}