[10/10] Add 'final' and 'override' in various places

Message ID 20220523192834.3785673-11-dmalcolm@redhat.com
State New
Headers
Series Add 'final' and 'override' where missing |

Commit Message

David Malcolm May 23, 2022, 7:28 p.m. UTC
  gcc/cp/ChangeLog:
	* cxx-pretty-print.h: Add "final" and "override" to various vfunc
	implementations, removing redundant "virtual" as appropriate.
	* module.cc: Likewise.

gcc/ChangeLog:
	* genmatch.cc: Add "final" and "override" to various vfunc
	implementations, removing redundant "virtual" as appropriate.
	* gensupport.cc: Likewise.
	* gimple-range-cache.h: Likewise.
	* ipa-icf-gimple.h: Likewise.
	* ipa-icf.h: Likewise.
	* read-md.h: Likewise.
	* read-rtl-function.cc: Likewise.
	* tree-ssa-loop-ch.cc: Likewise.
	* tree-ssa-sccvn.cc: Likewise.

gcc/lto/ChangeLog:
	* lto-dump.cc: Add "final" and "override" to various vfunc
	implementations, removing redundant "virtual" as appropriate.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
---
 gcc/cp/cxx-pretty-print.h | 38 +++++++++++++++++++-------------------
 gcc/cp/module.cc          |  4 ++--
 gcc/genmatch.cc           | 22 +++++++++++-----------
 gcc/gensupport.cc         |  2 +-
 gcc/gimple-range-cache.h  |  4 ++--
 gcc/ipa-icf-gimple.h      |  6 ++++--
 gcc/ipa-icf.h             | 36 ++++++++++++++++++++----------------
 gcc/lto/lto-dump.cc       |  8 ++++----
 gcc/read-md.h             |  2 +-
 gcc/read-rtl-function.cc  |  6 +++---
 gcc/tree-ssa-loop-ch.cc   |  4 ++--
 gcc/tree-ssa-sccvn.cc     |  4 ++--
 12 files changed, 71 insertions(+), 65 deletions(-)
  

Comments

David Malcolm June 13, 2022, 6:30 p.m. UTC | #1
Ping re this patch:
  https://gcc.gnu.org/pipermail/gcc-patches/2022-May/595443.html

OK for trunk?

Thanks
Dave

