1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2 
3 void f0() &; // expected-error {{non-member function cannot have '&' qualifier}}
4 void f1() &&; // expected-error {{non-member function cannot have '&&' qualifier}}
5 void f2() const volatile &&; // expected-error {{non-member function cannot have 'const volatile &&' qualifier}}
6 
7 struct X {
8   void f0() &;
9   void f1() &&;
10   static void f2() &; // expected-error{{static member function cannot have '&' qualifier}}
11   static void f3() &&; // expected-error{{static member function cannot have '&&' qualifier}}
12 };
13 
14 typedef void func_type_lvalue() &;
15 typedef void func_type_rvalue() &&;
16 
17 typedef func_type_lvalue *func_type_lvalue_ptr; // expected-error{{pointer to function type 'func_type_lvalue' (aka 'void () &') cannot have '&' qualifier}}
18 typedef func_type_rvalue *func_type_rvalue_ptr; // expected-error{{pointer to function type 'func_type_rvalue' (aka 'void () &&') cannot have '&&' qualifier}}
19 
20 typedef func_type_lvalue &func_type_lvalue_ref; // expected-error{{reference to function type 'func_type_lvalue' (aka 'void () &') cannot have '&' qualifier}}
21 typedef func_type_rvalue &func_type_rvalue_ref; // expected-error{{reference to function type 'func_type_rvalue' (aka 'void () &&') cannot have '&&' qualifier}}
22 
23 template<typename T = func_type_lvalue> struct wrap {
24   typedef T val;
25   typedef T *ptr;
26   typedef T &ref;
27 };
28 
29 using func_type_lvalue = wrap<>::val;
30 using func_type_lvalue = wrap<func_type_lvalue>::val;
31 using func_type_rvalue = wrap<func_type_rvalue>::val;
32 
33 using func_type_lvalue_ptr = wrap<>::ptr;
34 using func_type_lvalue_ptr = wrap<func_type_lvalue>::ptr;
35 using func_type_rvalue_ptr = wrap<func_type_rvalue>::ptr;
36 
37 using func_type_lvalue_ref = wrap<>::ref;
38 using func_type_lvalue_ref = wrap<func_type_lvalue>::ref;
39 using func_type_rvalue_ref = wrap<func_type_rvalue>::ref;
40 
41 func_type_lvalue f2; // expected-error{{non-member function of type 'func_type_lvalue' (aka 'void () &') cannot have '&' qualifier}}
42 func_type_rvalue f3; // expected-error{{non-member function of type 'func_type_rvalue' (aka 'void () &&') cannot have '&&' qualifier}}
43 
44 struct Y {
45   func_type_lvalue f0;
46   func_type_rvalue f1;
47 };
48 
49 void (X::*mpf1)() & = &X::f0;
50 void (X::*mpf2)() && = &X::f1;
51 
52 
53 void (f() &&); // expected-error{{non-member function cannot have '&&' qualifier}}
54