* [Ada] Set constraint error on real division just like on integer division
@ 2021-05-05 8:20 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-05-05 8:20 UTC (permalink / raw)
To: gcc-patches; +Cc: Piotr Trojanek
[-- Attachment #1: Type: text/plain, Size: 737 bytes --]
In Eval_Arithmetic_Op we set Raises_Constraint_Error flag on integer
division by zero, but we didn't set it for real division by zero.
This only affects GNATprove, because GNAT sets this flag inside
Apply_Compile_Time_Constraint_Error (which has an early return guarded
by GNATprove_Mode). Possibly the Raises_Constraint_Error flag should be
only set inside Apply_Compile_Time_Constraint_Error, but at least this
patch allows GNATprove to be have consistently for integer and real
division by zero.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_eval.adb (Eval_Arithmetic_Op): Call
Set_Raises_Constraint_Error on real division by zero just like
it is called for integer division by zero earlier in this
routine.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 433 bytes --]
diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb
--- a/gcc/ada/sem_eval.adb
+++ b/gcc/ada/sem_eval.adb
@@ -2226,6 +2226,7 @@ package body Sem_Eval is
if UR_Is_Zero (Right_Real) then
Apply_Compile_Time_Constraint_Error
(N, "division by zero", CE_Divide_By_Zero);
+ Set_Raises_Constraint_Error (N);
return;
end if;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-05-05 8:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-05 8:20 [Ada] Set constraint error on real division just like on integer division Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).