From: Marek Polacek Date: Fri, 10 May 2019 14:53:30 +0000 (+0000) Subject: PR c++/78010 - bogus -Wsuggest-override warning on final function. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d49b251f6d08fda3db606ac0e50cd28daac9eb33;p=gcc.git PR c++/78010 - bogus -Wsuggest-override warning on final function. * class.c (check_for_override): Don't warn for final functions. * g++.dg/warn/Wsuggest-override-2.C: New test. From-SVN: r271065 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a1c32a11059..a43001a1a11 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-05-10 Marek Polacek + + PR c++/78010 - bogus -Wsuggest-override warning on final function. + * class.c (check_for_override): Don't warn for final functions. + 2019-05-10 Jakub Jelinek PR pch/90326 diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 712169ce7e7..a47777cdd9e 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -2780,7 +2780,9 @@ check_for_override (tree decl, tree ctype) { DECL_VINDEX (decl) = decl; overrides_found = true; - if (warn_override && !DECL_OVERRIDE_P (decl) + if (warn_override + && !DECL_OVERRIDE_P (decl) + && !DECL_FINAL_P (decl) && !DECL_DESTRUCTOR_P (decl)) warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wsuggest_override, "%qD can be marked override", decl); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b42e68cf849..ac85d094f42 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-05-10 Marek Polacek + + PR c++/78010 - bogus -Wsuggest-override warning on final function. + * g++.dg/warn/Wsuggest-override-2.C: New test. + 2019-05-10 Jakub Jelinek PR tree-optimization/90385 diff --git a/gcc/testsuite/g++.dg/warn/Wsuggest-override-2.C b/gcc/testsuite/g++.dg/warn/Wsuggest-override-2.C new file mode 100644 index 00000000000..4948902e930 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wsuggest-override-2.C @@ -0,0 +1,9 @@ +// PR c++/78010 +// { dg-options "-std=c++11 -Wsuggest-override" } + +struct A { + virtual void f(); +}; +struct B : A { + void f() final; // { dg-bogus "can be marked override" } +};