[clang] [Clang][Sema] access checking of friend declaration should not be delayed (PR #91430)
via cfe-commits
cfe-commits at lists.llvm.org
Wed May 8 01:38:51 PDT 2024
================
@@ -1477,8 +1477,16 @@ static Sema::AccessResult CheckAccess(Sema &S, SourceLocation Loc,
// void foo(A::private_type);
// void B::foo(A::private_type);
if (S.DelayedDiagnostics.shouldDelayDiagnostics()) {
- S.DelayedDiagnostics.add(DelayedDiagnostic::makeAccess(Loc, Entity));
- return Sema::AR_delayed;
+ Scope *TS = S.getCurScope();
+ bool IsFriendDeclaration = false;
+ while (TS && !IsFriendDeclaration) {
+ IsFriendDeclaration = TS->isFriendScope();
+ TS = TS->getParent();
+ }
+ if (!IsFriendDeclaration) {
+ S.DelayedDiagnostics.add(DelayedDiagnostic::makeAccess(Loc, Entity));
+ return Sema::AR_delayed;
+ }
----------------
cor3ntin wrote:
We might want to quote the standard
https://eel.is/c++draft/class.friend#9
https://github.com/llvm/llvm-project/pull/91430
More information about the cfe-commits
mailing list