From: Arnaud Charlet Date: Thu, 7 May 2020 07:09:18 +0000 (-0400) Subject: [Ada] AI12-0366 Changes to Big_Integer and Big_Real X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=90d8163d9b9d90ceeead4e360b9d8d8dc2878074;p=gcc.git [Ada] AI12-0366 Changes to Big_Integer and Big_Real gcc/ada/ * libgnat/a-nbnbin.ads, libgnat/a-nbnbin.adb, libgnat/a-nbnbin__gmp.adb: Use more Valid_Big_Integer. --- diff --git a/gcc/ada/libgnat/a-nbnbin.adb b/gcc/ada/libgnat/a-nbnbin.adb index 9c8b7333cb8..5d415d9c17b 100644 --- a/gcc/ada/libgnat/a-nbnbin.adb +++ b/gcc/ada/libgnat/a-nbnbin.adb @@ -133,7 +133,7 @@ package body Ada.Numerics.Big_Numbers.Big_Integers is -- To_Integer -- ---------------- - function To_Integer (Arg : Big_Integer) return Integer is + function To_Integer (Arg : Valid_Big_Integer) return Integer is begin return Integer (From_Bignum (Get_Bignum (Arg))); end To_Integer; @@ -159,7 +159,7 @@ package body Ada.Numerics.Big_Numbers.Big_Integers is -- From_Big_Integer -- ---------------------- - function From_Big_Integer (Arg : Big_Integer) return Int is + function From_Big_Integer (Arg : Valid_Big_Integer) return Int is begin return Int (From_Bignum (Get_Bignum (Arg))); end From_Big_Integer; @@ -187,7 +187,7 @@ package body Ada.Numerics.Big_Numbers.Big_Integers is -- From_Big_Integer -- ---------------------- - function From_Big_Integer (Arg : Big_Integer) return Int is + function From_Big_Integer (Arg : Valid_Big_Integer) return Int is begin return Int (From_Bignum (Get_Bignum (Arg))); end From_Big_Integer; diff --git a/gcc/ada/libgnat/a-nbnbin.ads b/gcc/ada/libgnat/a-nbnbin.ads index 98619aa88cc..74232f9cbe8 100644 --- a/gcc/ada/libgnat/a-nbnbin.ads +++ b/gcc/ada/libgnat/a-nbnbin.ads @@ -58,10 +58,11 @@ is then Big_Natural >= To_Big_Integer (0)), Predicate_Failure => (raise Constraint_Error); - function In_Range (Arg, Low, High : Big_Integer) return Boolean is - ((Low <= Arg) and (Arg <= High)); + function In_Range + (Arg : Valid_Big_Integer; Low, High : Big_Integer) return Boolean + is (Low <= Arg and Arg <= High); - function To_Integer (Arg : Big_Integer) return Integer + function To_Integer (Arg : Valid_Big_Integer) return Integer with Pre => In_Range (Arg, Low => To_Big_Integer (Integer'First), High => To_Big_Integer (Integer'Last)) @@ -73,7 +74,7 @@ is function To_Big_Integer (Arg : Int) return Valid_Big_Integer; - function From_Big_Integer (Arg : Big_Integer) return Int + function From_Big_Integer (Arg : Valid_Big_Integer) return Int with Pre => In_Range (Arg, Low => To_Big_Integer (Int'First), High => To_Big_Integer (Int'Last)) @@ -87,7 +88,7 @@ is function To_Big_Integer (Arg : Int) return Valid_Big_Integer; - function From_Big_Integer (Arg : Big_Integer) return Int + function From_Big_Integer (Arg : Valid_Big_Integer) return Int with Pre => In_Range (Arg, Low => To_Big_Integer (Int'First), High => To_Big_Integer (Int'Last)) diff --git a/gcc/ada/libgnat/a-nbnbin__gmp.adb b/gcc/ada/libgnat/a-nbnbin__gmp.adb index 025272f90ad..9481eed63a1 100644 --- a/gcc/ada/libgnat/a-nbnbin__gmp.adb +++ b/gcc/ada/libgnat/a-nbnbin__gmp.adb @@ -330,7 +330,7 @@ package body Ada.Numerics.Big_Numbers.Big_Integers is -- From_String -- ----------------- - function From_String (Arg : String) return Valid_Big_Integer is + function From_String (Arg : String) return Big_Integer is function mpz_set_str (this : access mpz_t; str : System.Address; @@ -405,7 +405,7 @@ package body Ada.Numerics.Big_Numbers.Big_Integers is -- Put_Image -- --------------- - procedure Put_Image (S : in out Sink'Class; V : Big_Real) is + procedure Put_Image (S : in out Sink'Class; V : Big_Integer) is -- This is implemented in terms of To_String. It might be more elegant -- and more efficient to do it the other way around, but this is the -- most expedient implementation for now.