public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Set Raises_CE flag only in Apply_Compile_Time_Constraint_Error
@ 2021-05-06  7:58 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-05-06  7:58 UTC (permalink / raw)
  To: gcc-patches; +Cc: Piotr Trojanek

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

Routine Apply_Compile_Time_Constraint_Error, when operating in GNAT
mode, always sets Raises_Constraint_Error flag, so there is no need to
follow it with calls to Set_Raises_Constraint_Error. These calls only
had an effect in GNATprove mode, but they were following few calls to
Apply_Compile_Time_Constraint_Error.

Now the call to Set_Raises_Constraint_Error is executed exclusively as
part of Apply_Compile_Time_Constraint_Error, both in GNAT and GNATprove
modes.

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

gcc/ada/

	* sem_ch4.adb (Analyze_Selected_Component): Remove explicit call
	to Set_Raises_Constraint_Error on statically missing component.
	* sem_eval.adb (Eval_Arithmetic_Op): Likewise for static
	divisions by integer and real zeros.
	* sem_util.adb (Apply_Compile_Time_Constraint_Error): Call
	Set_Raises_Constraint_Error before exiting early in GNATprove
	mode.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1550 bytes --]

diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -5452,8 +5452,6 @@ package body Sem_Ch4 is
                        (N, "component not present in }??",
                         CE_Discriminant_Check_Failed,
                         Ent => Prefix_Type);
-
-                     Set_Raises_Constraint_Error (N);
                      return;
                   end if;
 


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
@@ -2124,7 +2124,6 @@ package body Sem_Eval is
                      Apply_Compile_Time_Constraint_Error
                        (N, "division by zero", CE_Divide_By_Zero,
                         Warn => not Stat or SPARK_Mode = On);
-                     Set_Raises_Constraint_Error (N);
                      return;
 
                   --  Otherwise we can do the division
@@ -2226,7 +2225,6 @@ 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;
 


diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -1436,6 +1436,7 @@ package body Sem_Util is
       --  generate a check message.
 
       if GNATprove_Mode then
+         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-06  7:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06  7:58 [Ada] Set Raises_CE flag only in Apply_Compile_Time_Constraint_Error 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).