]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Plug small loophole in Discrete_Range_Check
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 12 Aug 2019 08:59:02 +0000 (08:59 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Mon, 12 Aug 2019 08:59:02 +0000 (08:59 +0000)
This routine would not return if range checks are suppressed.

2019-08-12  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* exp_ch4.adb (Discrete_Range_Check): Return if checks are
suppressed.

From-SVN: r274282

gcc/ada/ChangeLog
gcc/ada/exp_ch4.adb

index 315b4f64d63fa39cd4ba702feaaf6bcca0482a73..df19f1bf69bc3def04008c29adc92f857153e7b3 100644 (file)
@@ -1,3 +1,8 @@
+2019-08-12  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * exp_ch4.adb (Discrete_Range_Check): Return if checks are
+       suppressed.
+
 2019-08-12  Eric Botcazou  <ebotcazou@adacore.com>
 
        * sem_res.adb: Add with & use clause for Sem_Mech and
index e4dc06b5d6a896beedef5c67750f7d2f432482fa..425c505bef56e0725bed5d9cf44d85e3feaf489b 100644 (file)
@@ -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