On Mon, 2022-05-23 at 15:28 -0400, David Malcolm wrote:
> gcc/cp/ChangeLog:
>         * cxx-pretty-print.h: Add "final" and "override" to various
> vfunc
>         implementations, removing redundant "virtual" as appropriate.
>         * module.cc: Likewise.
> 
> gcc/ChangeLog:
>         * genmatch.cc: Add "final" and "override" to various vfunc
>         implementations, removing redundant "virtual" as appropriate.
>         * gensupport.cc: Likewise.
>         * gimple-range-cache.h: Likewise.
>         * ipa-icf-gimple.h: Likewise.
>         * ipa-icf.h: Likewise.
>         * read-md.h: Likewise.
>         * read-rtl-function.cc: Likewise.
>         * tree-ssa-loop-ch.cc: Likewise.
>         * tree-ssa-sccvn.cc: Likewise.
> 
> gcc/lto/ChangeLog:
>         * lto-dump.cc: Add "final" and "override" to various vfunc
>         implementations, removing redundant "virtual" as appropriate.
> 
> Signed-off-by: David Malcolm <dmalcolm@redhat.com>
> ---
>  gcc/cp/cxx-pretty-print.h | 38 +++++++++++++++++++-------------------
>  gcc/cp/module.cc          |  4 ++--
>  gcc/genmatch.cc           | 22 +++++++++++-----------
>  gcc/gensupport.cc         |  2 +-
>  gcc/gimple-range-cache.h  |  4 ++--
>  gcc/ipa-icf-gimple.h      |  6 ++++--
>  gcc/ipa-icf.h             | 36 ++++++++++++++++++++----------------
>  gcc/lto/lto-dump.cc       |  8 ++++----
>  gcc/read-md.h             |  2 +-
>  gcc/read-rtl-function.cc  |  6 +++---
>  gcc/tree-ssa-loop-ch.cc   |  4 ++--
>  gcc/tree-ssa-sccvn.cc     |  4 ++--
>  12 files changed, 71 insertions(+), 65 deletions(-)
> 
> diff --git a/gcc/cp/cxx-pretty-print.h b/gcc/cp/cxx-pretty-print.h
> index 5080f70a8e4..593bd91d4f7 100644
> --- a/gcc/cp/cxx-pretty-print.h
> +++ b/gcc/cp/cxx-pretty-print.h
> @@ -36,25 +36,25 @@ public:
>  
>    pretty_printer *clone () const override;
>  
> -  void constant (tree);
> -  void id_expression (tree);
> -  void primary_expression (tree);
> -  void postfix_expression (tree);
> -  void unary_expression (tree);
> -  void multiplicative_expression (tree);
> -  void conditional_expression (tree);
> -  void assignment_expression (tree);
> -  void expression (tree);
> -  void type_id (tree);
> -  void statement (tree);
> -  void declaration (tree);
> -  void declaration_specifiers (tree);
> -  void simple_type_specifier (tree);
> -  void function_specifier (tree);
> -  void declarator (tree);
> -  void direct_declarator (tree);
> -  void abstract_declarator (tree);
> -  void direct_abstract_declarator (tree);
> +  void constant (tree) final override;
> +  void id_expression (tree) final override;
> +  void primary_expression (tree) final override;
> +  void postfix_expression (tree) final override;
> +  void unary_expression (tree) final override;
> +  void multiplicative_expression (tree) final override;
> +  void conditional_expression (tree) final override;
> +  void assignment_expression (tree) final override;
> +  void expression (tree) final override;
> +  void type_id (tree) final override;
> +  void statement (tree) final override;
> +  void declaration (tree) final override;
> +  void declaration_specifiers (tree) final override;
> +  void simple_type_specifier (tree) final override;
> +  void function_specifier (tree) final override;
> +  void declarator (tree) final override;
> +  void direct_declarator (tree) final override;
> +  void abstract_declarator (tree) final override;
> +  void direct_abstract_declarator (tree) final override;
>  
>    /* This is the enclosing scope of the entity being pretty-printed. 
> */
>    tree enclosing_scope;
> diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
> index d1dc73724d1..e93151c98c2 100644
> --- a/gcc/cp/module.cc
> +++ b/gcc/cp/module.cc
> @@ -1483,10 +1483,10 @@ private:
>  
>  protected:
>    using allocator::grow;
> -  virtual char *grow (char *, unsigned needed);
> +  char *grow (char *, unsigned needed) final override;
>  #if MAPPED_WRITING
>    using allocator::shrink;
> -  virtual void shrink (char *);
> +  void shrink (char *) final override;
>  #endif
>  
>  public:
> diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc
> index 2b84b849330..a0b22c50ae3 100644
> --- a/gcc/genmatch.cc
> +++ b/gcc/genmatch.cc
> @@ -723,9 +723,9 @@ public:
>    bool force_leaf;
>    /* If non-zero, the group for optional handling.  */
>    unsigned char opt_grp;
> -  virtual void gen_transform (FILE *f, int, const char *, bool, int,
> -                             const char *, capture_info *,
> -                             dt_operand ** = 0, int = 0);
> +  void gen_transform (FILE *f, int, const char *, bool, int,
> +                     const char *, capture_info *,
> +                     dt_operand ** = 0, int = 0) override;
>  };
>  
>  /* An operator that is represented by native C code.  This is always
> @@ -757,9 +757,9 @@ public:
>    unsigned nr_stmts;
>    /* The identifier replacement vector.  */
>    vec<id_tab> ids;
> -  virtual void gen_transform (FILE *f, int, const char *, bool, int,
> -                             const char *, capture_info *,
> -                             dt_operand ** = 0, int = 0);
> +  void gen_transform (FILE *f, int, const char *, bool, int,
> +                     const char *, capture_info *,
> +                     dt_operand ** = 0, int = 0) final override;
>  };
>  
>  /* A wrapper around another operand that captures its value.  */
> @@ -778,9 +778,9 @@ public:
>    bool value_match;
>    /* The captured value.  */
>    operand *what;
> -  virtual void gen_transform (FILE *f, int, const char *, bool, int,
> -                             const char *, capture_info *,
> -                             dt_operand ** = 0, int = 0);
> +  void gen_transform (FILE *f, int, const char *, bool, int,
> +                     const char *, capture_info *,
> +                     dt_operand ** = 0, int = 0) final override;
>  };
>  
>  /* if expression.  */
> @@ -1655,7 +1655,7 @@ public:
>        : dt_node (type, parent_), op (op_), match_dop (match_dop_),
>        pos (pos_), value_match (false), for_id (current_id) {}
>  
> -  void gen (FILE *, int, bool, int);
> +  void gen (FILE *, int, bool, int) final override;
>    unsigned gen_predicate (FILE *, int, const char *, bool);
>    unsigned gen_match_op (FILE *, int, const char *, bool);
>  
> @@ -1681,7 +1681,7 @@ public:
>           indexes (indexes_), info (NULL)  {}
>  
>    void gen_1 (FILE *, int, bool, operand *);
> -  void gen (FILE *f, int, bool, int);
> +  void gen (FILE *f, int, bool, int) final override;
>  };
>  
>  template<>
> diff --git a/gcc/gensupport.cc b/gcc/gensupport.cc
> index 42680499d86..8fcacf8f9d2 100644
> --- a/gcc/gensupport.cc
> +++ b/gcc/gensupport.cc
> @@ -2310,7 +2310,7 @@ class gen_reader : public rtx_reader
>  {
>   public:
>    gen_reader () : rtx_reader (false) {}
> -  void handle_unknown_directive (file_location, const char *);
> +  void handle_unknown_directive (file_location, const char *) final
> override;
>  };
>  
>  void
> diff --git a/gcc/gimple-range-cache.h b/gcc/gimple-range-cache.h
> index 555fe32513f..d768f418f0d 100644
> --- a/gcc/gimple-range-cache.h
> +++ b/gcc/gimple-range-cache.h
> @@ -77,8 +77,8 @@ public:
>    ranger_cache (int not_executable_flag, bool use_imm_uses);
>    ~ranger_cache ();
>  
> -  virtual bool range_of_expr (irange &r, tree name, gimple *stmt);
> -  virtual bool range_on_edge (irange &r, edge e, tree expr);
> +  bool range_of_expr (irange &r, tree name, gimple *stmt) final
> override;
> +  bool range_on_edge (irange &r, edge e, tree expr) final override;
>    bool block_range (irange &r, basic_block bb, tree name, bool calc =
> true);
>  
>    bool get_global_range (irange &r, tree name) const;
> diff --git a/gcc/ipa-icf-gimple.h b/gcc/ipa-icf-gimple.h
> index 1545e4a5905..8f498b31eef 100644
> --- a/gcc/ipa-icf-gimple.h
> +++ b/gcc/ipa-icf-gimple.h
> @@ -282,11 +282,13 @@ private:
>  public:
>    /* Return true if two operands are equal.  The flags fields can be
> used
>       to specify OEP flags described above.  */
> -  virtual bool operand_equal_p (const_tree, const_tree, unsigned int
> flags);
> +  bool operand_equal_p (const_tree, const_tree, unsigned int flags)
> +    final override;
>  
>    /* Generate a hash value for an expression.  This can be used
> iteratively
>       by passing a previous result as the HSTATE argument.  */
> -  virtual void hash_operand (const_tree, inchash::hash &, unsigned
> flags);
> +  void hash_operand (const_tree, inchash::hash &, unsigned flags)
> +    final override;
>    void hash_operand (const_tree, inchash::hash &, unsigned flags,
>                      operand_access_type access);
>  };
> diff --git a/gcc/ipa-icf.h b/gcc/ipa-icf.h
> index dbae2cca02b..bb550923ad4 100644
> --- a/gcc/ipa-icf.h
> +++ b/gcc/ipa-icf.h
> @@ -317,16 +317,18 @@ public:
>  
>    ~sem_function ();
>  
> -  virtual void init (ipa_icf_gimple::func_checker *);
> -  virtual bool equals_wpa (sem_item *item,
> -                          hash_map <symtab_node *, sem_item *>
> &ignored_nodes);
> -  virtual hashval_t get_hash (void);
> -  virtual bool equals (sem_item *item,
> -                      hash_map <symtab_node *, sem_item *>
> &ignored_nodes);
> -  virtual bool merge (sem_item *alias_item);
> +  void init (ipa_icf_gimple::func_checker *) final override;
> +  bool equals_wpa (sem_item *item,
> +                  hash_map <symtab_node *, sem_item *> &ignored_nodes)
> +    final override;
> +  hashval_t get_hash (void) final override;
> +  bool equals (sem_item *item,
> +              hash_map <symtab_node *, sem_item *> &ignored_nodes)
> +    final override;
> +  bool merge (sem_item *alias_item) final override;
>  
>    /* Dump symbol to FILE.  */
> -  virtual void dump_to_file (FILE *file)
> +  void dump_to_file (FILE *file) final override
>    {
>      gcc_assert (file);
>      dump_function_to_file (decl, file, TDF_DETAILS);
> @@ -426,17 +428,19 @@ public:
>    sem_variable (varpool_node *_node, bitmap_obstack *stack);
>  
>    /* Semantic variable initialization function.  */
> -  virtual void init (ipa_icf_gimple::func_checker *);
> +  void init (ipa_icf_gimple::func_checker *) final override;
>  
> -  virtual hashval_t get_hash (void);
> -  virtual bool merge (sem_item *alias_item);
> -  virtual void dump_to_file (FILE *file);
> -  virtual bool equals (sem_item *item,
> -                      hash_map <symtab_node *, sem_item *>
> &ignored_nodes);
> +  hashval_t get_hash (void) final override;
> +  bool merge (sem_item *alias_item) final override;
> +  void dump_to_file (FILE *file) final override;
> +  bool equals (sem_item *item,
> +              hash_map <symtab_node *, sem_item *> &ignored_nodes)
> +    final override;
>  
>    /* Fast equality variable based on knowledge known in WPA.  */
> -  virtual bool equals_wpa (sem_item *item,
> -                          hash_map <symtab_node *, sem_item *>
> &ignored_nodes);
> +  bool equals_wpa (sem_item *item,
> +                  hash_map <symtab_node *, sem_item *> &ignored_nodes)
> +     final override;
>  
>    /* Returns varpool_node.  */
>    inline varpool_node *get_node (void)
> diff --git a/gcc/lto/lto-dump.cc b/gcc/lto/lto-dump.cc
> index 1fb3fb86fb5..f88486b5143 100644
> --- a/gcc/lto/lto-dump.cc
> +++ b/gcc/lto/lto-dump.cc
> @@ -80,7 +80,7 @@ public:
>    virtual ~variable_entry ()
>    {}
>  
> -  virtual size_t get_size () const
> +  size_t get_size () const final override
>    {
>      varpool_node *vnode = dyn_cast<varpool_node *> (node);
>      if (DECL_SIZE (vnode->decl) && tree_fits_shwi_p (DECL_SIZE (vnode-
> >decl)))
> @@ -88,7 +88,7 @@ public:
>      return 0;
>    }
>  
> -  virtual void dump ()
> +  void dump () final override
>    {
>      symbol_entry :: dump ();
>      varpool_node *vnode = dyn_cast<varpool_node *> (node);
> @@ -111,13 +111,13 @@ public:
>    virtual ~function_entry ()
>    {}
>  
> -  virtual void dump ()
> +  void dump () final override
>    {
>      symbol_entry :: dump ();
>      printf ("\n");
>    }
>  
> -  virtual size_t get_size () const
> +  size_t get_size () const final override
>    {
>      cgraph_node *cnode = dyn_cast<cgraph_node *> (node);
>      gcc_assert (cnode);
> diff --git a/gcc/read-md.h b/gcc/read-md.h
> index 34a64fa93a2..7d8cd4a8336 100644
> --- a/gcc/read-md.h
> +++ b/gcc/read-md.h
> @@ -330,7 +330,7 @@ class noop_reader : public md_reader
>    noop_reader () : md_reader (false) {}
>  
>    /* A dummy implementation which skips unknown directives.  */
> -  void handle_unknown_directive (file_location, const char *);
> +  void handle_unknown_directive (file_location, const char *)
> override;
>  };
>  
>  /* An md_reader subclass that actually handles full hierarchical
> diff --git a/gcc/read-rtl-function.cc b/gcc/read-rtl-function.cc
> index eacbe4c1200..3bcff1540e7 100644
> --- a/gcc/read-rtl-function.cc
> +++ b/gcc/read-rtl-function.cc
> @@ -188,7 +188,7 @@ class fixup_insn_uid : public operand_fixup
>        m_insn_uid (insn_uid)
>    {}
>  
> -  void apply (function_reader *reader) const;
> +  void apply (function_reader *reader) const final override;
>  
>   private:
>    int m_insn_uid;
> @@ -206,7 +206,7 @@ class fixup_note_insn_basic_block : public
> operand_fixup
>        m_bb_idx (bb_idx)
>    {}
>  
> -  void apply (function_reader *reader) const;
> +  void apply (function_reader *reader) const final override;
>  
>   private:
>    int m_bb_idx;
> @@ -225,7 +225,7 @@ class fixup_expr : public fixup
>  
>    ~fixup_expr () { free (m_desc); }
>  
> -  void apply (function_reader *reader) const;
> +  void apply (function_reader *reader) const final override;
>  
>   private:
>    char *m_desc;
> diff --git a/gcc/tree-ssa-loop-ch.cc b/gcc/tree-ssa-loop-ch.cc
> index 9ab63d1fa0c..d1391940c2b 100644
> --- a/gcc/tree-ssa-loop-ch.cc
> +++ b/gcc/tree-ssa-loop-ch.cc
> @@ -320,7 +320,7 @@ public:
>  
>  protected:
>    /* ch_base method: */
> -  virtual bool process_loop_p (class loop *loop);
> +  bool process_loop_p (class loop *loop) final override;
>  }; // class pass_ch
>  
>  const pass_data pass_data_ch_vect =
> @@ -358,7 +358,7 @@ public:
>  
>  protected:
>    /* ch_base method: */
> -  virtual bool process_loop_p (class loop *loop);
> +  bool process_loop_p (class loop *loop) final override;
>  }; // class pass_ch_vect
>  
>  /* For all loops, copy the condition at the end of the loop body in
> front
> diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
> index 7407591e98c..b2f35a5fb55 100644
> --- a/gcc/tree-ssa-sccvn.cc
> +++ b/gcc/tree-ssa-sccvn.cc
> @@ -2534,9 +2534,9 @@ public:
>      : eliminate_dom_walker (CDI_DOMINATORS, NULL), entry (entry_),
>        m_avail_freelist (NULL) {}
>  
> -  virtual tree eliminate_avail (basic_block, tree op);
> +  tree eliminate_avail (basic_block, tree op) final override;
>  
> -  virtual void eliminate_push_avail (basic_block, tree);
> +  void eliminate_push_avail (basic_block, tree) final override;
>  
>    basic_block entry;
>    /* Freelist of avail entries which are allocated from the vn_ssa_aux
  
David Malcolm June 24, 2022, 6:20 p.m. UTC | #2
On Mon, 2022-06-13 at 14:30 -0400, David Malcolm wrote:
> Ping re this patch:
>   https://gcc.gnu.org/pipermail/gcc-patches/2022-May/595443.html
> 
> OK for trunk?
> 
> Thanks
> Dave
> 
> On Mon, 2022-05-23 at 15:28 -0400, David Malcolm wrote:
> > gcc/cp/ChangeLog:
> >         * cxx-pretty-print.h: Add "final" and "override" to various
> > vfunc
> >         implementations, removing redundant "virtual" as
> > appropriate.
> >         * module.cc: Likewise.
> > 
> > gcc/ChangeLog:
> >         * genmatch.cc: Add "final" and "override" to various vfunc
> >         implementations, removing redundant "virtual" as
> > appropriate.
> >         * gensupport.cc: Likewise.
> >         * gimple-range-cache.h: Likewise.
> >         * ipa-icf-gimple.h: Likewise.
> >         * ipa-icf.h: Likewise.
> >         * read-md.h: Likewise.
> >         * read-rtl-function.cc: Likewise.
> >         * tree-ssa-loop-ch.cc: Likewise.
> >         * tree-ssa-sccvn.cc: Likewise.
> > 
> > gcc/lto/ChangeLog:
> >         * lto-dump.cc: Add "final" and "override" to various vfunc
> >         implementations, removing redundant "virtual" as
> > appropriate.
> > 
> > Signed-off-by: David Malcolm <dmalcolm@redhat.com>
> > ---
> >  gcc/cp/cxx-pretty-print.h | 38 +++++++++++++++++++----------------
> > ---
> >  gcc/cp/module.cc          |  4 ++--
> >  gcc/genmatch.cc           | 22 +++++++++++-----------
> >  gcc/gensupport.cc         |  2 +-
> >  gcc/gimple-range-cache.h  |  4 ++--
> >  gcc/ipa-icf-gimple.h      |  6 ++++--
> >  gcc/ipa-icf.h             | 36 ++++++++++++++++++++---------------
> > -
> >  gcc/lto/lto-dump.cc       |  8 ++++----
> >  gcc/read-md.h             |  2 +-
> >  gcc/read-rtl-function.cc  |  6 +++---
> >  gcc/tree-ssa-loop-ch.cc   |  4 ++--
> >  gcc/tree-ssa-sccvn.cc     |  4 ++--
> >  12 files changed, 71 insertions(+), 65 deletions(-)
> > 
> > diff --git a/gcc/cp/cxx-pretty-print.h b/gcc/cp/cxx-pretty-print.h
> > index 5080f70a8e4..593bd91d4f7 100644
> > --- a/gcc/cp/cxx-pretty-print.h
> > +++ b/gcc/cp/cxx-pretty-print.h
> > @@ -36,25 +36,25 @@ public:
> >  
> >    pretty_printer *clone () const override;
> >  
> > -  void constant (tree);
> > -  void id_expression (tree);
> > -  void primary_expression (tree);
> > -  void postfix_expression (tree);
> > -  void unary_expression (tree);
> > -  void multiplicative_expression (tree);
> > -  void conditional_expression (tree);
> > -  void assignment_expression (tree);
> > -  void expression (tree);
> > -  void type_id (tree);
> > -  void statement (tree);
> > -  void declaration (tree);
> > -  void declaration_specifiers (tree);
> > -  void simple_type_specifier (tree);
> > -  void function_specifier (tree);
> > -  void declarator (tree);
> > -  void direct_declarator (tree);
> > -  void abstract_declarator (tree);
> > -  void direct_abstract_declarator (tree);
> > +  void constant (tree) final override;
> > +  void id_expression (tree) final override;
> > +  void primary_expression (tree) final override;
> > +  void postfix_expression (tree) final override;
> > +  void unary_expression (tree) final override;
> > +  void multiplicative_expression (tree) final override;
> > +  void conditional_expression (tree) final override;
> > +  void assignment_expression (tree) final override;
> > +  void expression (tree) final override;
> > +  void type_id (tree) final override;
> > +  void statement (tree) final override;
> > +  void declaration (tree) final override;
> > +  void declaration_specifiers (tree) final override;
> > +  void simple_type_specifier (tree) final override;
> > +  void function_specifier (tree) final override;
> > +  void declarator (tree) final override;
> > +  void direct_declarator (tree) final override;
> > +  void abstract_declarator (tree) final override;
> > +  void direct_abstract_declarator (tree) final override;
> >  
> >    /* This is the enclosing scope of the entity being pretty-
> > printed. 
> > */
> >    tree enclosing_scope;
> > diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
> > index d1dc73724d1..e93151c98c2 100644
> > --- a/gcc/cp/module.cc
> > +++ b/gcc/cp/module.cc
> > @@ -1483,10 +1483,10 @@ private:
> >  
> >  protected:
> >    using allocator::grow;
> > -  virtual char *grow (char *, unsigned needed);
> > +  char *grow (char *, unsigned needed) final override;
> >  #if MAPPED_WRITING
> >    using allocator::shrink;
> > -  virtual void shrink (char *);
> > +  void shrink (char *) final override;
> >  #endif
> >  
> >  public:
> > diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc
> > index 2b84b849330..a0b22c50ae3 100644
> > --- a/gcc/genmatch.cc
> > +++ b/gcc/genmatch.cc
> > @@ -723,9 +723,9 @@ public:
> >    bool force_leaf;
> >    /* If non-zero, the group for optional handling.  */
> >    unsigned char opt_grp;
> > -  virtual void gen_transform (FILE *f, int, const char *, bool,
> > int,
> > -                             const char *, capture_info *,
> > -                             dt_operand ** = 0, int = 0);
> > +  void gen_transform (FILE *f, int, const char *, bool, int,
> > +                     const char *, capture_info *,
> > +                     dt_operand ** = 0, int = 0) override;
> >  };
> >  
> >  /* An operator that is represented by native C code.  This is
> > always
> > @@ -757,9 +757,9 @@ public:
> >    unsigned nr_stmts;
> >    /* The identifier replacement vector.  */
> >    vec<id_tab> ids;
> > -  virtual void gen_transform (FILE *f, int, const char *, bool,
> > int,
> > -                             const char *, capture_info *,
> > -                             dt_operand ** = 0, int = 0);
> > +  void gen_transform (FILE *f, int, const char *, bool, int,
> > +                     const char *, capture_info *,
> > +                     dt_operand ** = 0, int = 0) final override;
> >  };
> >  
> >  /* A wrapper around another operand that captures its value.  */
> > @@ -778,9 +778,9 @@ public:
> >    bool value_match;
> >    /* The captured value.  */
> >    operand *what;
> > -  virtual void gen_transform (FILE *f, int, const char *, bool,
> > int,
> > -                             const char *, capture_info *,
> > -                             dt_operand ** = 0, int = 0);
> > +  void gen_transform (FILE *f, int, const char *, bool, int,
> > +                     const char *, capture_info *,
> > +                     dt_operand ** = 0, int = 0) final override;
> >  };
> >  
> >  /* if expression.  */
> > @@ -1655,7 +1655,7 @@ public:
> >        : dt_node (type, parent_), op (op_), match_dop (match_dop_),
> >        pos (pos_), value_match (false), for_id (current_id) {}
> >  
> > -  void gen (FILE *, int, bool, int);
> > +  void gen (FILE *, int, bool, int) final override;
> >    unsigned gen_predicate (FILE *, int, const char *, bool);
> >    unsigned gen_match_op (FILE *, int, const char *, bool);
> >  
> > @@ -1681,7 +1681,7 @@ public:
> >           indexes (indexes_), info (NULL)  {}
> >  
> >    void gen_1 (FILE *, int, bool, operand *);
> > -  void gen (FILE *f, int, bool, int);
> > +  void gen (FILE *f, int, bool, int) final override;
> >  };
> >  
> >  template<>
> > diff --git a/gcc/gensupport.cc b/gcc/gensupport.cc
> > index 42680499d86..8fcacf8f9d2 100644
> > --- a/gcc/gensupport.cc
> > +++ b/gcc/gensupport.cc
> > @@ -2310,7 +2310,7 @@ class gen_reader : public rtx_reader
> >  {
> >   public:
> >    gen_reader () : rtx_reader (false) {}
> > -  void handle_unknown_directive (file_location, const char *);
> > +  void handle_unknown_directive (file_location, const char *)
> > final
> > override;
> >  };
> >  
> >  void
> > diff --git a/gcc/gimple-range-cache.h b/gcc/gimple-range-cache.h
> > index 555fe32513f..d768f418f0d 100644
> > --- a/gcc/gimple-range-cache.h
> > +++ b/gcc/gimple-range-cache.h
> > @@ -77,8 +77,8 @@ public:
> >    ranger_cache (int not_executable_flag, bool use_imm_uses);
> >    ~ranger_cache ();
> >  
> > -  virtual bool range_of_expr (irange &r, tree name, gimple *stmt);
> > -  virtual bool range_on_edge (irange &r, edge e, tree expr);
> > +  bool range_of_expr (irange &r, tree name, gimple *stmt) final
> > override;
> > +  bool range_on_edge (irange &r, edge e, tree expr) final
> > override;
> >    bool block_range (irange &r, basic_block bb, tree name, bool
> > calc =
> > true);
> >  
> >    bool get_global_range (irange &r, tree name) const;
> > diff --git a/gcc/ipa-icf-gimple.h b/gcc/ipa-icf-gimple.h
> > index 1545e4a5905..8f498b31eef 100644
> > --- a/gcc/ipa-icf-gimple.h
> > +++ b/gcc/ipa-icf-gimple.h
> > @@ -282,11 +282,13 @@ private:
> >  public:
> >    /* Return true if two operands are equal.  The flags fields can
> > be
> > used
> >       to specify OEP flags described above.  */
> > -  virtual bool operand_equal_p (const_tree, const_tree, unsigned
> > int
> > flags);
> > +  bool operand_equal_p (const_tree, const_tree, unsigned int
> > flags)
> > +    final override;
> >  
> >    /* Generate a hash value for an expression.  This can be used
> > iteratively
> >       by passing a previous result as the HSTATE argument.  */
> > -  virtual void hash_operand (const_tree, inchash::hash &, unsigned
> > flags);
> > +  void hash_operand (const_tree, inchash::hash &, unsigned flags)
> > +    final override;
> >    void hash_operand (const_tree, inchash::hash &, unsigned flags,
> >                      operand_access_type access);
> >  };
> > diff --git a/gcc/ipa-icf.h b/gcc/ipa-icf.h
> > index dbae2cca02b..bb550923ad4 100644
> > --- a/gcc/ipa-icf.h
> > +++ b/gcc/ipa-icf.h
> > @@ -317,16 +317,18 @@ public:
> >  
> >    ~sem_function ();
> >  
> > -  virtual void init (ipa_icf_gimple::func_checker *);
> > -  virtual bool equals_wpa (sem_item *item,
> > -                          hash_map <symtab_node *, sem_item *>
> > &ignored_nodes);
> > -  virtual hashval_t get_hash (void);
> > -  virtual bool equals (sem_item *item,
> > -                      hash_map <symtab_node *, sem_item *>
> > &ignored_nodes);
> > -  virtual bool merge (sem_item *alias_item);
> > +  void init (ipa_icf_gimple::func_checker *) final override;
> > +  bool equals_wpa (sem_item *item,
> > +                  hash_map <symtab_node *, sem_item *>
> > &ignored_nodes)
> > +    final override;
> > +  hashval_t get_hash (void) final override;
> > +  bool equals (sem_item *item,
> > +              hash_map <symtab_node *, sem_item *> &ignored_nodes)
> > +    final override;
> > +  bool merge (sem_item *alias_item) final override;
> >  
> >    /* Dump symbol to FILE.  */
> > -  virtual void dump_to_file (FILE *file)
> > +  void dump_to_file (FILE *file) final override
> >    {
> >      gcc_assert (file);
> >      dump_function_to_file (decl, file, TDF_DETAILS);
> > @@ -426,17 +428,19 @@ public:
> >    sem_variable (varpool_node *_node, bitmap_obstack *stack);
> >  
> >    /* Semantic variable initialization function.  */
> > -  virtual void init (ipa_icf_gimple::func_checker *);
> > +  void init (ipa_icf_gimple::func_checker *) final override;
> >  
> > -  virtual hashval_t get_hash (void);
> > -  virtual bool merge (sem_item *alias_item);
> > -  virtual void dump_to_file (FILE *file);
> > -  virtual bool equals (sem_item *item,
> > -                      hash_map <symtab_node *, sem_item *>
> > &ignored_nodes);
> > +  hashval_t get_hash (void) final override;
> > +  bool merge (sem_item *alias_item) final override;
> > +  void dump_to_file (FILE *file) final override;
> > +  bool equals (sem_item *item,
> > +              hash_map <symtab_node *, sem_item *> &ignored_nodes)
> > +    final override;
> >  
> >    /* Fast equality variable based on knowledge known in WPA.  */
> > -  virtual bool equals_wpa (sem_item *item,
> > -                          hash_map <symtab_node *, sem_item *>
> > &ignored_nodes);
> > +  bool equals_wpa (sem_item *item,
> > +                  hash_map <symtab_node *, sem_item *>
> > &ignored_nodes)
> > +     final override;
> >  
> >    /* Returns varpool_node.  */
> >    inline varpool_node *get_node (void)
> > diff --git a/gcc/lto/lto-dump.cc b/gcc/lto/lto-dump.cc
> > index 1fb3fb86fb5..f88486b5143 100644
> > --- a/gcc/lto/lto-dump.cc
> > +++ b/gcc/lto/lto-dump.cc
> > @@ -80,7 +80,7 @@ public:
> >    virtual ~variable_entry ()
> >    {}
> >  
> > -  virtual size_t get_size () const
> > +  size_t get_size () const final override
> >    {
> >      varpool_node *vnode = dyn_cast<varpool_node *> (node);
> >      if (DECL_SIZE (vnode->decl) && tree_fits_shwi_p (DECL_SIZE
> > (vnode-
> > > decl)))
> > @@ -88,7 +88,7 @@ public:
> >      return 0;
> >    }
> >  
> > -  virtual void dump ()
> > +  void dump () final override
> >    {
> >      symbol_entry :: dump ();
> >      varpool_node *vnode = dyn_cast<varpool_node *> (node);
> > @@ -111,13 +111,13 @@ public:
> >    virtual ~function_entry ()
> >    {}
> >  
> > -  virtual void dump ()
> > +  void dump () final override
> >    {
> >      symbol_entry :: dump ();
> >      printf ("\n");
> >    }
> >  
> > -  virtual size_t get_size () const
> > +  size_t get_size () const final override
> >    {
> >      cgraph_node *cnode = dyn_cast<cgraph_node *> (node);
> >      gcc_assert (cnode);
> > diff --git a/gcc/read-md.h b/gcc/read-md.h
> > index 34a64fa93a2..7d8cd4a8336 100644
> > --- a/gcc/read-md.h
> > +++ b/gcc/read-md.h
> > @@ -330,7 +330,7 @@ class noop_reader : public md_reader
> >    noop_reader () : md_reader (false) {}
> >  
> >    /* A dummy implementation which skips unknown directives.  */
> > -  void handle_unknown_directive (file_location, const char *);
> > +  void handle_unknown_directive (file_location, const char *)
> > override;
> >  };
> >  
> >  /* An md_reader subclass that actually handles full hierarchical
> > diff --git a/gcc/read-rtl-function.cc b/gcc/read-rtl-function.cc
> > index eacbe4c1200..3bcff1540e7 100644
> > --- a/gcc/read-rtl-function.cc
> > +++ b/gcc/read-rtl-function.cc
> > @@ -188,7 +188,7 @@ class fixup_insn_uid : public operand_fixup
> >        m_insn_uid (insn_uid)
> >    {}
> >  
> > -  void apply (function_reader *reader) const;
> > +  void apply (function_reader *reader) const final override;
> >  
> >   private:
> >    int m_insn_uid;
> > @@ -206,7 +206,7 @@ class fixup_note_insn_basic_block : public
> > operand_fixup
> >        m_bb_idx (bb_idx)
> >    {}
> >  
> > -  void apply (function_reader *reader) const;
> > +  void apply (function_reader *reader) const final override;
> >  
> >   private:
> >    int m_bb_idx;
> > @@ -225,7 +225,7 @@ class fixup_expr : public fixup
> >  
> >    ~fixup_expr () { free (m_desc); }
> >  
> > -  void apply (function_reader *reader) const;
> > +  void apply (function_reader *reader) const final override;
> >  
> >   private:
> >    char *m_desc;
> > diff --git a/gcc/tree-ssa-loop-ch.cc b/gcc/tree-ssa-loop-ch.cc
> > index 9ab63d1fa0c..d1391940c2b 100644
> > --- a/gcc/tree-ssa-loop-ch.cc
> > +++ b/gcc/tree-ssa-loop-ch.cc
> > @@ -320,7 +320,7 @@ public:
> >  
> >  protected:
> >    /* ch_base method: */
> > -  virtual bool process_loop_p (class loop *loop);
> > +  bool process_loop_p (class loop *loop) final override;
> >  }; // class pass_ch
> >  
> >  const pass_data pass_data_ch_vect =
> > @@ -358,7 +358,7 @@ public:
> >  
> >  protected:
> >    /* ch_base method: */
> > -  virtual bool process_loop_p (class loop *loop);
> > +  bool process_loop_p (class loop *loop) final override;
> >  }; // class pass_ch_vect
> >  
> >  /* For all loops, copy the condition at the end of the loop body
> > in
> > front
> > diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
> > index 7407591e98c..b2f35a5fb55 100644
> > --- a/gcc/tree-ssa-sccvn.cc
> > +++ b/gcc/tree-ssa-sccvn.cc
> > @@ -2534,9 +2534,9 @@ public:
> >      : eliminate_dom_walker (CDI_DOMINATORS, NULL), entry (entry_),
> >        m_avail_freelist (NULL) {}
> >  
> > -  virtual tree eliminate_avail (basic_block, tree op);
> > +  tree eliminate_avail (basic_block, tree op) final override;
> >  
> > -  virtual void eliminate_push_avail (basic_block, tree);
> > +  void eliminate_push_avail (basic_block, tree) final override;
> >  
> >    basic_block entry;
> >    /* Freelist of avail entries which are allocated from the
> > vn_ssa_aux
>
  

Patch

diff --git a/gcc/cp/cxx-pretty-print.h b/gcc/cp/cxx-pretty-print.h
index 5080f70a8e4..593bd91d4f7 100644
--- a/gcc/cp/cxx-pretty-print.h
+++ b/gcc/cp/cxx-pretty-print.h
@@ -36,25 +36,25 @@  public:
 
   pretty_printer *clone () const override;
 
-  void constant (tree);
-  void id_expression (tree);
-  void primary_expression (tree);
-  void postfix_expression (tree);
-  void unary_expression (tree);
-  void multiplicative_expression (tree);
-  void conditional_expression (tree);
-  void assignment_expression (tree);
-  void expression (tree);
-  void type_id (tree);
-  void statement (tree);
-  void declaration (tree);
-  void declaration_specifiers (tree);
-  void simple_type_specifier (tree);
-  void function_specifier (tree);
-  void declarator (tree);
-  void direct_declarator (tree);
-  void abstract_declarator (tree);
-  void direct_abstract_declarator (tree);
+  void constant (tree) final override;
+  void id_expression (tree) final override;
+  void primary_expression (tree) final override;
+  void postfix_expression (tree) final override;
+  void unary_expression (tree) final override;
+  void multiplicative_expression (tree) final override;
+  void conditional_expression (tree) final override;
+  void assignment_expression (tree) final override;
+  void expression (tree) final override;
+  void type_id (tree) final override;
+  void statement (tree) final override;
+  void declaration (tree) final override;
+  void declaration_specifiers (tree) final override;
+  void simple_type_specifier (tree) final override;
+  void function_specifier (tree) final override;
+  void declarator (tree) final override;
+  void direct_declarator (tree) final override;
+  void abstract_declarator (tree) final override;
+  void direct_abstract_declarator (tree) final override;
 
   /* This is the enclosing scope of the entity being pretty-printed.  */
   tree enclosing_scope;
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index d1dc73724d1..e93151c98c2 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -1483,10 +1483,10 @@  private:
 
 protected:
   using allocator::grow;
