My earlier patch broke out of the loop over base members when we found a
match, but that caused trouble for dtors, which can have multiple for which
same_signature_p is true.  But as the function comment says, we know this
doesn't apply to [cd]tors, so skip them.

Tested x86_64-pc-linux-gnu, applying to trunk.

        PR c++/87729

gcc/cp/ChangeLog:

        * class.cc (warn_hidden): Ignore [cd]tors.

gcc/testsuite/ChangeLog:

        * g++.dg/warn/Woverloaded-virt3.C: New test.
---
 gcc/cp/class.cc                               | 3 +++
 gcc/testsuite/g++.dg/warn/Woverloaded-virt3.C | 7 +++++++
 2 files changed, 10 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/warn/Woverloaded-virt3.C

diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc
index 17683f421a7..eb69e7f985c 100644
--- a/gcc/cp/class.cc
+++ b/gcc/cp/class.cc
@@ -3020,6 +3020,9 @@ warn_hidden (tree t)
        tree binfo;
        unsigned j;
 
+       if (IDENTIFIER_CDTOR_P (name))
+         continue;
+
        /* Iterate through all of the base classes looking for possibly
           hidden functions.  */
        for (binfo = TYPE_BINFO (t), j = 0;
diff --git a/gcc/testsuite/g++.dg/warn/Woverloaded-virt3.C 
b/gcc/testsuite/g++.dg/warn/Woverloaded-virt3.C
new file mode 100644
index 00000000000..34214ba2557
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Woverloaded-virt3.C
@@ -0,0 +1,7 @@
+// PR c++/87729
+// { dg-additional-options -Woverloaded-virtual }
+
+struct S1 {};
+struct S2: S1 { virtual ~S2(); };
+struct S3 { virtual ~S3(); };
+struct S4: S2, S3 { virtual ~S4(); };

base-commit: c1b1c4e58bda152ae932b45396ab67b07dd8c3fe
-- 
2.31.1

Reply via email to