p3-0x.cpp revision 8e8fb3be5bd78f0564444eca02b404566a5f3b5d
1// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s 2// expected-no-diagnostics 3 4// A glvalue of type "cv1 T1" can be cast to type "rvalue reference to 5// cv2 T2" if "cv2 T2" is reference-compatible with "cv1 T1" (8.5.3). 6struct A { }; 7struct B : A { }; 8 9template<typename T> T& lvalue(); 10template<typename T> T&& xvalue(); 11 12void test(A &a, B &b) { 13 A &&ar0 = static_cast<A&&>(a); 14 A &&ar1 = static_cast<A&&>(b); 15 A &&ar2 = static_cast<A&&>(lvalue<A>()); 16 A &&ar3 = static_cast<A&&>(lvalue<B>()); 17 A &&ar4 = static_cast<A&&>(xvalue<A>()); 18 A &&ar5 = static_cast<A&&>(xvalue<B>()); 19 const A &&ar6 = static_cast<const A&&>(a); 20 const A &&ar7 = static_cast<const A&&>(b); 21 const A &&ar8 = static_cast<const A&&>(lvalue<A>()); 22 const A &&ar9 = static_cast<const A&&>(lvalue<B>()); 23 const A &&ar10 = static_cast<const A&&>(xvalue<A>()); 24 const A &&ar11 = static_cast<const A&&>(xvalue<B>()); 25} 26