xref: /aosp_15_r20/external/clang/test/CXX/over/over.load/p2-0x.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2*67e74705SXin Li 
3*67e74705SXin Li // Member function declarations with the same name and the same
4*67e74705SXin Li // parameter-type-list as well as mem- ber function template
5*67e74705SXin Li // declarations with the same name, the same parameter-type-list, and
6*67e74705SXin Li // the same template parameter lists cannot be overloaded if any of
7*67e74705SXin Li // them, but not all, have a ref-qualifier (8.3.5).
8*67e74705SXin Li 
9*67e74705SXin Li class Y {
10*67e74705SXin Li   void h() &;
11*67e74705SXin Li   void h() const &;
12*67e74705SXin Li   void h() &&;
13*67e74705SXin Li   void i() &; // expected-note{{previous declaration}}
14*67e74705SXin Li   void i() const; // expected-error{{cannot overload a member function without a ref-qualifier with a member function with ref-qualifier '&'}}
15*67e74705SXin Li 
16*67e74705SXin Li   template<typename T> void f(T*) &;
17*67e74705SXin Li   template<typename T> void f(T*) &&;
18*67e74705SXin Li 
19*67e74705SXin Li   template<typename T> void g(T*) &; // expected-note{{previous declaration}}
20*67e74705SXin Li   template<typename T> void g(T*); // expected-error{{cannot overload a member function without a ref-qualifier with a member function with ref-qualifier '&'}}
21*67e74705SXin Li 
22*67e74705SXin Li   void k(); // expected-note{{previous declaration}}
23*67e74705SXin Li   void k() &&; // expected-error{{cannot overload a member function with ref-qualifier '&&' with a member function without a ref-qualifier}}
24*67e74705SXin Li };
25