Skip to content

Commit 97723ff

Browse files
jcsxkyhuqizhi
authored and
huqizhi
committed
apply reviews
1 parent 324e436 commit 97723ff

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,7 @@ Bug Fixes to C++ Support
699699
performed incorrectly when checking constraints. Fixes (#GH90349).
700700
- Clang now allows constrained member functions to be explicitly specialized for an implicit instantiation
701701
of a class template.
702+
- Fix a bug in access control checking due to dealyed checking of friend declaration. Fixes (#GH12361).
702703

703704
Bug Fixes to AST Handling
704705
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/Scope.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ void Scope::dumpImpl(raw_ostream &OS) const {
229229
{ClassInheritanceScope, "ClassInheritanceScope"},
230230
{CatchScope, "CatchScope"},
231231
{OpenACCComputeConstructScope, "OpenACCComputeConstructScope"},
232-
{TypeAliasScope, "TypeAliasScope"},
233232
{FriendScope, "FriendScope"},
234233
};
235234

clang/lib/Sema/SemaAccess.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,10 +1473,22 @@ static Sema::AccessResult CheckAccess(Sema &S, SourceLocation Loc,
14731473
// specifier, like this:
14741474
// A::private_type A::foo() { ... }
14751475
//
1476-
// Or we might be parsing something that will turn out to be a friend:
1477-
// void foo(A::private_type);
1478-
// void B::foo(A::private_type);
1476+
// friend declaration should not be delayed because it may lead to incorrect
1477+
// redeclaration chain, such as:
1478+
// class D {
1479+
// class E{
1480+
// class F{};
1481+
// friend void foo(D::E::F& q);
1482+
// };
1483+
// friend void foo(D::E::F& q);
1484+
// };
14791485
if (S.DelayedDiagnostics.shouldDelayDiagnostics()) {
1486+
// [class.friend]p9:
1487+
// A member nominated by a friend declaration shall be accessible in the
1488+
// class containing the friend declaration. The meaning of the friend
1489+
// declaration is the same whether the friend declaration appears in the
1490+
// private, protected, or public ([class.mem]) portion of the class
1491+
// member-specification.
14801492
Scope *TS = S.getCurScope();
14811493
bool IsFriendDeclaration = false;
14821494
while (TS && !IsFriendDeclaration) {

0 commit comments

Comments
 (0)