public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Stephan Bergmann <sbergman@redhat.com>
To: Jason Merrill <jason@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [pushed] c++: Include -Woverloaded-virtual in -Wall [PR87729]
Date: Fri, 1 Jul 2022 22:30:44 +0200	[thread overview]
Message-ID: <90daa422-016f-4dc7-a422-3fb9ae5e90fd@redhat.com> (raw)
In-Reply-To: <20220624222604.335563-1-jason@redhat.com>

On 6/25/22 00:26, Jason Merrill via Gcc-patches wrote:
> This seems like a good warning to have in -Wall, as requested.  But as
> pointed out in PR20423, some users want a warning only when a derived
> function doesn't override any base function.  So let's put that lesser
> version in -Wall (and -Woverloaded-virtual=1) while leaving the semantics
> for the existing option the same.

This now causes

> $ cat test.cc
> struct S1 {};
> struct S2: S1 { virtual ~S2(); };
> struct S3 { virtual ~S3(); };
> struct S4: S2, S3 { virtual ~S4(); };

> $ g++ -Woverloaded-virtual -fsyntax-only test.cc
> test.cc:3:21: warning: ‘virtual S3::~S3()’ was hidden [-Woverloaded-virtual=]
>     3 | struct S3 { virtual ~S3(); };
>       |                     ^
> test.cc:4:29: note:   by ‘virtual S4::~S4()’
>     4 | struct S4: S2, S3 { virtual ~S4(); };
>       |                             ^
> test.cc:3:21: warning: ‘virtual S3::~S3()’ was hidden [-Woverloaded-virtual=]
>     3 | struct S3 { virtual ~S3(); };
>       |                     ^
> test.cc:4:29: note:   by ‘virtual S4::~S4()’
>     4 | struct S4: S2, S3 { virtual ~S4(); };
>       |                             ^
> test.cc:3:21: warning: ‘virtual S3::~S3()’ was hidden [-Woverloaded-virtual=]
>     3 | struct S3 { virtual ~S3(); };
>       |                     ^
> test.cc:4:29: note:   by ‘virtual S4::~S4()’
>     4 | struct S4: S2, S3 { virtual ~S4(); };
>       |                             ^


  reply	other threads:[~2022-07-01 20:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-24 22:26 Jason Merrill
2022-07-01 20:30 ` Stephan Bergmann [this message]
2022-07-05  8:18   ` Stephan Bergmann
2022-07-07 15:55 ` [pushed] c++: -Woverloaded-virtual and dtors [PR87729] Jason Merrill

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=90daa422-016f-4dc7-a422-3fb9ae5e90fd@redhat.com \
    --to=sbergman@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    /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).