[PATCH] c++: Fix misuse of "override" in -Weffc++ warnings (PR 94698)

Jonathan Wakely jwakely@redhat.com
Wed Apr 22 19:43:26 GMT 2020


On 22/04/20 15:33 -0400, Jason Merrill wrote:
>On Wed, Apr 22, 2020 at 3:31 PM Jonathan Wakely <jwakely@redhat.com> wrote:
>
>> On 22/04/20 15:19 -0400, Jason Merrill wrote:
>> >On 4/22/20 2:37 AM, Jonathan Wakely wrote:
>> >>These warnings have nothing to do with virtual functions, so "override"
>> >>is inappropriate. The warnings are just talking about defining special
>> >>members, so let's say that.
>> >>
>> >>      PR translation/94698
>> >>      * class.c (check_field_decls): Change "override" to "define" in
>> >>      -Weffc++ diagnostics.
>> >>
>> >>Tested powerpc64le-linux, OK for master?
>> >
>> >It is overriding the default(ed) definition, but I agree that
>> >"override" now suggests virtual functions.
>> >
>> >"define" is also wrong, though; it should be "declare".  OK with that
>> >change.
>>
>> I did consider that, but decided that it has to be user-provided (i.e.
>> defined by the user) to avoid the problem, because a user-declared but
>> defaulted function would still not clean up pointer members.
>>
>
>True, but we don't warn in that case, and I think that's reasonable, as the
>user is being explicit about their intent.  Adding a defaulted declaration
>seems like a good way to silence the warning without changing ABI.

Ah good point.




More information about the Gcc-patches mailing list