aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2020-06-24 13:24:49 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-10-15 05:39:12 -0400
commit7e37c1a522eca7dbe88ec58d22a88362df572758 (patch)
tree623e3ecc298c0d32bd6e14573fc2db9c9c502076 /gcc
parente4f503be5d8f4b6f985f91ffe8a42ed9663466b3 (diff)
downloadgcc-7e37c1a522eca7dbe88ec58d22a88362df572758.zip
gcc-7e37c1a522eca7dbe88ec58d22a88362df572758.tar.gz
gcc-7e37c1a522eca7dbe88ec58d22a88362df572758.tar.bz2
[Ada] Crash on subtype of fixed-point type
gcc/ada/ * freeze.adb (Freeze_Fixed_Point_Type): Do not scale the bounds of a declared subtype using the 'Small of the type; this is done during resolution of the bound itself, unlike what is done for the bounds of the base type, which are used to determine its required size. Previous code performed this scaling twice, leading to meaningless values for such a subtype.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/freeze.adb21
1 files changed, 10 insertions, 11 deletions
diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index 1c177b1..5032724 100644
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -8494,21 +8494,21 @@ package body Freeze is
Set_Analyzed (Lo, False);
Analyze (Lo);
- -- Resolve with universal fixed if the base type, and the base type if
- -- it is a subtype. Note we can't resolve the base type with itself,
- -- that would be a reference before definition.
+ -- Resolve with universal fixed if the base type, and with the base
+ -- type if we are freezing a subtype. Note we can't resolve the base
+ -- type with itself, that would be a reference before definition.
+ -- The resolution of the bounds of a subtype, if they are given by real
+ -- literals, includes the setting of the Corresponding_Integer_Value,
+ -- as for other literals of a fixed-point type.
if Typ = Btyp then
Resolve (Lo, Universal_Fixed);
+ Set_Corresponding_Integer_Value
+ (Lo, UR_To_Uint (Realval (Lo) / Small));
else
Resolve (Lo, Btyp);
end if;
- -- Set corresponding integer value for bound
-
- Set_Corresponding_Integer_Value
- (Lo, UR_To_Uint (Realval (Lo) / Small));
-
-- Similar processing for high bound
Set_Etype (Hi, Empty);
@@ -8517,13 +8517,12 @@ package body Freeze is
if Typ = Btyp then
Resolve (Hi, Universal_Fixed);
+ Set_Corresponding_Integer_Value
+ (Hi, UR_To_Uint (Realval (Hi) / Small));
else
Resolve (Hi, Btyp);
end if;
- Set_Corresponding_Integer_Value
- (Hi, UR_To_Uint (Realval (Hi) / Small));
-
-- Set type of range to correspond to bounds
Set_Etype (Rng, Etype (Lo));