-  virtual char *grow (char *, unsigned needed);
+  char *grow (char *, unsigned needed) final override;
 #if MAPPED_WRITING
   using allocator::shrink;
-  virtual void shrink (char *);
+  void shrink (char *) final override;
 #endif
 
 public:
diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc
index 2b84b849330..a0b22c50ae3 100644
--- a/gcc/genmatch.cc
+++ b/gcc/genmatch.cc
@@ -723,9 +723,9 @@  public:
   bool force_leaf;
   /* If non-zero, the group for optional handling.  */
   unsigned char opt_grp;
-  virtual void gen_transform (FILE *f, int, const char *, bool, int,
-			      const char *, capture_info *,
-			      dt_operand ** = 0, int = 0);
+  void gen_transform (FILE *f, int, const char *, bool, int,
+		      const char *, capture_info *,
+		      dt_operand ** = 0, int = 0) override;
 };
 
 /* An operator that is represented by native C code.  This is always
@@ -757,9 +757,9 @@  public:
   unsigned nr_stmts;
   /* The identifier replacement vector.  */
   vec<id_tab> ids;
-  virtual void gen_transform (FILE *f, int, const char *, bool, int,
-			      const char *, capture_info *,
-			      dt_operand ** = 0, int = 0);
+  void gen_transform (FILE *f, int, const char *, bool, int,
+		      const char *, capture_info *,
+		      dt_operand ** = 0, int = 0) final override;
 };
 
 /* A wrapper around another operand that captures its value.  */
