https://gcc.gnu.org/g:a61eb1d4ad7e1bf53303ae3ff7e6141e54f1f9af

commit r16-1794-ga61eb1d4ad7e1bf53303ae3ff7e6141e54f1f9af
Author: Eric Botcazou <ebotca...@adacore.com>
Date:   Fri Apr 18 14:48:04 2025 +0200

    ada: Remove redundant condition in test of System.Val_Real.Integer_To_Real
    
    The second condition of the conjunction is redundant with the first.
    
    gcc/ada/ChangeLog:
    
            * libgnat/s-valrea.adb (Integer_to_Real): Rename to...
            (Integer_To_Real): ...this.  Remove the second condition of the
            conjunction in the test for the zero value.
            (Scan_Real): Adjust to above renaming.
            (Value_Real): Likewise.
            * libgnat/s-valuer.ads (Scan_Raw_Real): Add note about Val.

Diff:
---
 gcc/ada/libgnat/s-valrea.adb | 14 +++++++-------
 gcc/ada/libgnat/s-valuer.ads |  3 ++-
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/gcc/ada/libgnat/s-valrea.adb b/gcc/ada/libgnat/s-valrea.adb
index aff694dd7219..6dd8aa5da967 100644
--- a/gcc/ada/libgnat/s-valrea.adb
+++ b/gcc/ada/libgnat/s-valrea.adb
@@ -90,7 +90,7 @@ package body System.Val_Real is
         when others => raise Program_Error);
    --  Return the exponent of a power of 2
 
-   function Integer_to_Real
+   function Integer_To_Real
      (Str   : String;
       Val   : Impl.Value_Array;
       Base  : Unsigned;
@@ -105,10 +105,10 @@ package body System.Val_Real is
    --  Return Num'Scaling (5.0**Exp, -S) as a double number where Exp > Maxexp
 
    ---------------------
-   -- Integer_to_Real --
+   -- Integer_To_Real --
    ---------------------
 
-   function Integer_to_Real
+   function Integer_To_Real
      (Str   : String;
       Val   : Impl.Value_Array;
       Base  : Unsigned;
@@ -213,7 +213,7 @@ package body System.Val_Real is
 
       --  Compute the final value by applying the scaling, if any
 
-      if (Val (1) = 0 and then Val (2) = 0) or else S = 0 then
+      if Val (1) = 0 or else S = 0 then
          R_Val := Double_Real.To_Single (D_Val);
 
       else
@@ -313,7 +313,7 @@ package body System.Val_Real is
 
    exception
       when Constraint_Error => Bad_Value (Str);
-   end Integer_to_Real;
+   end Integer_To_Real;
 
    -------------------
    -- Large_Powfive --
@@ -456,7 +456,7 @@ package body System.Val_Real is
    begin
       Val := Impl.Scan_Raw_Real (Str, Ptr, Max, Base, Scale, Extra, Minus);
 
-      return Integer_to_Real (Str, Val, Base, Scale, Minus);
+      return Integer_To_Real (Str, Val, Base, Scale, Minus);
    end Scan_Real;
 
    ----------------
@@ -473,7 +473,7 @@ package body System.Val_Real is
    begin
       Val := Impl.Value_Raw_Real (Str, Base, Scale, Extra, Minus);
 
-      return Integer_to_Real (Str, Val, Base, Scale, Minus);
+      return Integer_To_Real (Str, Val, Base, Scale, Minus);
    end Value_Real;
 
 end System.Val_Real;
diff --git a/gcc/ada/libgnat/s-valuer.ads b/gcc/ada/libgnat/s-valuer.ads
index 9f2799828121..bc5a2e0954aa 100644
--- a/gcc/ada/libgnat/s-valuer.ads
+++ b/gcc/ada/libgnat/s-valuer.ads
@@ -85,7 +85,8 @@ package System.Value_R is
    --
    --    Sum [Val (N) * (Base ** Scale (N)), N in 1 .. Parts]
    --
-   --  when Parts > 1, with the negative sign if Minus is true.
+   --  when Parts > 1, with the negative sign if Minus is true. Note that
+   --  Val (1) cannot be zero unless Val is entirely filled with zero.
    --
    --  If no valid real is found, then Ptr.all points either to an initial
    --  non-blank character, or to Max + 1 if the field is all spaces and the

Reply via email to