[Ada] Add provision for floating-point in Apply_Division_Check
authorArnaud Charlet <charlet@adacore.com>
Tue, 17 Jul 2018 08:12:46 +0000 (08:12 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Tue, 17 Jul 2018 08:12:46 +0000 (08:12 +0000)
2018-07-17  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

* checks.adb (Apply_Division_Check): Add provision for floating-point
checks.

From-SVN: r262801

gcc/ada/ChangeLog
gcc/ada/checks.adb

index afee8f4aa85bded687ff08541662ba57ee313f58..38db4d6189d225956a9b986f4177ff7efc7e22bd 100644 (file)
@@ -1,3 +1,8 @@
+2018-07-17  Arnaud Charlet  <charlet@adacore.com>
+
+       * checks.adb (Apply_Division_Check): Add provision for floating-point
+       checks.
+
 2018-07-17  Ed Schonberg  <schonberg@adacore.com>
 
        * exp_aggr.adb (Component_OK_For_Backend): If an array component of the
index 8e061ebfd48731aad02a5d1093bdbee1d42229e7..0af436f0d708a7e23f8f828f141c79719b5343bb 100644 (file)
@@ -1888,13 +1888,24 @@ package body Checks is
             Set_Do_Division_Check (N, False);
 
             if (not ROK) or else (Rlo <= 0 and then 0 <= Rhi) then
-               Insert_Action (N,
-                 Make_Raise_Constraint_Error (Loc,
-                   Condition =>
-                     Make_Op_Eq (Loc,
-                       Left_Opnd  => Duplicate_Subexpr_Move_Checks (Right),
-                       Right_Opnd => Make_Integer_Literal (Loc, 0)),
-                   Reason => CE_Divide_By_Zero));
+               if Is_Floating_Point_Type (Etype (N)) then
+                  Insert_Action (N,
+                    Make_Raise_Constraint_Error (Loc,
+                      Condition =>
+                        Make_Op_Eq (Loc,
+                          Left_Opnd  => Duplicate_Subexpr_Move_Checks (Right),
+                          Right_Opnd => Make_Real_Literal (Loc, Ureal_0)),
+                      Reason => CE_Divide_By_Zero));
+
+               else
+                  Insert_Action (N,
+                    Make_Raise_Constraint_Error (Loc,
+                      Condition =>
+                        Make_Op_Eq (Loc,
+                          Left_Opnd  => Duplicate_Subexpr_Move_Checks (Right),
+                          Right_Opnd => Make_Integer_Literal (Loc, 0)),
+                      Reason => CE_Divide_By_Zero));
+               end if;
             end if;
          end if;
       end if;