Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -840,6 +840,7 @@ Bug Fixes to C++ Support
- Fixed a pack substitution bug in deducing class template partial specializations. (#GH53609)
- Fixed a crash when constant evaluating some explicit object member assignment operators. (#GH142835)
- Fixed an access checking bug when substituting into concepts (#GH115838)
- 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 @@ -16981,6 +16981,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
Loading