@@ -16249,8 +16249,19 @@ tsubst_baselink (tree baselink, tree object_type,
fns = BASELINK_FUNCTIONS (baselink);
}
else
- /* We're going to overwrite pieces below, make a duplicate. */
- baselink = copy_node (baselink);
+ {
+ /* We're going to overwrite pieces below, make a duplicate. */
+ baselink = copy_node (baselink);
+
+ if (qualifying_scope != BINFO_TYPE (BASELINK_ACCESS_BINFO (baselink)))
+ {
+ /* The decl we found was from non-dependent scope, but we still need
+ to update the binfos for the instantiated qualifying_scope. */
+ BASELINK_ACCESS_BINFO (baselink) = TYPE_BINFO (qualifying_scope);
+ BASELINK_BINFO (baselink) = lookup_base (qualifying_scope, binfo_type,
+ ba_unique, nullptr, complain);
+ }
+ }
/* If lookup found a single function, mark it as used at this point.
(If lookup found multiple functions the one selected later by
new file mode 100644
@@ -0,0 +1,17 @@
+// PR c++/101078
+
+struct A {
+ static void f();
+};
+
+template<class>
+struct B : private A {
+ struct C {
+ void g() { f(); }
+ void g2() { B::f(); }
+ };
+};
+
+int main() {
+ B<int>::C().g();
+}