1// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2// expected-no-diagnostics
3
4template<typename T> T &lvalue();
5template<typename T> T &&xvalue();
6template<typename T> T prvalue();
7
8struct X0 {
9  int &f() &;
10  float &f() &&;
11
12  template<typename T> int &ft(T) &;
13  template<typename T> float &ft(T) &&;
14
15  typedef int &(*func_int_ref)();
16  typedef float &(*func_float_ref)();
17
18  operator func_int_ref() &;
19  operator func_float_ref() &&;
20
21  void g();
22
23  int &operator+(const X0&) &;
24  float &operator+(const X0&) &&;
25
26  template<typename T> int &operator+(const T&) &;
27  template<typename T> float &operator+(const T&) &&;
28
29  int &h() const&;
30  float &h() &&;
31  int &h2() const&;
32  float &h2() const&&;
33};
34
35void X0::g() {
36  int &ir1 = f();
37  int &ir2 = X0::f();
38}
39
40void test_ref_qualifier_binding() {
41  int &ir1 = lvalue<X0>().f();
42  float &fr1 = xvalue<X0>().f();
43  float &fr2 = prvalue<X0>().f();
44  int &ir2 = lvalue<X0>().ft(1);
45  float &fr3 = xvalue<X0>().ft(2);
46  float &fr4 = prvalue<X0>().ft(3);
47}
48
49void test_ref_qualifier_binding_with_surrogates() {
50  int &ir1 = lvalue<X0>()();
51  float &fr1 = xvalue<X0>()();
52  float &fr2 = prvalue<X0>()();
53}
54
55void test_ref_qualifier_binding_operators() {
56  int &ir1 = lvalue<X0>() + prvalue<X0>();
57  float &fr1 = xvalue<X0>() + prvalue<X0>();
58  float &fr2 = prvalue<X0>() + prvalue<X0>();
59  int &ir2 = lvalue<X0>() + 1;
60  float &fr3 = xvalue<X0>() + 2;
61  float &fr4 = prvalue<X0>() + 3;
62}
63
64void test_ref_qualifier_overloading() {
65  int &ir1 = lvalue<X0>().h();
66  float &fr1 = xvalue<X0>().h();
67  float &fr2 = prvalue<X0>().h();
68  int &ir2 = lvalue<X0>().h2();
69  float &fr3 = xvalue<X0>().h2();
70  float &fr4 = prvalue<X0>().h2();
71}
72