Skip to content

Commit 1a84a02

Browse files
test: Add test for using decls for overloads (#318)
1 parent e9aa5d2 commit 1a84a02

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

test/index/functions/methods.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,22 @@ void test_member_pointer() {
7575
M0 m{};
7676
(m.*p)();
7777
}
78+
79+
// Using-declarations making methods public:
80+
81+
namespace u {
82+
struct Z0 {
83+
protected:
84+
void f(int) {}
85+
void f(int, int) {}
86+
};
87+
88+
struct Z1: Z0 {
89+
using Z0::f;
90+
};
91+
92+
void use_made_public(Z1 z1) {
93+
z1.f(0);
94+
z1.f(0, 0);
95+
}
96+
}

test/index/functions/methods.snapshot.cc

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,41 @@
165165
// ^ reference local 1
166166
// ^ reference local 0
167167
}
168+
169+
// Using-declarations making methods public:
170+
171+
namespace u {
172+
// ^ definition [..] u/
173+
struct Z0 {
174+
// ^^ definition [..] u/Z0#
175+
protected:
176+
void f(int) {}
177+
// ^ definition [..] u/Z0#f(d4f767463ce0a6b3).
178+
void f(int, int) {}
179+
// ^ definition [..] u/Z0#f(3e454b8ccf442868).
180+
};
181+
182+
struct Z1: Z0 {
183+
// ^^ definition [..] u/Z1#
184+
// relation implementation [..] u/Z0#
185+
// ^^ reference [..] u/Z0#
186+
using Z0::f;
187+
// ^^ reference [..] u/Z0#
188+
// ^ reference [..] u/Z0#f(3e454b8ccf442868).
189+
// ^ reference [..] u/Z0#f(d4f767463ce0a6b3).
190+
// ^ definition [..] u/Z1#f(3e454b8ccf442868).
191+
// ^ definition [..] u/Z1#f(d4f767463ce0a6b3).
192+
};
193+
194+
void use_made_public(Z1 z1) {
195+
// ^^^^^^^^^^^^^^^ definition [..] u/use_made_public(eb27b0ef67ae3f66).
196+
// ^^ reference [..] u/Z1#
197+
// ^^ definition local 2
198+
z1.f(0);
199+
// ^^ reference local 2
200+
// ^ reference [..] u/Z0#f(d4f767463ce0a6b3).
201+
z1.f(0, 0);
202+
// ^^ reference local 2
203+
// ^ reference [..] u/Z0#f(3e454b8ccf442868).
204+
}
205+
}

0 commit comments

Comments
 (0)