// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s // p3 // A glvalue of type "cv1 T1" can be cast to type "rvalue reference to // cv2 T2" if "cv2 T2" is reference-compatible with "cv1 T1" (8.5.3). // p4 // Otherwise, an expression e can be explicitly converted to a type T using a // static_cast of the form static_cast(e) if the declaration T t(e); is // well-formed, for some invented temporary variable t (8.5). [...] struct A { }; struct B : A { }; struct C { explicit operator A&&(); }; struct D { operator B(); }; template T& lvalue(); template T&& xvalue(); template T prvalue(); void test(A &a, B &b) { A &&ar0 = static_cast(prvalue()); A &&ar1 = static_cast(prvalue()); A &&ar2 = static_cast(lvalue()); A &&ar3 = static_cast(xvalue()); A &&ar4 = static_cast(prvalue()); A &&ar5 = static_cast(lvalue()); A &&ar6 = static_cast(xvalue()); A &&ar7 = static_cast(prvalue()); A &&ar8 = static_cast(prvalue()); // expected-error {{binding reference of type 'A' to value of type 'const A' drops 'const' qualifier}} A &&ar9 = static_cast(lvalue()); // expected-error {{cannot cast from lvalue of type 'const A'}} A &&ar10 = static_cast(xvalue()); // expected-error {{cannot cast from rvalue of type 'const A'}} const A &&ar11 = static_cast(prvalue()); const A &&ar12 = static_cast(prvalue()); const A &&ar13 = static_cast(lvalue()); const A &&ar14 = static_cast(xvalue()); const A &&ar15 = static_cast(prvalue()); const A &&ar16 = static_cast(lvalue()); const A &&ar17 = static_cast(prvalue()); // expected-error {{binding reference of type 'const A' to value of type 'const volatile A' drops 'volatile' qualifier}} }