diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-01-21 01:11:43 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-01-21 01:11:43 +0000 |
commit | 00d66cce52cf027eac77591a9847f87dacf36995 (patch) | |
tree | aa6c5f6e17e8abc8f4198db5148857c43185e67f | |
parent | 7ac0ff2a8791280102a557761dbb931deb21a1dc (diff) |
Add more reference-binding examples from the C++0x working paper, all of which seem to be working fine
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123955 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
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 fe67d8a917..6f81326b1d 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 @@ -89,7 +89,23 @@ void test_direct_binding() { const NonCopyable &nc11 = ConvertsTo<NonCopyableDerived&&>(); } -namespace std_example { +namespace std_example_1 { + double d = 2.0; + double& rd = d; + const double& rcd = d; + struct A { }; + struct B : A { + operator int&(); + } b; + A& ra = b; + const A& rca = b; + int& ir = B(); +} + +namespace std_example_2 { + double& rd2 = 2.0; // expected-error{{non-const lvalue reference to type 'double' cannot bind to a temporary of type 'double'}} + int i = 2; + double& rd3 = i; // expected-error{{non-const lvalue reference to type 'double' cannot bind to a value of unrelated type 'int'}} struct A { }; struct B : A { } b; extern B f(); @@ -100,8 +116,17 @@ namespace std_example { operator int&(); // expected-note{{candidate function}} } x; const A& r = x; - int i; int&& rri = static_cast<int&&>(i); B&& rrb = x; - int&& rri2 = X(); // expected-error{{no viable conversion from 'std_example::X' to 'int'}} + int&& rri2 = X(); // expected-error{{no viable conversion from 'std_example_2::X' to 'int'}} + + const double& rcd2 = 2; + double&& rrd = 2; + const volatile int cvi = 1; + const int& r2 = cvi; // expected-error{{binding of reference to type 'const int' to a value of type 'const volatile int' drops qualifiers}} + + double d; + double&& rrd2 = d; // expected-error{{rvalue reference to type 'double' cannot bind to lvalue of type 'double'}} + double&& rrd3 = i; } + |