summaryrefslogtreecommitdiff
path: root/gcc/ada/a-nudira.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-19 10:59:04 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-19 10:59:04 +0000
commit341bd953dd179dacec3648ffc315c01ae8f6be39 (patch)
tree007f417d2cffc875792dc7dd354090911831687c /gcc/ada/a-nudira.adb
parentd4b026c15fdd0957de6d579ec01628981ade8fdd (diff)
downloadgcc-341bd953dd179dacec3648ffc315c01ae8f6be39.tar.gz
2009-06-19 Eric Botcazou <ebotcazou@adacore.com>
* einfo.ads (Handling of Type'Size Values): Fix Object_Size values. 2009-06-19 Robert Dewar <dewar@adacore.com> * a-nudira.adb (Need_64): Handle negative ranges and also dynamic ranges * checks.adb (Determine_Range): Move the test for generic types later. * sem_eval.adb (Compile_Time_Compare): Improve circuitry to catch more cases. (Eval_Relational_Op): Fold more cases including string compares * sem_util.ads, sem_util.adb (References_Generic_Formal_Type): New function. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148697 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-nudira.adb')
-rw-r--r--gcc/ada/a-nudira.adb15
1 files changed, 14 insertions, 1 deletions
diff --git a/gcc/ada/a-nudira.adb b/gcc/ada/a-nudira.adb
index 087ce56ea08..3a8819b6aaa 100644
--- a/gcc/ada/a-nudira.adb
+++ b/gcc/ada/a-nudira.adb
@@ -51,11 +51,24 @@ package body Ada.Numerics.Discrete_Random is
type Pointer is access all State;
- Need_64 : constant Boolean := Rst'Pos (Rst'Last) > Int'Last;
+ Need_64 : constant Boolean := Rst'Pos (Rst'Last) > 2**31 - 1
+ or else
+ Rst'Pos (Rst'First) < 2**31;
-- Set if we need more than 32 bits in the result. In practice we will
-- only use the meaningful 48 bits of any 64 bit number generated, since
-- if more than 48 bits are required, we split the computation into two
-- separate parts, since the algorithm does not behave above 48 bits.
+ --
+ -- Note: the right hand side used to be Int'Last, but that won't work
+ -- since it means that if Rst is a dynamic subtype, the comparison is
+ -- evaluated at run time in type Int, which is too small. In practice
+ -- the use of dynamic bounds is rare, and this constant will always
+ -- be evaluated at compile time in an instance.
+ --
+ -- This still is not quite right for dynamic subtypes of 64-bit modular
+ -- types where the upper bound can exceed the upper bound of universal
+ -- integer. Not clear how to do this with a nice static expression ???
+ -- Might have to introduce a special Type'First_In_32_Bits attribute!
-----------------------
-- Local Subprograms --