[all-commits] [llvm/llvm-project] 200f3b: [Clang][Sema] access checking of friend declaratio...

Qizhi Hu via All-commits all-commits at lists.llvm.org
Fri May 10 05:14:29 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 200f3bd39562f4d605f13567398025d30fa27d61
      https://github.com/llvm/llvm-project/commit/200f3bd39562f4d605f13567398025d30fa27d61
  Author: Qizhi Hu <836744285 at qq.com>
  Date:   2024-05-10 (Fri, 10 May 2024)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Sema/Scope.h
    M clang/lib/Parse/ParseDecl.cpp
    M clang/lib/Sema/Scope.cpp
    M clang/lib/Sema/SemaAccess.cpp
    A clang/test/SemaCXX/PR12361.cpp

  Log Message:
  -----------
  [Clang][Sema] access checking of friend declaration should not be delayed (#91430)

attempt to fix https://github.com/llvm/llvm-project/issues/12361
Consider this example:
```cpp
class D {
    class E{
        class F{};
        friend  void foo(D::E::F& q);
        };
    friend  void foo(D::E::F& q);
    };

void foo(D::E::F& q) {}
```
The first friend declaration of foo is correct. After that, the second
friend declaration delayed access checking and set its previous
declaration to be the first one. When doing access checking of `F`(which
is private filed of `E`), we put its canonical declaration(the first
friend declaration) into `EffectiveContext.Functions`. Actually, we are
still checking the first one. This is incorrect due to the delayed
checking.
Creating a new scope to indicate we are parsing a friend declaration and
doing access checking in time.



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