@@ -778,9 +778,9 @@  public:
   bool value_match;
   /* The captured value.  */
   operand *what;
-  virtual void gen_transform (FILE *f, int, const char *, bool, int,
-			      const char *, capture_info *,
-			      dt_operand ** = 0, int = 0);
+  void gen_transform (FILE *f, int, const char *, bool, int,
+		      const char *, capture_info *,
+		      dt_operand ** = 0, int = 0) final override;
 };
 
 /* if expression.  */
@@ -1655,7 +1655,7 @@  public:
       : dt_node (type, parent_), op (op_), match_dop (match_dop_),
       pos (pos_), value_match (false), for_id (current_id) {}
 
-  void gen (FILE *, int, bool, int);
+  void gen (FILE *, int, bool, int) final override;
   unsigned gen_predicate (FILE *, int, const char *, bool);
   unsigned gen_match_op (FILE *, int, const char *, bool);
 
@@ -1681,7 +1681,7 @@  public:
 	  indexes (indexes_), info (NULL)  {}
 
   void gen_1 (FILE *, int, bool, operand *);
-  void gen (FILE *f, int, bool, int);
+  void gen (FILE *f, int, bool, int) final override;
 };
 
 template<>
diff --git a/gcc/gensupport.cc b/gcc/gensupport.cc
index 42680499d86..8fcacf8f9d2 100644
--- a/gcc/gensupport.cc
+++ b/gcc/gensupport.cc
@@ -2310,7 +2310,7 @@  class gen_reader : public rtx_reader
 {
  public:
   gen_reader () : rtx_reader (false) {}
-  void handle_unknown_directive (file_location, const char *);
+  void handle_unknown_directive (file_location, const char *) final override;
 };
 
 void
