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