================ @@ -542,3 +542,46 @@ void foo(C c) { } } + + +namespace GH69838 { +struct S { + S(this auto &self) {} // expected-error {{an explicit object parameter cannot appear in a constructor}} + virtual void f(this S self) {} // expected-error {{an explicit object parameter cannot appear in a virtual function}} + void g(this auto &self) const {} // expected-error {{explicit object member function cannot have 'const' qualifier}} + void h(this S self = S{}) {} // expected-error {{the explicit object parameter cannot have a default argument}} + void i(int i, this S self = S{}) {} // expected-error {{an explicit object parameter can only appear as the first parameter of the function}} + ~S(this S &&self); // expected-error {{an explicit object parameter cannot appear in a destructor}} \ + // expected-error {{destructor cannot have any parameters}} + + static void j(this S s); // expected-error {{an explicit object parameter cannot appear in a static function}} +}; + +void nonmember(this S s); // expected-error {{an explicit object parameter cannot appear in a non-member function}} ---------------- shafik wrote:
You could add `static` here for extra fun. https://github.com/llvm/llvm-project/pull/70018 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits