[clang] [Clang] Mark declarators invalid in the presence of ill-formed explicit parameters. (PR #70018)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 26 21:48:49 PDT 2023
================
@@ -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
More information about the cfe-commits
mailing list