p3-0x.cpp 903 B

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