File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4502,10 +4502,20 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
45024502 if (auto cldec = ad.isClassDeclaration())
45034503 {
45044504 assert (cldec.cppDtorVtblIndex == - 1 ); // double-call check already by dd.type
4505- if (cldec.baseClass && cldec.baseClass.cppDtorVtblIndex != - 1 )
4505+ // Walk up the base chain: an intermediate class may have no explicit
4506+ // dtor (cppDtorVtblIndex == -1) yet still inherit a dtor vtbl slot.
4507+ // https://github.com/dlang/dmd/issues/22709
4508+ int inheritedDtorVtblIndex = - 1 ;
4509+ for (auto base = cldec.baseClass; base; base = base.baseClass)
4510+ if (base.cppDtorVtblIndex != - 1 )
4511+ {
4512+ inheritedDtorVtblIndex = base.cppDtorVtblIndex;
4513+ break ;
4514+ }
4515+ if (inheritedDtorVtblIndex != - 1 )
45064516 {
45074517 // override the base virtual
4508- cldec.cppDtorVtblIndex = cldec.baseClass.cppDtorVtblIndex ;
4518+ cldec.cppDtorVtblIndex = inheritedDtorVtblIndex ;
45094519 }
45104520 else if (! dd.isFinal())
45114521 {
Original file line number Diff line number Diff line change 1+ // https://github.com/dlang/dmd/issues/22709
2+ // extern(C++) destructor in base class should not be flagged as hidden
3+
4+ extern (C++ ):
5+ class A
6+ {
7+ ~this ();
8+ }
9+ class B : A
10+ {
11+ }
12+ class C : B
13+ {
14+ ~this ();
15+ }
You can’t perform that action at this time.
0 commit comments