diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2020-11-06 13:51:45 +0100 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-11-27 04:16:05 -0500 |
commit | def0e5b83ddb5d4916d0e804b9044f73ffb2923c (patch) | |
tree | 0e2bf236895806ac1def143a2ad5b2e41a704ed2 /gcc/ada/libgnat | |
parent | 4e6b87e933bbbf3671f02210261615076b998644 (diff) | |
download | gcc-def0e5b83ddb5d4916d0e804b9044f73ffb2923c.zip gcc-def0e5b83ddb5d4916d0e804b9044f73ffb2923c.tar.gz gcc-def0e5b83ddb5d4916d0e804b9044f73ffb2923c.tar.bz2 |
[Ada] Small tweaks to couple of Value routines
gcc/ada/
* libgnat/s-valuef.adb (Integer_To_Fixed): Take into account the
extra digit when scaling up the input.
* libgnat/s-valuer.adb (Scan_Decimal_Digits): Restrict previous
change to fixed-point types.
(Scan_Integral_Digits): Likewise.
Diffstat (limited to 'gcc/ada/libgnat')
-rw-r--r-- | gcc/ada/libgnat/s-valuef.adb | 5 | ||||
-rw-r--r-- | gcc/ada/libgnat/s-valuer.adb | 18 |
2 files changed, 14 insertions, 9 deletions
diff --git a/gcc/ada/libgnat/s-valuef.adb b/gcc/ada/libgnat/s-valuef.adb index f3ed5fa..caec598 100644 --- a/gcc/ada/libgnat/s-valuef.adb +++ b/gcc/ada/libgnat/s-valuef.adb @@ -227,8 +227,9 @@ package body System.Value_F is Z := N; for J in 1 .. LS loop - if V <= Uns'Last / Uns (B) then - V := V * Uns (B); + if V <= (Uns'Last - E) / Uns (B) then + V := V * Uns (B) + E; + E := 0; else Bad_Value (Str); end if; diff --git a/gcc/ada/libgnat/s-valuer.adb b/gcc/ada/libgnat/s-valuer.adb index 0fa4fe1..06d7adc 100644 --- a/gcc/ada/libgnat/s-valuer.adb +++ b/gcc/ada/libgnat/s-valuer.adb @@ -188,11 +188,13 @@ package body System.Value_R is -- If precision limit has been reached, just ignore any remaining -- digits for the computation of Value and Scale, but store the - -- first in Extra and use the second to round Extra. The scanning - -- should continue only to assess the validity of the string. + -- first in Extra and use the second to round Extra if this is for + -- a fixed-point type (we skip the rounding for a floating-point + -- type to preserve backward compatibility). The scanning should + -- continue only to assess the validity of the string. if Precision_Limit_Reached then - if Precision_Limit_Just_Reached then + if Precision_Limit_Just_Reached and then not Floating then if Digit >= Base / 2 then if Extra = Base - 1 then Extra := 0; @@ -343,14 +345,16 @@ package body System.Value_R is end if; -- If precision limit has been reached, just ignore any remaining - -- digits for the computation of Value, but update Scale and store - -- the first in Extra and use the second to round Extra. The scanning - -- should continue only to assess the validity of the string. + -- digits for the computation of Value and Scale, but store the + -- first in Extra and use the second to round Extra if this is for + -- a fixed-point type (we skip the rounding for a floating-point + -- type to preserve backward compatibility). The scanning should + -- continue only to assess the validity of the string. if Precision_Limit_Reached then Scale := Scale + 1; - if Precision_Limit_Just_Reached then + if Precision_Limit_Just_Reached and then not Floating then if Digit >= Base / 2 then if Extra = Base - 1 then Extra := 0; |