aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2020-08-19 21:54:21 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2020-10-22 08:11:23 -0400
commit46e54783503c30aecb7e36e6034f915ffc479d33 (patch)
tree7c3ab03800ff3c5b12dd8507183b3b34ccf2cb6d /gcc
parentd7e20130650fb46d71e0403652e4e07bc14f9775 (diff)
downloadgcc-46e54783503c30aecb7e36e6034f915ffc479d33.zip
gcc-46e54783503c30aecb7e36e6034f915ffc479d33.tar.gz
gcc-46e54783503c30aecb7e36e6034f915ffc479d33.tar.bz2
[Ada] Fix bogus error on conversion from Float to 128-bit unsigned
gcc/ada/ * checks.adb (Apply_Float_Conversion_Check): Saturate the bounds of the check to those of the base type of the expression.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/checks.adb18
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
index 6d20fbb..3552795 100644
--- a/gcc/ada/checks.adb
+++ b/gcc/ada/checks.adb
@@ -2149,6 +2149,15 @@ package body Checks is
Lo_OK := (Lo >= UR_From_Uint (Ifirst));
end if;
+ -- Saturate the lower bound to that of the expression's type, because
+ -- we do not want to create an out-of-range value but we still need to
+ -- do a comparison to catch NaNs.
+
+ if Lo < Expr_Value_R (Type_Low_Bound (Expr_Type)) then
+ Lo := Expr_Value_R (Type_Low_Bound (Expr_Type));
+ Lo_OK := True;
+ end if;
+
if Lo_OK then
-- Lo_Chk := (X >= Lo)
@@ -2183,6 +2192,15 @@ package body Checks is
Hi_OK := (Hi <= UR_From_Uint (Ilast));
end if;
+ -- Saturate the higher bound to that of the expression's type, because
+ -- we do not want to create an out-of-range value but we still need to
+ -- do a comparison to catch NaNs.
+
+ if Hi > Expr_Value_R (Type_High_Bound (Expr_Type)) then
+ Hi := Expr_Value_R (Type_High_Bound (Expr_Type));
+ Hi_OK := True;
+ end if;
+
if Hi_OK then
-- Hi_Chk := (X <= Hi)