public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-1559] c++: -Woverloaded-virtual and dtors [PR87729]
Date: Thu,  7 Jul 2022 16:00:19 +0000 (GMT)	[thread overview]
Message-ID: <20220707160019.A537B3858D32@sourceware.org> (raw)

https://gcc.gnu.org/g:81bec060e31b6ef2feeb3046c6f13a207c6f698a

commit r13-1559-g81bec060e31b6ef2feeb3046c6f13a207c6f698a
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jul 7 10:12:04 2022 -0400

    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.

Diff:
---
 gcc/cp/class.cc                               | 3 +++
 gcc/testsuite/g++.dg/warn/Woverloaded-virt3.C | 7 +++++++
 2 files changed, 10 insertions(+)

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(); };


                 reply	other threads:[~2022-07-07 16:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220707160019.A537B3858D32@sourceware.org \
    --to=jason@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).