p1-0x.cpp revision 762bb9d0ad20320b9f97a841dce57ba5e8e48b07
1762bb9d0ad20320b9f97a841dce57ba5e8e48b07Richard Smith// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregor
3575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregor// The result of the expression const_cast<T>(v) is of type T. If T is
4575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregor// an lvalue reference to object type, the result is an lvalue; if T
5575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregor// is an rvalue reference to object type, the result is an xvalue;.
6575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregor
7575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregorunsigned int f(int);
8575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregor
9575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregortemplate<typename T> T& lvalue();
10575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregortemplate<typename T> T&& xvalue();
11575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregortemplate<typename T> T prvalue();
12575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregor
13575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregorvoid test_classification(const int *ptr) {
14575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregor  int *ptr0 = const_cast<int *&&>(ptr);
15575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregor  int *ptr1 = const_cast<int *&&>(xvalue<const int*>());
16575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregor  int *ptr2 = const_cast<int *&&>(prvalue<const int*>());
17575d2a30f288ddab2f24a77dfcc71f6f7f808394Douglas Gregor}
18