From: Douglas Gregor Date: Thu, 20 Jan 2011 17:04:36 +0000 (+0000) Subject: More tests for reference binding in the presence of rvalue X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=35e99fa40f1245cc554d8a26373e0486eb9c28f2;p=clang More tests for reference binding in the presence of rvalue references. Note that we're currently failing reference binding to a function lvalue. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123920 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp index 41741a98d8..f8a13b7c2a 100644 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp @@ -15,6 +15,11 @@ struct HasArray { int f(int); +template +struct ConvertsTo { + operator T(); +}; + void test_rvalue_refs() { // If the initializer expression... @@ -35,6 +40,23 @@ void test_rvalue_refs() { // 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&& base5 = ConvertsTo(); + int && int1 = ConvertsTo(); + + // class prvalue + Base&& base6 = ConvertsTo(); + Base&& base7 = ConvertsTo(); + + // FIXME: function lvalue + // int (&&function1)(int) = ConvertsTo(); } class NonCopyable { @@ -45,6 +67,7 @@ class NonCopyableDerived : public NonCopyable { NonCopyableDerived(const NonCopyableDerived&); }; +// Make sure we get direct bindings with no copies. void test_direct_binding() { NonCopyable &&nc0 = prvalue(); NonCopyable &&nc1 = prvalue(); @@ -54,4 +77,8 @@ void test_direct_binding() { const NonCopyable &nc5 = prvalue(); const NonCopyable &nc6 = xvalue(); const NonCopyable &nc7 = xvalue(); + NonCopyable &&nc8 = ConvertsTo(); + NonCopyable &&nc9 = ConvertsTo(); + const NonCopyable &nc10 = ConvertsTo(); + const NonCopyable &nc11 = ConvertsTo(); }