From: Arnaud Charlet Date: Fri, 24 Jan 2014 16:22:02 +0000 (+0100) Subject: [multiple changes] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c51f5910f32421583d6b64d9681bba4c1b7d9a62;p=gcc.git [multiple changes] 2014-01-24 Eric Botcazou * set_targ.adb: Set Short_Enums. * gcc-interface/lang.opt (fshort-enums): New option. * gcc-interface/misc.c (gnat_handle_option): Handle it. (gnat_post_options): Do not modify the global settings. 2014-01-24 Robert Dewar * g-rannum.ads, g-rannum.adb (Random_Ordinary_Fixed): New generic function. (Random_Decimal_Fixed): New generic function. * s-rannum.ads: Minor comment clarifications. From-SVN: r207049 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 686e96e7b8e..f0cb5ee91ca 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,17 @@ +2014-01-24 Eric Botcazou + + * set_targ.adb: Set Short_Enums. + * gcc-interface/lang.opt (fshort-enums): New option. + * gcc-interface/misc.c (gnat_handle_option): Handle it. + (gnat_post_options): Do not modify the global settings. + +2014-01-24 Robert Dewar + + * g-rannum.ads, g-rannum.adb (Random_Ordinary_Fixed): New generic + function. + (Random_Decimal_Fixed): New generic function. + * s-rannum.ads: Minor comment clarifications. + 2014-01-24 Robert Dewar * back_end.adb: Remove Short_Enums handling (handled in diff --git a/gcc/ada/g-rannum.adb b/gcc/ada/g-rannum.adb index e35c86cb281..a868f08123e 100644 --- a/gcc/ada/g-rannum.adb +++ b/gcc/ada/g-rannum.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2007-2009 Free Software Foundation, Inc. -- +-- Copyright (C) 2007-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -30,8 +30,9 @@ ------------------------------------------------------------------------------ with Ada.Numerics.Long_Elementary_Functions; -use Ada.Numerics.Long_Elementary_Functions; +use Ada.Numerics.Long_Elementary_Functions; with Ada.Unchecked_Conversion; + with System.Random_Numbers; use System.Random_Numbers; package body GNAT.Random_Numbers is @@ -87,6 +88,40 @@ package body GNAT.Random_Numbers is return F (Gen.Rep, Min, Max); end Random_Discrete; + -------------------------- + -- Random_Decimal_Fixed -- + -------------------------- + + function Random_Decimal_Fixed + (Gen : Generator; + Min : Result_Subtype := Default_Min; + Max : Result_Subtype := Result_Subtype'Last) return Result_Subtype + is + subtype IntV is Integer_64 range + Integer_64'Integer_Value (Min) .. + Integer_64'Integer_Value (Max); + function R is new Random_Discrete (Integer_64, IntV'First); + begin + return Result_Subtype'Fixed_Value (R (Gen, IntV'First, IntV'Last)); + end Random_Decimal_Fixed; + + --------------------------- + -- Random_Ordinary_Fixed -- + --------------------------- + + function Random_Ordinary_Fixed + (Gen : Generator; + Min : Result_Subtype := Default_Min; + Max : Result_Subtype := Result_Subtype'Last) return Result_Subtype + is + subtype IntV is Integer_64 range + Integer_64'Integer_Value (Min) .. + Integer_64'Integer_Value (Max); + function R is new Random_Discrete (Integer_64, IntV'First); + begin + return Result_Subtype'Fixed_Value (R (Gen, IntV'First, IntV'Last)); + end Random_Ordinary_Fixed; + ------------ -- Random -- ------------ @@ -137,7 +172,7 @@ package body GNAT.Random_Numbers is -- Random_Float -- ------------------ - function Random_Float (Gen : Generator) return Result_Subtype is + function Random_Float (Gen : Generator) return Result_Subtype is function F is new System.Random_Numbers.Random_Float (Result_Subtype); begin return F (Gen.Rep); diff --git a/gcc/ada/g-rannum.ads b/gcc/ada/g-rannum.ads index 353e21cd0f1..010c21c6cde 100644 --- a/gcc/ada/g-rannum.ads +++ b/gcc/ada/g-rannum.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2007-2009 Free Software Foundation, Inc. -- +-- Copyright (C) 2007-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -78,10 +78,28 @@ package GNAT.Random_Numbers is Max : Result_Subtype := Result_Subtype'Last) return Result_Subtype; -- Returns pseudo-random numbers uniformly distributed on Min .. Max + generic + type Result_Subtype is delta <>; + Default_Min : Result_Subtype := 0.0; + function Random_Ordinary_Fixed + (Gen : Generator; + Min : Result_Subtype := Default_Min; + Max : Result_Subtype := Result_Subtype'Last) return Result_Subtype; + -- Returns pseudo-random numbers uniformly distributed on Min .. Max + + generic + type Result_Subtype is delta <> digits <>; + Default_Min : Result_Subtype := 0.0; + function Random_Decimal_Fixed + (Gen : Generator; + Min : Result_Subtype := Default_Min; + Max : Result_Subtype := Result_Subtype'Last) return Result_Subtype; + -- Returns pseudo-random numbers uniformly distributed on Min .. Max + generic type Result_Subtype is digits <>; function Random_Float (Gen : Generator) return Result_Subtype; - -- Returns pseudo-random numbers uniformly distributed on [0 .. 1) + -- Returns pseudo-random numbers uniformly distributed on [0.0 .. 1.0) function Random_Gaussian (Gen : Generator) return Long_Float; function Random_Gaussian (Gen : Generator) return Float; diff --git a/gcc/ada/gcc-interface/lang.opt b/gcc/ada/gcc-interface/lang.opt index debeff660e0..004388ba26a 100644 --- a/gcc/ada/gcc-interface/lang.opt +++ b/gcc/ada/gcc-interface/lang.opt @@ -1,6 +1,5 @@ ; Options for the Ada front end. -; Copyright (C) 2003, 2007, 2008, 2010, 2011, 2012 -; Free Software Foundation, Inc. +; Copyright (C) 2003-2013 Free Software Foundation, Inc. ; ; This file is part of GCC. ; @@ -18,7 +17,6 @@ ; along with GCC; see the file COPYING3. If not see ; . - ; See the GCC internals manual for a description of this file's format. ; Please try to keep this file in ASCII collating order. @@ -74,6 +72,10 @@ fRTS= Ada AdaWhy AdaSCIL Joined RejectNegative Select the runtime +fshort-enums +Ada AdaWhy AdaSCIL +Use the narrowest integer type possible for enumeration types + gant Ada AdaWhy AdaSCIL Joined Undocumented Catch typos diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c index 0272050954f..5f135a063b2 100644 --- a/gcc/ada/gcc-interface/misc.c +++ b/gcc/ada/gcc-interface/misc.c @@ -151,6 +151,10 @@ gnat_handle_option (size_t scode, const char *arg ATTRIBUTE_UNUSED, int value, /* These are handled by the front-end. */ break; + case OPT_fshort_enums: + /* This is handled by the middle-end. */ + break; + default: gcc_unreachable (); } @@ -259,13 +263,14 @@ gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED) optimize_size = global_options.x_optimize_size; flag_compare_debug = global_options.x_flag_compare_debug; flag_stack_check = global_options.x_flag_stack_check; - - /* Unfortunately the post_options hook is called before setting the - short_enums flag. Set it now. */ - if (global_options.x_flag_short_enums == 2) - global_options.x_flag_short_enums = targetm.default_short_enums (); flag_short_enums = global_options.x_flag_short_enums; + /* Unfortunately the post_options hook is called before the value of + flag_short_enums is autodetected, if need be. Mimic the process + for our private flag_short_enums. */ + if (flag_short_enums == 2) + flag_short_enums = targetm.default_short_enums (); + return false; } diff --git a/gcc/ada/s-rannum.ads b/gcc/ada/s-rannum.ads index 0d2a7e9dee7..a412b9c85c9 100644 --- a/gcc/ada/s-rannum.ads +++ b/gcc/ada/s-rannum.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2007-2010, Free Software Foundation, Inc. -- +-- Copyright (C) 2007-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -56,12 +56,16 @@ with Interfaces; package System.Random_Numbers is type Generator is limited private; + -- Generator encodes the current state of a random number stream, it is + -- provided as input to produce the next random number, and updated so + -- that it is ready to produce the next one. + type State is private; -- A non-limited version of a Generator's internal state function Random (Gen : Generator) return Float; function Random (Gen : Generator) return Long_Float; - -- Return pseudo-random numbers uniformly distributed on [0 .. 1) + -- Return pseudo-random numbers uniformly distributed on [0.0 .. 1.0) function Random (Gen : Generator) return Interfaces.Unsigned_32; function Random (Gen : Generator) return Interfaces.Unsigned_64; diff --git a/gcc/ada/set_targ.adb b/gcc/ada/set_targ.adb index 0dc9b839b25..83ba3313483 100755 --- a/gcc/ada/set_targ.adb +++ b/gcc/ada/set_targ.adb @@ -573,6 +573,7 @@ begin Maximum_Alignment := Get_Maximum_Alignment; Max_Unaligned_Field := Get_Max_Unaligned_Field; Pointer_Size := Get_Pointer_Size; + Short_Enums := Get_Short_Enums; Short_Size := Get_Short_Size; Strict_Alignment := Get_Strict_Alignment; System_Allocator_Alignment := Get_System_Allocator_Alignment;