]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Fix minor issue in Scan_Decimal_Digits
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 18 Dec 2020 17:49:31 +0000 (18:49 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 29 Apr 2021 08:00:48 +0000 (04:00 -0400)
gcc/ada/

* libgnat/s-valuer.adb (Scan_Decimal_Digits): Set Extra to zero
when the precision limit is reached by means of trailing zeros
and prevent it from being overwritten later.

gcc/ada/libgnat/s-valuer.adb

index bd57bfbd88c1b08192cfd28966102e802a9908f5..937ef8e9db939aba17dee475a0e706597e7a967d 100644 (file)
@@ -261,7 +261,11 @@ package body System.Value_R is
                      Scale := Scale - 1;
 
                   else
+                     Extra := 0;
                      Precision_Limit_Reached := True;
+                     if Round and then J = Trailing_Zeros then
+                        Round_Extra (Digit, Value, Scale, Extra, Base);
+                     end if;
                      exit;
                   end if;
                end loop;
@@ -274,11 +278,16 @@ package body System.Value_R is
 
                Temp := Value * Uns (Base) + Uns (Digit);
 
+               --  Precision_Limit_Reached may have been set above
+
+               if Precision_Limit_Reached then
+                  null;
+
                --  Check if Temp is larger than Precision_Limit, taking into
                --  account that Temp may wrap around when Precision_Limit is
                --  equal to the largest integer.
 
-               if Value <= Umax
+               elsif Value <= Umax
                  or else (Value <= UmaxB
                            and then ((Precision_Limit < Uns'Last
                                        and then Temp <= Precision_Limit)