[cfe-commits] r123920 - /cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp

Douglas Gregor dgregor at apple.com
Thu Jan 20 09:04:36 PST 2011


Author: dgregor
Date: Thu Jan 20 11:04:36 2011
New Revision: 123920

URL: http://llvm.org/viewvc/llvm-project?rev=123920&view=rev
Log:
More tests for reference binding in the presence of rvalue
references. Note that we're currently failing reference binding to a
function lvalue.

Modified:
    cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp

Modified: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp?rev=123920&r1=123919&r2=123920&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp Thu Jan 20 11:04:36 2011
@@ -15,6 +15,11 @@
 
 int f(int);
 
+template<typename T>
+struct ConvertsTo {
+  operator T();
+};
+
 void test_rvalue_refs() {
   // If the initializer expression...
 
@@ -35,6 +40,23 @@
 
   // function lvalue case
   int (&&function0)(int) = f;
+
+  //   - has a class type (i.e., T2 is a class type), where T1 is not
+  //     reference-related to T2, and can be implicitly converted to
+  //     an xvalue, class prvalue, or function lvalue of type "cv3
+  //     T3", where "cv1 T1" is reference-compatible with "cv3 T3",
+
+  // xvalue
+  Base&& base4 = ConvertsTo<Base&&>();
+  Base&& base5 = ConvertsTo<Derived&&>();
+  int && int1 = ConvertsTo<int&&>();
+
+  // class prvalue
+  Base&& base6 = ConvertsTo<Base>();
+  Base&& base7 = ConvertsTo<Derived>();
+  
+  // FIXME: function lvalue
+  //  int (&&function1)(int) = ConvertsTo<int(&)(int)>();
 }
 
 class NonCopyable {
@@ -45,6 +67,7 @@
   NonCopyableDerived(const NonCopyableDerived&);
 };
 
+// Make sure we get direct bindings with no copies.
 void test_direct_binding() {
   NonCopyable &&nc0 = prvalue<NonCopyable>();
   NonCopyable &&nc1 = prvalue<NonCopyableDerived>();
@@ -54,4 +77,8 @@
   const NonCopyable &nc5 = prvalue<NonCopyableDerived>();
   const NonCopyable &nc6 = xvalue<NonCopyable>();
   const NonCopyable &nc7 = xvalue<NonCopyableDerived>();
+  NonCopyable &&nc8 = ConvertsTo<NonCopyable&&>();
+  NonCopyable &&nc9 = ConvertsTo<NonCopyableDerived&&>();
+  const NonCopyable &nc10 = ConvertsTo<NonCopyable&&>();
+  const NonCopyable &nc11 = ConvertsTo<NonCopyableDerived&&>();
 }





More information about the cfe-commits mailing list