[clang] [Clang] Disallow explicit object parameters in more contexts (PR #89078)

via cfe-commits cfe-commits at lists.llvm.org
Tue May 28 11:27:02 PDT 2024


================
@@ -11463,6 +11463,23 @@ void Sema::CheckExplicitObjectMemberFunction(Declarator &D,
     D.setInvalidType();
   }
 
+  // Handle the following case:
+  //
+  // struct S {
+  //   struct T {
+  //     int f(this T);
+  //   };
+  //
+  //   friend int T::f(this T); // Allow this.
+  //   friend int f(this S);    // But disallow this.
+  // };
+  if (D.getDeclSpec().isFriendSpecified() && D.getCXXScopeSpec().isEmpty()) {
----------------
cor3ntin wrote:

did you consider 

` friend int SomeNamespace::f(this T);` ?



https://github.com/llvm/llvm-project/pull/89078


More information about the cfe-commits mailing list