1762bb9d0ad20320b9f97a841dce57ba5e8e48b07Richard Smith// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregor
3575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregor// If T is an lvalue reference type or an rvalue reference to function
4575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregor// type, the result is an lvalue; if T is an rvalue reference to
5575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregor// object type, the result is an xvalue;
6575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregor
7575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregorunsigned int f(int);
8575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregor
9575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregortemplate<typename T> T&& xvalue();
10575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregorvoid test_classification(char *ptr) {
11575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregor  int (&fr0)(int) = reinterpret_cast<int (&&)(int)>(f);
12575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregor  int &&ir0 = reinterpret_cast<int &&>(*ptr);
136850fafd27ba804d4d4ca8af404beed5574e3749Richard Smith  int &&ir1 = reinterpret_cast<int &&>(0); // expected-error {{rvalue to reference type}}
146850fafd27ba804d4d4ca8af404beed5574e3749Richard Smith  int &&ir2 = reinterpret_cast<int &&>('a'); // expected-error {{rvalue to reference type}}
15575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregor  int &&ir3 = reinterpret_cast<int &&>(xvalue<char>());
166850fafd27ba804d4d4ca8af404beed5574e3749Richard Smith  // Per DR1268, reinterpret_cast can convert between lvalues and xvalues.
176850fafd27ba804d4d4ca8af404beed5574e3749Richard Smith  int &ir4 = reinterpret_cast<int &>(xvalue<char>());
186850fafd27ba804d4d4ca8af404beed5574e3749Richard Smith  int &&ir5 = reinterpret_cast<int &&>(*ptr);
19575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregor}
20