From: Eric Botcazou Date: Mon, 12 Aug 2019 08:59:02 +0000 (+0000) Subject: [Ada] Plug small loophole in Discrete_Range_Check X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=43eb2bb6967ffd6d9b9fadfa606c177671c28261;p=gcc.git [Ada] Plug small loophole in Discrete_Range_Check This routine would not return if range checks are suppressed. 2019-08-12 Eric Botcazou gcc/ada/ * exp_ch4.adb (Discrete_Range_Check): Return if checks are suppressed. From-SVN: r274282 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 315b4f64d63..df19f1bf69b 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2019-08-12 Eric Botcazou + + * exp_ch4.adb (Discrete_Range_Check): Return if checks are + suppressed. + 2019-08-12 Eric Botcazou * sem_res.adb: Add with & use clause for Sem_Mech and diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index e4dc06b5d6a..425c505bef5 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -10969,7 +10969,9 @@ package body Exp_Ch4 is -- Discrete_Range_Check -- -------------------------- - -- Case of conversions to a discrete type + -- Case of conversions to a discrete type. We let Generate_Range_Check + -- do the heavy lifting, after converting a fixed-point operand to an + -- appropriate integer type. procedure Discrete_Range_Check is Expr : Node_Id; @@ -10984,6 +10986,21 @@ package body Exp_Ch4 is Expr := Expression (N); + -- Nothing to do if range checks suppressed + + if Range_Checks_Suppressed (Target_Type) then + return; + end if; + + -- Nothing to do if expression is an entity on which checks have been + -- suppressed. + + if Is_Entity_Name (Expr) + and then Range_Checks_Suppressed (Entity (Expr)) + then + return; + end if; + -- Before we do a range check, we have to deal with treating -- a fixed-point operand as an integer. The way we do this -- is simply to do an unchecked conversion to an appropriate