Skip to content

Commit 694b7dd

Browse files
committed
fix
1 parent 017c75b commit 694b7dd

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,7 @@ Bug Fixes to C++ Support
763763
- Fixed a bug where bounds of partially expanded pack indexing expressions were checked too early. (#GH116105)
764764
- Fixed an assertion failure caused by using ``consteval`` in condition in consumed analyses. (#GH117385)
765765
- Fix a crash caused by incorrect argument position in merging deduced template arguments. (#GH113659)
766+
- Fix a bug where private access specifier of overloaded function not respected. (#GH107629)
766767

767768
Bug Fixes to AST Handling
768769
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaOverload.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16305,6 +16305,9 @@ ExprResult Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found,
1630516305
}
1630616306

1630716307
if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(E)) {
16308+
if (Found.getAccess() == AS_none) {
16309+
CheckUnresolvedLookupAccess(ULE, Found);
16310+
}
1630816311
// FIXME: avoid copy.
1630916312
TemplateArgumentListInfo TemplateArgsBuffer, *TemplateArgs = nullptr;
1631016313
if (ULE->hasExplicitTemplateArgs()) {

clang/test/CXX/class.access/p4.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ namespace test0 {
2121
public:
2222
void foo(Public&);
2323
protected:
24-
void foo(Protected&); // expected-note 2 {{declared protected here}}
24+
void foo(Protected&); // expected-note 4 {{declared protected here}}
2525
private:
26-
void foo(Private&); // expected-note 2 {{declared private here}}
26+
void foo(Private&); // expected-note 4 {{declared private here}}
2727
};
2828

29+
class B : public A {};
30+
2931
void test(A *op) {
3032
op->foo(PublicInst);
3133
op->foo(ProtectedInst); // expected-error {{'foo' is a protected member}}
@@ -35,6 +37,16 @@ namespace test0 {
3537
void (A::*b)(Protected&) = &A::foo; // expected-error {{'foo' is a protected member}}
3638
void (A::*c)(Private&) = &A::foo; // expected-error {{'foo' is a private member}}
3739
}
40+
41+
void test(B *op) {
42+
op->foo(PublicInst);
43+
op->foo(ProtectedInst); // expected-error {{'foo' is a protected member}}
44+
op->foo(PrivateInst); // expected-error {{'foo' is a private member}}
45+
46+
void (B::*a)(Public&) = &B::foo;
47+
void (B::*b)(Protected&) = &B::foo; // expected-error {{'foo' is a protected member}}
48+
void (B::*c)(Private&) = &B::foo; // expected-error {{'foo' is a private member}}
49+
}
3850
}
3951

4052
// Member operators.

0 commit comments

Comments
 (0)