aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2022-07-07 10:12:04 -0400
committerJason Merrill <jason@redhat.com>2022-07-07 11:56:09 -0400
commit81bec060e31b6ef2feeb3046c6f13a207c6f698a (patch)
treeb4ba8d61bf92cb0c9d49d5d3409b37722a97e9df /gcc
parentd89fa97ff318b1f892e2629c5a249313872a01b1 (diff)
downloadgcc-81bec060e31b6ef2feeb3046c6f13a207c6f698a.zip
gcc-81bec060e31b6ef2feeb3046c6f13a207c6f698a.tar.gz
gcc-81bec060e31b6ef2feeb3046c6f13a207c6f698a.tar.bz2
c++: -Woverloaded-virtual and dtors [PR87729]
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. PR c++/87729 gcc/cp/ChangeLog: * class.cc (warn_hidden): Ignore [cd]tors. gcc/testsuite/ChangeLog: * g++.dg/warn/Woverloaded-virt3.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/class.cc3
-rw-r--r--gcc/testsuite/g++.dg/warn/Woverloaded-virt3.C7
2 files changed, 10 insertions, 0 deletions
diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc
index 17683f4..eb69e7f 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 0000000..34214ba
--- /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(); };