xref: /llvm-project/clang/test/CXX/expr/expr.post/expr.static.cast/p3-0x.cpp (revision c6e68daac0fa6e77a89f3ca72f266a528503dd1c)
19ca5c425SRichard Smith // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2*c6e68daaSAndy Gibbs // expected-no-diagnostics
3465184aeSDouglas Gregor 
4465184aeSDouglas Gregor // A glvalue of type "cv1 T1" can be cast to type "rvalue reference to
5465184aeSDouglas Gregor // cv2 T2" if "cv2 T2" is reference-compatible with "cv1 T1" (8.5.3).
6465184aeSDouglas Gregor struct A { };
7465184aeSDouglas Gregor struct B : A { };
8465184aeSDouglas Gregor 
9465184aeSDouglas Gregor template<typename T> T& lvalue();
10465184aeSDouglas Gregor template<typename T> T&& xvalue();
11465184aeSDouglas Gregor 
test(A & a,B & b)12465184aeSDouglas Gregor void test(A &a, B &b) {
13465184aeSDouglas Gregor   A &&ar0 = static_cast<A&&>(a);
14465184aeSDouglas Gregor   A &&ar1 = static_cast<A&&>(b);
15465184aeSDouglas Gregor   A &&ar2 = static_cast<A&&>(lvalue<A>());
16465184aeSDouglas Gregor   A &&ar3 = static_cast<A&&>(lvalue<B>());
17465184aeSDouglas Gregor   A &&ar4 = static_cast<A&&>(xvalue<A>());
18465184aeSDouglas Gregor   A &&ar5 = static_cast<A&&>(xvalue<B>());
19465184aeSDouglas Gregor   const A &&ar6 = static_cast<const A&&>(a);
20465184aeSDouglas Gregor   const A &&ar7 = static_cast<const A&&>(b);
21465184aeSDouglas Gregor   const A &&ar8 = static_cast<const A&&>(lvalue<A>());
22465184aeSDouglas Gregor   const A &&ar9 = static_cast<const A&&>(lvalue<B>());
23465184aeSDouglas Gregor   const A &&ar10 = static_cast<const A&&>(xvalue<A>());
24465184aeSDouglas Gregor   const A &&ar11 = static_cast<const A&&>(xvalue<B>());
25465184aeSDouglas Gregor }
26