[clang] [Clang] Disallow explicit object parameters in more contexts (PR #89078)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue May 28 11:53:47 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()) {
----------------
AaronBallman wrote:
Heh, another terrible test case to consider but should just fall out naturally is:
```
struct S {
int friend func(this T);
};
```
https://github.com/llvm/llvm-project/pull/89078
More information about the cfe-commits
mailing list