1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s 2 // RUN: %clang_cc1 -std=c++1z -fsyntax-only -verify %s 3 4 void f0() &; // expected-error {{non-member function cannot have '&' qualifier}} 5 void f1() &&; // expected-error {{non-member function cannot have '&&' qualifier}} 6 void f2() const volatile &&; // expected-error {{non-member function cannot have 'const volatile &&' qualifier}} 7 8 struct X { 9 void f0() &; 10 void f1() &&; 11 static void f2() &; // expected-error{{static member function cannot have '&' qualifier}} 12 static void f3() &&; // expected-error{{static member function cannot have '&&' qualifier}} 13 }; 14 15 typedef void func_type_lvalue() &; 16 typedef void func_type_rvalue() &&; 17 18 typedef func_type_lvalue *func_type_lvalue_ptr; // expected-error{{pointer to function type 'func_type_lvalue' (aka 'void () &') cannot have '&' qualifier}} 19 typedef func_type_rvalue *func_type_rvalue_ptr; // expected-error{{pointer to function type 'func_type_rvalue' (aka 'void () &&') cannot have '&&' qualifier}} 20 21 typedef func_type_lvalue &func_type_lvalue_ref; // expected-error{{reference to function type 'func_type_lvalue' (aka 'void () &') cannot have '&' qualifier}} 22 typedef func_type_rvalue &func_type_rvalue_ref; // expected-error{{reference to function type 'func_type_rvalue' (aka 'void () &&') cannot have '&&' qualifier}} 23 24 template<typename T = func_type_lvalue> struct wrap { 25 typedef T val; 26 typedef T *ptr; // expected-error-re 2{{pointer to function type '{{.*}}' cannot have '{{&|&&}}' qualifier}} 27 typedef T &ref; // expected-error-re 2{{reference to function type '{{.*}}' cannot have '{{&|&&}}' qualifier}} 28 }; 29 30 using func_type_lvalue = wrap<>::val; // expected-note{{in instantiation of}} 31 using func_type_lvalue = wrap<func_type_lvalue>::val; 32 using func_type_rvalue = wrap<func_type_rvalue>::val; // expected-note{{in instantiation of}} 33 34 using func_type_lvalue_ptr = wrap<>::ptr; 35 using func_type_lvalue_ptr = wrap<func_type_lvalue>::ptr; 36 using func_type_rvalue_ptr = wrap<func_type_rvalue>::ptr; 37 38 using func_type_lvalue_ref = wrap<>::ref; 39 using func_type_lvalue_ref = wrap<func_type_lvalue>::ref; 40 using func_type_rvalue_ref = wrap<func_type_rvalue>::ref; 41 42 func_type_lvalue f2; // expected-error{{non-member function of type 'func_type_lvalue' (aka 'void () &') cannot have '&' qualifier}} 43 func_type_rvalue f3; // expected-error{{non-member function of type 'func_type_rvalue' (aka 'void () &&') cannot have '&&' qualifier}} 44 45 struct Y { 46 func_type_lvalue f0; 47 func_type_rvalue f1; 48 }; 49 50 void (X::*mpf1)() & = &X::f0; 51 void (X::*mpf2)() && = &X::f1; 52 53 54 void (f() &&); // expected-error{{non-member function cannot have '&&' qualifier}} 55 56 // FIXME: These are ill-formed. 57 template<typename T> struct pass { 58 void f(T); 59 }; 60 pass<func_type_lvalue> pass0; 61 pass<func_type_lvalue> pass1; 62 63 template<typename T, typename U> struct is_same { static const bool value = false; }; 64 template<typename T> struct is_same<T, T> { static const bool value = true; }; 65 constexpr bool cxx1z = __cplusplus > 201402L; 66 67 void noexcept_true() noexcept(true); 68 void noexcept_false() noexcept(false); 69 using func_type_noexcept_true = wrap<decltype(noexcept_true)>; 70 using func_type_noexcept_false = wrap<decltype(noexcept_false)>; 71 static_assert(is_same<func_type_noexcept_false, func_type_noexcept_true>::value == !cxx1z, ""); 72 static_assert(is_same<func_type_noexcept_false::val, func_type_noexcept_true::val>::value == !cxx1z, ""); 73 static_assert(is_same<func_type_noexcept_false::ptr, func_type_noexcept_true::ptr>::value == !cxx1z, ""); 74 static_assert(is_same<func_type_noexcept_false::ref, func_type_noexcept_true::ref>::value == !cxx1z, ""); 75