diff --git a/gcc/gimple-range-cache.h b/gcc/gimple-range-cache.h
index 555fe32513f..d768f418f0d 100644
--- a/gcc/gimple-range-cache.h
+++ b/gcc/gimple-range-cache.h
@@ -77,8 +77,8 @@  public:
   ranger_cache (int not_executable_flag, bool use_imm_uses);
   ~ranger_cache ();
 
-  virtual bool range_of_expr (irange &r, tree name, gimple *stmt);
-  virtual bool range_on_edge (irange &r, edge e, tree expr);
+  bool range_of_expr (irange &r, tree name, gimple *stmt) final override;
+  bool range_on_edge (irange &r, edge e, tree expr) final override;
   bool block_range (irange &r, basic_block bb, tree name, bool calc = true);
 
   bool get_global_range (irange &r, tree name) const;
diff --git a/gcc/ipa-icf-gimple.h b/gcc/ipa-icf-gimple.h
index 1545e4a5905..8f498b31eef 100644
--- a/gcc/ipa-icf-gimple.h
+++ b/gcc/ipa-icf-gimple.h
@@ -282,11 +282,13 @@  private:
 public:
   /* Return true if two operands are equal.  The flags fields can be used
      to specify OEP flags described above.  */
-  virtual bool operand_equal_p (const_tree, const_tree, unsigned int flags);
+  bool operand_equal_p (const_tree, const_tree, unsigned int flags)
+    final override;
 
   /* Generate a hash value for an expression.  This can be used iteratively
      by passing a previous result as the HSTATE argument.  */
