When tree-ssa-propagate.h is compiled with clang, it complains that
member functions functions value_of_expr and range_of_expr of class
substitute_and_fold_engine are not marked as override even though they
do override virtual functions of the ancestor class.  This patch
merely adds the keyword to silence the warning and for consistency's
sake.

I did not make this part of the previous patch because I wanted to
point out that the first case is quite unusual, a virtual function
with a functional body (range_query::value_of_expr) is being
overridden with a pure virtual function.  I assume it was a conscious
decision but adding the override keyword seems even more important
then.

Bootstrapped and tested on x86_64-linx.  OK for master?

Alternatively, as with all of these clang warning issues, I'm
perfectly happy to add an entry to contrib/filter-clang-warnings.py to
ignore the warning(s) instead.

Thanks,

Martin


gcc/ChangeLog:

2025-06-24  Martin Jambor  <mjam...@suse.cz>

        * tree-ssa-propagate.h (class substitute_and_fold_engine): Mark
        member functions value_of_expr and range_of_expr as override.
---
 gcc/tree-ssa-propagate.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/tree-ssa-propagate.h b/gcc/tree-ssa-propagate.h
index 8429e38f40e..200fc732079 100644
--- a/gcc/tree-ssa-propagate.h
+++ b/gcc/tree-ssa-propagate.h
@@ -102,10 +102,10 @@ class substitute_and_fold_engine : public range_query
   substitute_and_fold_engine (bool fold_all_stmts = false)
     : fold_all_stmts (fold_all_stmts) { }
 
-  virtual tree value_of_expr (tree expr, gimple * = NULL) = 0;
+  virtual tree value_of_expr (tree expr, gimple * = NULL) override = 0;
   virtual tree value_on_edge (edge, tree expr) override;
   virtual tree value_of_stmt (gimple *, tree name = NULL) override;
-  virtual bool range_of_expr (vrange &r, tree expr, gimple * = NULL);
+  virtual bool range_of_expr (vrange &r, tree expr, gimple * = NULL) override;
 
   virtual ~substitute_and_fold_engine (void) { }
   virtual bool fold_stmt (gimple_stmt_iterator *) { return false; }
-- 
2.49.0

Reply via email to