]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Remove redundant condition in test of System.Val_Real.Integer_To_Real
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 18 Apr 2025 12:48:04 +0000 (14:48 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 30 Jun 2025 13:47:20 +0000 (15:47 +0200)
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.

gcc/ada/libgnat/s-valrea.adb
gcc/ada/libgnat/s-valuer.ads

index aff694dd7219ae8a3965a2e223e6ce8fe70cdcfc..6dd8aa5da96741f4e04eab0ad1f5b6d0a1e01521 100644 (file)
@@ -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;
index 9f2799828121485fc8ce16f45003b633bf0339c2..bc5a2e0954aa06b8b9c4f28059c935797f1fc6bd 100644 (file)
@@ -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