public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Move messages on division by zero to the right operand
@ 2022-01-06 17:13 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-01-06 17:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: Piotr Trojanek

[-- Attachment #1: Type: text/plain, Size: 374 bytes --]

All compile-time messages about division by zero are now located at the
right operand. Previously some of them were located at the division
operator, which was inconsistent.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* sem_eval.adb (Eval_Arithmetic_Op): Add Loc parameter to all
	calls to Apply_Compile_Time_Constraint_Error related to division
	by zero.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1506 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
@@ -2117,6 +2117,7 @@ package body Sem_Eval is
 
                      Apply_Compile_Time_Constraint_Error
                        (N, "division by zero", CE_Divide_By_Zero,
+                        Loc  => Sloc (Right),
                         Warn => not Stat or SPARK_Mode = On);
                      return;
 
@@ -2139,6 +2140,7 @@ package body Sem_Eval is
 
                      Apply_Compile_Time_Constraint_Error
                        (N, "mod with zero divisor", CE_Divide_By_Zero,
+                        Loc  => Sloc (Right),
                         Warn => not Stat or SPARK_Mode = On);
                      return;
 
@@ -2159,6 +2161,7 @@ package body Sem_Eval is
 
                      Apply_Compile_Time_Constraint_Error
                        (N, "rem with zero divisor", CE_Divide_By_Zero,
+                        Loc  => Sloc (Right),
                         Warn => not Stat or SPARK_Mode = On);
                      return;
 
@@ -2218,7 +2221,8 @@ package body Sem_Eval is
             else pragma Assert (Nkind (N) = N_Op_Divide);
                if UR_Is_Zero (Right_Real) then
                   Apply_Compile_Time_Constraint_Error
-                    (N, "division by zero", CE_Divide_By_Zero);
+                    (N, "division by zero", CE_Divide_By_Zero,
+                     Loc => Sloc (Right));
                   return;
                end if;
 



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-06 17:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-06 17:13 [Ada] Move messages on division by zero to the right operand 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).