https://gcc.gnu.org/g:85f0620a8b0cde32fb12e27f602e13445281e670

commit r16-1680-g85f0620a8b0cde32fb12e27f602e13445281e670
Author: Martin Jambor <mjam...@suse.cz>
Date:   Wed Jun 25 16:59:12 2025 +0200

    ranger: Mark several member functions as final override
    
    When GCC is built with clang, it emits warnings that several member
    functions of various ranger classes override a virtual function of an
    ancestor but are not marked with the override keyword.  After
    inspecting the cases, I found that all these classes had other member
    functions marked as final override, so I added the final keyword
    everywhere too.
    
    In some cases other such overrides were not explicitly marked as
    virtual, which made formatting easier.  For that reason and also for
    consistency, in such cases I removed the virtual keyword from the
    functions I marked as final override too.
    
    gcc/ChangeLog:
    
    2025-06-24  Martin Jambor  <mjam...@suse.cz>
    
            * range-op-mixed.h (class operator_plus): Mark member function
            overflow_free_p as final override.
            (class operator_minus): Likewise.
            (class operator_mult): Likewise.
            * range-op-ptr.cc (class pointer_plus_operator): Mark member
            function lhs_op1_relation as final override.
            * range-op.cc (class operator_div::): Mark member functions
            op2_range and update_bitmask as final override.
            (class operator_logical_and): Mark member functions fold_range,
            op1_range and op2_range as final override.  Remove unnecessary
            virtual.
            (class operator_logical_or): Likewise.
            (class operator_logical_not): Mark member functions fold_range and
            op1_range as final override.  Remove unnecessary virtual.
            formatting easier.
            (class operator_absu): Mark member functions wi_fold as final
            override.

Diff:
---
 gcc/range-op-mixed.h | 12 ++++-----
 gcc/range-op-ptr.cc  |  2 +-
 gcc/range-op.cc      | 72 +++++++++++++++++++++++++++-------------------------
 3 files changed, 44 insertions(+), 42 deletions(-)

diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h
index f8f183069046..567b0cdd31bb 100644
--- a/gcc/range-op-mixed.h
+++ b/gcc/range-op-mixed.h
@@ -558,8 +558,8 @@ public:
   void update_bitmask (irange &r, const irange &lh,
                       const irange &rh) const final override;
 
-  virtual bool overflow_free_p (const irange &lh, const irange &rh,
-                               relation_trio = TRIO_VARYING) const;
+  bool overflow_free_p (const irange &lh, const irange &rh,
+                       relation_trio = TRIO_VARYING) const final override;
   // Check compatibility of all operands.
   bool operand_check_p (tree t1, tree t2, tree t3) const final override
     { return range_compatible_p (t1, t2) && range_compatible_p (t1, t3); }
@@ -634,8 +634,8 @@ public:
   void update_bitmask (irange &r, const irange &lh,
                       const irange &rh) const final override;
 
-  virtual bool overflow_free_p (const irange &lh, const irange &rh,
-                               relation_trio = TRIO_VARYING) const;
+  bool overflow_free_p (const irange &lh, const irange &rh,
+                       relation_trio = TRIO_VARYING) const final override;
   // Check compatibility of all operands.
   bool operand_check_p (tree t1, tree t2, tree t3) const final override
     { return range_compatible_p (t1, t2) && range_compatible_p (t1, t3); }
@@ -720,8 +720,8 @@ public:
                const REAL_VALUE_TYPE &lh_lb, const REAL_VALUE_TYPE &lh_ub,
                const REAL_VALUE_TYPE &rh_lb, const REAL_VALUE_TYPE &rh_ub,
                relation_kind kind) const final override;
-  virtual bool overflow_free_p (const irange &lh, const irange &rh,
-                               relation_trio = TRIO_VARYING) const;
+  bool overflow_free_p (const irange &lh, const irange &rh,
+                       relation_trio = TRIO_VARYING) const final override;
   // Check compatibility of all operands.
   bool operand_check_p (tree t1, tree t2, tree t3) const final override
     { return range_compatible_p (t1, t2) && range_compatible_p (t1, t3); }
diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc
index 6aadc9cf2c95..e0e21ad1b2a3 100644
--- a/gcc/range-op-ptr.cc
+++ b/gcc/range-op-ptr.cc
@@ -315,7 +315,7 @@ public:
   virtual relation_kind lhs_op1_relation (const prange &lhs,
                                          const prange &op1,
                                          const irange &op2,
-                                         relation_kind) const;
+                                         relation_kind) const final override;
   void update_bitmask (prange &r, const prange &lh, const irange &rh) const
     { update_known_bitmask (r, POINTER_PLUS_EXPR, lh, rh); }
 } op_pointer_plus;
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 0a3f0b6b56c7..1f91066a44e7 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -2455,7 +2455,7 @@ class operator_div : public cross_product_operator
 public:
   operator_div (tree_code div_kind) { m_code = div_kind; }
   bool op2_range (irange &r, tree type, const irange &lhs, const irange &,
-                 relation_trio) const;
+                 relation_trio) const final override;
   virtual void wi_fold (irange &r, tree type,
                        const wide_int &lh_lb,
                        const wide_int &lh_ub,
@@ -2464,7 +2464,8 @@ public:
   virtual bool wi_op_overflows (wide_int &res, tree type,
                                const wide_int &, const wide_int &)
     const final override;
-  void update_bitmask (irange &r, const irange &lh, const irange &rh) const
+  void update_bitmask (irange &r, const irange &lh, const irange &rh)
+    const final override
     { update_known_bitmask (r, m_code, lh, rh); }
 protected:
   tree_code m_code;
@@ -3233,18 +3234,18 @@ class operator_logical_and : public range_operator
   using range_operator::op1_range;
   using range_operator::op2_range;
 public:
-  virtual bool fold_range (irange &r, tree type,
-                          const irange &lh,
-                          const irange &rh,
-                          relation_trio rel = TRIO_VARYING) const;
-  virtual bool op1_range (irange &r, tree type,
-                         const irange &lhs,
-                         const irange &op2,
-                         relation_trio rel = TRIO_VARYING) const;
-  virtual bool op2_range (irange &r, tree type,
-                         const irange &lhs,
-                         const irange &op1,
-                         relation_trio rel = TRIO_VARYING) const;
+  bool fold_range (irange &r, tree type,
+                  const irange &lh,
+                  const irange &rh,
+                  relation_trio rel = TRIO_VARYING) const final override;
+  bool op1_range (irange &r, tree type,
+                 const irange &lhs,
+                 const irange &op2,
+                 relation_trio rel = TRIO_VARYING) const final override;
+  bool op2_range (irange &r, tree type,
+                 const irange &lhs,
+                 const irange &op1,
+                 relation_trio rel = TRIO_VARYING) const final override;
   // Check compatibility of all operands.
   bool operand_check_p (tree t1, tree t2, tree t3) const final override
     { return range_compatible_p (t1, t2) && range_compatible_p (t1, t3); }
@@ -3757,18 +3758,18 @@ class operator_logical_or : public range_operator
   using range_operator::op1_range;
   using range_operator::op2_range;
 public:
-  virtual bool fold_range (irange &r, tree type,
-                          const irange &lh,
-                          const irange &rh,
-                          relation_trio rel = TRIO_VARYING) const;
-  virtual bool op1_range (irange &r, tree type,
-                         const irange &lhs,
-                         const irange &op2,
-                         relation_trio rel = TRIO_VARYING) const;
-  virtual bool op2_range (irange &r, tree type,
-                         const irange &lhs,
-                         const irange &op1,
-                         relation_trio rel = TRIO_VARYING) const;
+  bool fold_range (irange &r, tree type,
+                  const irange &lh,
+                  const irange &rh,
+                  relation_trio rel = TRIO_VARYING) const final override;
+  bool op1_range (irange &r, tree type,
+                 const irange &lhs,
+                 const irange &op2,
+                 relation_trio rel = TRIO_VARYING) const final override;
+  bool op2_range (irange &r, tree type,
+                 const irange &lhs,
+                 const irange &op1,
+                 relation_trio rel = TRIO_VARYING) const final override;
   // Check compatibility of all operands.
   bool operand_check_p (tree t1, tree t2, tree t3) const final override
     { return range_compatible_p (t1, t2) && range_compatible_p (t1, t3); }
@@ -4203,14 +4204,14 @@ class operator_logical_not : public range_operator
   using range_operator::fold_range;
   using range_operator::op1_range;
 public:
-  virtual bool fold_range (irange &r, tree type,
-                          const irange &lh,
-                          const irange &rh,
-                          relation_trio rel = TRIO_VARYING) const;
-  virtual bool op1_range (irange &r, tree type,
-                         const irange &lhs,
-                         const irange &op2,
-                         relation_trio rel = TRIO_VARYING) const;
+  bool fold_range (irange &r, tree type,
+                  const irange &lh,
+                  const irange &rh,
+                  relation_trio rel = TRIO_VARYING) const final override;
+  bool op1_range (irange &r, tree type,
+                 const irange &lhs,
+                 const irange &op2,
+                 relation_trio rel = TRIO_VARYING) const final override;
   // Check compatibility of LHS and op1.
   bool operand_check_p (tree t1, tree t2, tree) const final override
     { return range_compatible_p (t1, t2); }
@@ -4484,7 +4485,8 @@ class operator_absu : public range_operator
  public:
   virtual void wi_fold (irange &r, tree type,
                        const wide_int &lh_lb, const wide_int &lh_ub,
-                       const wide_int &rh_lb, const wide_int &rh_ub) const;
+                       const wide_int &rh_lb, const wide_int &rh_ub)
+    const final override;
   virtual void update_bitmask (irange &r, const irange &lh,
                               const irange &rh) const final override;
 } op_absu;

Reply via email to