Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,7 @@ Bug Fixes to C++ Support
- Fixed a bug where bounds of partially expanded pack indexing expressions were checked too early. (#GH116105)
- Fixed an assertion failure caused by using ``consteval`` in condition in consumed analyses. (#GH117385)
- Fix a crash caused by incorrect argument position in merging deduced template arguments. (#GH113659)
- Fix a bug where private access specifier of overloaded function not respected. (#GH107629)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Sema/SemaOverload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16305,6 +16305,9 @@ ExprResult Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found,
}

if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(E)) {
if (Found.getAccess() == AS_none) {
CheckUnresolvedLookupAccess(ULE, Found);
}
// FIXME: avoid copy.
TemplateArgumentListInfo TemplateArgsBuffer, *TemplateArgs = nullptr;
if (ULE->hasExplicitTemplateArgs()) {
Expand Down
16 changes: 14 additions & 2 deletions clang/test/CXX/class.access/p4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ namespace test0 {
public:
void foo(Public&);
protected:
void foo(Protected&); // expected-note 2 {{declared protected here}}
void foo(Protected&); // expected-note 4 {{declared protected here}}
private:
void foo(Private&); // expected-note 2 {{declared private here}}
void foo(Private&); // expected-note 4 {{declared private here}}
};

class B : public A {};

void test(A *op) {
op->foo(PublicInst);
op->foo(ProtectedInst); // expected-error {{'foo' is a protected member}}
Expand All @@ -35,6 +37,16 @@ namespace test0 {
void (A::*b)(Protected&) = &A::foo; // expected-error {{'foo' is a protected member}}
void (A::*c)(Private&) = &A::foo; // expected-error {{'foo' is a private member}}
}

void test(B *op) {
op->foo(PublicInst);
op->foo(ProtectedInst); // expected-error {{'foo' is a protected member}}
op->foo(PrivateInst); // expected-error {{'foo' is a private member}}

void (B::*a)(Public&) = &B::foo;
void (B::*b)(Protected&) = &B::foo; // expected-error {{'foo' is a protected member}}
void (B::*c)(Private&) = &B::foo; // expected-error {{'foo' is a private member}}
}
}

// Member operators.
Expand Down