diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2020-11-27 09:21:17 +0100 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-12-16 08:00:59 -0500 |
commit | 94117322e68f29677f5a7088fc83f57e824ca8a7 (patch) | |
tree | f71699012f27f915e85ab22b9cd12a0ed456a48c | |
parent | cbe22e189a355f19eb1344fcaf91bc2bb0b95f36 (diff) | |
download | gcc-94117322e68f29677f5a7088fc83f57e824ca8a7.zip gcc-94117322e68f29677f5a7088fc83f57e824ca8a7.tar.gz gcc-94117322e68f29677f5a7088fc83f57e824ca8a7.tar.bz2 |
[Ada] Another small adjustment to System.Value_R
gcc/ada/
* libgnat/s-valuer.adb (Scan_Decimal_Digits): Tweak overflow test.
(Scan_Integral_Digits): Likewise.
-rw-r--r-- | gcc/ada/libgnat/s-valuer.adb | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/gcc/ada/libgnat/s-valuer.adb b/gcc/ada/libgnat/s-valuer.adb index 9c126cc..65a0d50 100644 --- a/gcc/ada/libgnat/s-valuer.adb +++ b/gcc/ada/libgnat/s-valuer.adb @@ -236,12 +236,15 @@ package body System.Value_R is Temp := Value * Uns (Base) + Uns (Digit); -- Check if Temp is larger than Precision_Limit, taking into - -- account that Temp may have wrapped around. + -- account that Temp may wrap around when Precision_Limit is + -- equal to the largest integer. if Value <= Umax or else (Value <= UmaxB - and then Temp <= Precision_Limit - and then Temp >= Uns (Base)) + and then ((Precision_Limit < Uns'Last + and then Temp <= Precision_Limit) + or else (Precision_Limit = Uns'Last + and then Temp >= Uns (Base)))) then Value := Temp; Scale := Scale - 1; @@ -386,12 +389,15 @@ package body System.Value_R is Temp := Value * Uns (Base) + Uns (Digit); -- Check if Temp is larger than Precision_Limit, taking into - -- account that Temp may have wrapped around. + -- account that Temp may wrap around when Precision_Limit is + -- equal to the largest integer. if Value <= Umax or else (Value <= UmaxB - and then Temp <= Precision_Limit - and then Temp >= Uns (Base)) + and then ((Precision_Limit < Uns'Last + and then Temp <= Precision_Limit) + or else (Precision_Limit = Uns'Last + and then Temp >= Uns (Base)))) then Value := Temp; |