brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · f813305 Raw
61 lines · cpp
1// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s2// expected-no-diagnostics3namespace std_example {4  int i; 5  int f1(); 6  int&& f2(); 7  int &g(const int &);8  float &g(const int &&);9  int &j = g(i); 10  float &k = g(f1());11  float &l = g(f2());12 13  int &g2(const int &);14  float &g2(int &&);15  int &j2 = g2(i); 16  float &k2 = g2(f1());17  float &l2 = g2(f2());18 19  // FIXME: We don't support ref-qualifiers yet.20#if 021  struct A { 22    A& operator<<(int); 23    void p() &; 24    void p() &&;25  };26 27  A& operator<<(A&&, char); 28  A() << 1; 29  A() << 'c'; 30  A a; 31  a << 1; 32  a << 'c'; 33  A().p(); 34  a.p();35#endif36}37 38template<typename T>39struct remove_reference {40  typedef T type;41};42 43template<typename T>44struct remove_reference<T&> {45  typedef T type;46};47 48template<typename T>49struct remove_reference<T&&> {50  typedef T type;51};52 53namespace FunctionReferencesOverloading {54  template<typename T> int &f(typename remove_reference<T>::type&);55  template<typename T> float &f(typename remove_reference<T>::type&&);56 57  void test_f(int (&func_ref)(int)) {58    int &ir = f<int (&)(int)>(func_ref);59  }60}61