-  virtual void hash_operand (const_tree, inchash::hash &, unsigned flags);
+  void hash_operand (const_tree, inchash::hash &, unsigned flags)
+    final override;
   void hash_operand (const_tree, inchash::hash &, unsigned flags,
 		     operand_access_type access);
 };
diff --git a/gcc/ipa-icf.h b/gcc/ipa-icf.h
index dbae2cca02b..bb550923ad4 100644
--- a/gcc/ipa-icf.h
+++ b/gcc/ipa-icf.h
@@ -317,16 +317,18 @@  public:
 
   ~sem_function ();
 
-  virtual void init (ipa_icf_gimple::func_checker *);
-  virtual bool equals_wpa (sem_item *item,
-			   hash_map <symtab_node *, sem_item *> &ignored_nodes);
-  virtual hashval_t get_hash (void);
-  virtual bool equals (sem_item *item,
-		       hash_map <symtab_node *, sem_item *> &ignored_nodes);
-  virtual bool merge (sem_item *alias_item);
+  void init (ipa_icf_gimple::func_checker *) final override;
+  bool equals_wpa (sem_item *item,
+		   hash_map <symtab_node *, sem_item *> &ignored_nodes)
+    final override;
+  hashval_t get_hash (void) final override;
+  bool equals (sem_item *item,
+	       hash_map <symtab_node *, sem_item *> &ignored_nodes)
+    final override;
+  bool merge (sem_item *alias_item) final override;
 
   /* Dump symbol to FILE.  */
