From c3c80e3c3adde1f96d9f5070eccf1184a97ce2cd Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Fri, 31 Jan 2020 05:47:01 -0500 Subject: [PATCH] [Ada] AI12-0144 Make Discrete_Random more flexible 2020-06-05 Arnaud Charlet gcc/ada/ * libgnat/a-nudira.ads, libgnat/a-nudira.adb (Random): New function. --- gcc/ada/libgnat/a-nudira.adb | 11 +++++++++++ gcc/ada/libgnat/a-nudira.ads | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/gcc/ada/libgnat/a-nudira.adb b/gcc/ada/libgnat/a-nudira.adb index 77f81b44856..e18403cf140 100644 --- a/gcc/ada/libgnat/a-nudira.adb +++ b/gcc/ada/libgnat/a-nudira.adb @@ -56,6 +56,17 @@ is return Random (SRN.Generator (Gen)); end Random; + function Random + (Gen : Generator; + First : Result_Subtype; + Last : Result_Subtype) return Result_Subtype + is + subtype Local_Subtype is Result_Subtype range First .. Last; + function Random is new SRN.Random_Discrete (Local_Subtype, First); + begin + return Random (SRN.Generator (Gen)); + end Random; + ----------- -- Reset -- ----------- diff --git a/gcc/ada/libgnat/a-nudira.ads b/gcc/ada/libgnat/a-nudira.ads index 64342dd3b14..35b7dc62b50 100644 --- a/gcc/ada/libgnat/a-nudira.ads +++ b/gcc/ada/libgnat/a-nudira.ads @@ -51,6 +51,12 @@ is function Random (Gen : Generator) return Result_Subtype; + function Random + (Gen : Generator; + First : Result_Subtype; + Last : Result_Subtype) return Result_Subtype + with Post => Random'Result in First .. Last; + procedure Reset (Gen : Generator; Initiator : Integer); procedure Reset (Gen : Generator); -- 2.30.2