]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Couple of adjustments for the sake of static analyzers
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 7 Dec 2020 21:04:43 +0000 (22:04 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 28 Apr 2021 09:37:59 +0000 (05:37 -0400)
gcc/ada/

* libgnat/s-valrea.adb (Integer_to_Real): Use a subtype of Num
for the component type of the table of powers of ten.
* libgnat/s-valuer.adb (Round_Extra): Add assertion on Base.

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

index 0ac3846542b75132660ff8da9c3c898b418b2077..582b9662486227b8ca71771532db72779a9ba854 100644 (file)
@@ -173,7 +173,9 @@ package body System.Val_Real is
 
             when 10 =>
                declare
-                  Powten : constant array (0 .. Maxpow) of Num;
+                  subtype Pow_Num is Num range 1.0 .. Num'Last;
+
+                  Powten : constant array (0 .. Maxpow) of Pow_Num;
                   pragma Import (Ada, Powten);
                   for Powten'Address use Powten_Address;
 
index 9e4de3e299e02e34582c55951eab9917726ec151..bd57bfbd88c1b08192cfd28966102e802a9908f5 100644 (file)
@@ -128,6 +128,8 @@ package body System.Value_R is
       Extra : in out Char_As_Digit;
       Base  : Unsigned)
    is
+      pragma Assert (Base in 2 .. 16);
+
       B : constant Uns := Uns (Base);
 
    begin