[clang] fix access checking about function overloading (PR #107768)
Zhikai Zeng via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 13 07:54:01 PDT 2024
Backl1ght wrote:
After some more debugging, I find out that we will check access here at https://github.com/llvm/llvm-project/blob/8e010ac5a173c9dee44b44324169a3e100a1a6fc/clang/lib/Sema/SemaInit.cpp#L7807
And for `f()` inside code below, `Found.getAccess()` is `AS_none` hence `CheckAddressOfMemberAccess` return `AR_accessible` directly.
```cpp
struct Base {
public:
int f(int);
private:
int f(); // expect-note {{declared private here}}
};
struct Derived : public Base {};
void f() {
int(Derived::* public_f)(int) = &Derived::f;
int(Derived::* private_f)() = &Derived::f; // expect-error {{'f' is a private member of 'Base'}}
}
```
https://github.com/llvm/llvm-project/pull/107768
More information about the cfe-commits
mailing list