[all-commits] [llvm/llvm-project] 46b7a8: fix access checking about function overloading (#1...

Zhikai Zeng via All-commits all-commits at lists.llvm.org
Tue Jun 10 11:51:01 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 46b7a88548e5016f403cdc5f2cb1e4ff09353c3b
      https://github.com/llvm/llvm-project/commit/46b7a88548e5016f403cdc5f2cb1e4ff09353c3b
  Author: Zhikai Zeng <backlight.zzk at gmail.com>
  Date:   2025-06-10 (Tue, 10 Jun 2025)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/lib/Sema/SemaOverload.cpp
    M clang/test/CXX/class.access/p4.cpp

  Log Message:
  -----------
  fix access checking about function overloading (#107768)

fix https://github.com/llvm/llvm-project/issues/107629

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'}}
}
```

I think the `Found.getAccess()` is intended to be `AS_none` so I just
add one more access check for the `UnresolvedLookupExpr` when
`Found.getAccess()` is `AS_none`. If add the check unconditionally clang
will report lots of duplicate errors and cause several unit tests to
fail.

I also test the UB mentioned in
https://github.com/llvm/llvm-project/issues/107629 and clang now display
4 `false` as expecetd.

Co-authored-by: Erich Keane <ekeane at nvidia.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list