From ed1707422002fb2efaa18f6abb790b0b10255c30 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Tue, 17 Jul 2018 08:12:46 +0000 Subject: [PATCH] [Ada] Add provision for floating-point in Apply_Division_Check 2018-07-17 Arnaud Charlet gcc/ada/ * checks.adb (Apply_Division_Check): Add provision for floating-point checks. From-SVN: r262801 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/checks.adb | 25 ++++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index afee8f4aa85..38db4d6189d 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2018-07-17 Arnaud Charlet + + * checks.adb (Apply_Division_Check): Add provision for floating-point + checks. + 2018-07-17 Ed Schonberg * exp_aggr.adb (Component_OK_For_Backend): If an array component of the diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index 8e061ebfd48..0af436f0d70 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -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; -- 2.30.2