]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/78010 - bogus -Wsuggest-override warning on final function.
authorMarek Polacek <polacek@redhat.com>
Fri, 10 May 2019 14:57:22 +0000 (14:57 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 10 May 2019 14:57:22 +0000 (14:57 +0000)
* class.c (check_for_override): Don't warn for final functions.

* g++.dg/warn/Wsuggest-override-2.C: New test.

From-SVN: r271066

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/g++.dg/warn/Wsuggest-override-2.C [new file with mode: 0644]

index a2dc643862fdee4d75a4b09812de0ab11e12e70f..93485ccfb55ed72691ac6d742b08768a98aa0ce4 100644 (file)
@@ -1,3 +1,8 @@
+2019-05-10  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/78010 - bogus -Wsuggest-override warning on final function.
+       * class.c (check_for_override): Don't warn for final functions.
+
 2019-05-06  Marek Polacek  <polacek@redhat.com>
 
        PR c++/90265 - ICE with generic lambda.
index 712169ce7e766ebf5e7a3e35a18704e50b9a2d0b..a47777cdd9ef4d03d1652fa6e8c72b9b595b323f 100644 (file)
@@ -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/g++.dg/warn/Wsuggest-override-2.C b/gcc/testsuite/g++.dg/warn/Wsuggest-override-2.C
new file mode 100644 (file)
index 0000000..4948902
--- /dev/null
@@ -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" }
+};