aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2020-12-18 18:49:31 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2021-04-29 04:00:48 -0400
commit8833f142768c41651503e709262d0d0fdd4a196c (patch)
tree94d3aee48a15ae618ee152a05d6c17ddba74d2c4 /gcc
parent210cae9d510bffe5f4103ea82afe07f9b31418db (diff)
downloadgcc-8833f142768c41651503e709262d0d0fdd4a196c.zip
gcc-8833f142768c41651503e709262d0d0fdd4a196c.tar.gz
gcc-8833f142768c41651503e709262d0d0fdd4a196c.tar.bz2
[Ada] Fix minor issue in Scan_Decimal_Digits
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/libgnat/s-valuer.adb11
1 files changed, 10 insertions, 1 deletions
diff --git a/gcc/ada/libgnat/s-valuer.adb b/gcc/ada/libgnat/s-valuer.adb
index bd57bfb..937ef8e 100644
--- a/gcc/ada/libgnat/s-valuer.adb
+++ b/gcc/ada/libgnat/s-valuer.adb
@@ -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)