-  virtual void dump_to_file (FILE *file)
+  void dump_to_file (FILE *file) final override
   {
     gcc_assert (file);
     dump_function_to_file (decl, file, TDF_DETAILS);
@@ -426,17 +428,19 @@  public:
   sem_variable (varpool_node *_node, bitmap_obstack *stack);
 
   /* Semantic variable initialization function.  */
-  virtual void init (ipa_icf_gimple::func_checker *);
+  void init (ipa_icf_gimple::func_checker *) final override;
 
-  virtual hashval_t get_hash (void);
-  virtual bool merge (sem_item *alias_item);
-  virtual void dump_to_file (FILE *file);
-  virtual bool equals (sem_item *item,
-		       hash_map <symtab_node *, sem_item *> &ignored_nodes);
+  hashval_t get_hash (void) final override;
+  bool merge (sem_item *alias_item) final override;
+  void dump_to_file (FILE *file) final override;
+  bool equals (sem_item *item,
+	       hash_map <symtab_node *, sem_item *> &ignored_nodes)
+    final override;
 
   /* Fast equality variable based on knowledge known in WPA.  */
-  virtual bool equals_wpa (sem_item *item,
-			   hash_map <symtab_node *, sem_item *> &ignored_nodes);
+  bool equals_wpa (sem_item *item,
+		   hash_map <symtab_node *, sem_item *> &ignored_nodes)
+     final override;
 
   /* Returns varpool_node.  */
   inline varpool_node *get_node (void)
diff --git a/gcc/lto/lto-dump.cc b/gcc/lto/lto-dump.cc
index 1fb3fb86fb5..f88486b5143 100644
--- a/gcc/lto/lto-dump.cc
+++ b/gcc/lto/lto-dump.cc
@@ -80,7 +80,7 @@  public:
   virtual ~variable_entry ()
   {}
 
-  virtual size_t get_size () const
+  size_t get_size () const final override
   {
     varpool_node *vnode = dyn_cast<varpool_node *> (node);
     if (DECL_SIZE (vnode->decl) && tree_fits_shwi_p (DECL_SIZE (vnode->decl)))
@@ -88,7 +88,7 @@  public:
     return 0;
   }
 
-  virtual void dump ()
+  void dump () final override
   {
     symbol_entry :: dump ();
     varpool_node *vnode = dyn_cast<varpool_node *> (node);
@@ -111,13 +111,13 @@  public:
   virtual ~function_entry ()
   {}
 
-  virtual void dump ()
+  void dump () final override
   {
     symbol_entry :: dump ();
     printf ("\n");
   }
 
-  virtual size_t get_size () const
+  size_t get_size () const final override
   {
     cgraph_node *cnode = dyn_cast<cgraph_node *> (node);
     gcc_assert (cnode);
diff --git a/gcc/read-md.h b/gcc/read-md.h
index 34a64fa93a2..7d8cd4a8336 100644
--- a/gcc/read-md.h
+++ b/gcc/read-md.h
@@ -330,7 +330,7 @@  class noop_reader : public md_reader
   noop_reader () : md_reader (false) {}
 
   /* A dummy implementation which skips unknown directives.  */
-  void handle_unknown_directive (file_location, const char *);
+  void handle_unknown_directive (file_location, const char *) override;
 };
 
 /* An md_reader subclass that actually handles full hierarchical
diff --git a/gcc/read-rtl-function.cc b/gcc/read-rtl-function.cc
index eacbe4c1200..3bcff1540e7 100644
--- a/gcc/read-rtl-function.cc
+++ b/gcc/read-rtl-function.cc
@@ -188,7 +188,7 @@  class fixup_insn_uid : public operand_fixup
       m_insn_uid (insn_uid)
   {}
 
-  void apply (function_reader *reader) const;
+  void apply (function_reader *reader) const final override;
 
  private:
   int m_insn_uid;
@@ -206,7 +206,7 @@  class fixup_note_insn_basic_block : public operand_fixup
       m_bb_idx (bb_idx)
   {}
 
-  void apply (function_reader *reader) const;
+  void apply (function_reader *reader) const final override;
 
  private:
   int m_bb_idx;
@@ -225,7 +225,7 @@  class fixup_expr : public fixup
 
   ~fixup_expr () { free (m_desc); }
 
-  void apply (function_reader *reader) const;
+  void apply (function_reader *reader) const final override;
 
  private:
   char *m_desc;
diff --git a/gcc/tree-ssa-loop-ch.cc b/gcc/tree-ssa-loop-ch.cc
index 9ab63d1fa0c..d1391940c2b 100644
--- a/gcc/tree-ssa-loop-ch.cc
+++ b/gcc/tree-ssa-loop-ch.cc
@@ -320,7 +320,7 @@  public:
 
 protected:
   /* ch_base method: */
-  virtual bool process_loop_p (class loop *loop);
+  bool process_loop_p (class loop *loop) final override;
 }; // class pass_ch
 
 const pass_data pass_data_ch_vect =
@@ -358,7 +358,7 @@  public:
 
 protected:
   /* ch_base method: */
-  virtual bool process_loop_p (class loop *loop);
+  bool process_loop_p (class loop *loop) final override;
 }; // class pass_ch_vect
 
 /* For all loops, copy the condition at the end of the loop body in front
diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
index 7407591e98c..b2f35a5fb55 100644
--- a/gcc/tree-ssa-sccvn.cc
+++ b/gcc/tree-ssa-sccvn.cc
@@ -2534,9 +2534,9 @@  public:
     : eliminate_dom_walker (CDI_DOMINATORS, NULL), entry (entry_),
       m_avail_freelist (NULL) {}
 
-  virtual tree eliminate_avail (basic_block, tree op);
+  tree eliminate_avail (basic_block, tree op) final override;
 
-  virtual void eliminate_push_avail (basic_block, tree);
+  void eliminate_push_avail (basic_block, tree) final override;
 
   basic_block entry;
   /* Freelist of avail entries which are allocated from the vn_ssa_aux