public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Ronan Desplanques <desplanques@adacore.com>
Subject: [COMMITTED 25/35] ada: Fix reason code for length check
Date: Thu, 16 May 2024 11:25:54 +0200	[thread overview]
Message-ID: <20240516092606.41242-25-poulhies@adacore.com> (raw)
In-Reply-To: <20240516092606.41242-1-poulhies@adacore.com>

From: Ronan Desplanques <desplanques@adacore.com>

This patch fixes the reason code used by Apply_Selected_Length_Checks,
which was wrong in some cases when the check could be determined to
always fail at compile time.

gcc/ada/

	* checks.adb (Apply_Selected_Length_Checks): Fix reason code.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/checks.adb | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
index 4e3eb502706..6af392eeda8 100644
--- a/gcc/ada/checks.adb
+++ b/gcc/ada/checks.adb
@@ -322,7 +322,8 @@ package body Checks is
    --  that the access value is non-null, since the checks do not
    --  not apply to null access values.
 
-   procedure Install_Static_Check (R_Cno : Node_Id; Loc : Source_Ptr);
+   procedure Install_Static_Check
+     (R_Cno : Node_Id; Loc : Source_Ptr; Reason : RT_Exception_Code);
    --  Called by Apply_{Length,Range}_Checks to rewrite the tree with the
    --  Constraint_Error node.
 
@@ -3001,7 +3002,7 @@ package body Checks is
             Insert_Action (Insert_Node, R_Cno);
 
          else
-            Install_Static_Check (R_Cno, Loc);
+            Install_Static_Check (R_Cno, Loc, CE_Range_Check_Failed);
          end if;
       end loop;
    end Apply_Range_Check;
@@ -3469,7 +3470,7 @@ package body Checks is
             end if;
 
          else
-            Install_Static_Check (R_Cno, Loc);
+            Install_Static_Check (R_Cno, Loc, CE_Length_Check_Failed);
          end if;
       end loop;
    end Apply_Selected_Length_Checks;
@@ -8692,14 +8693,16 @@ package body Checks is
    -- Install_Static_Check --
    --------------------------
 
-   procedure Install_Static_Check (R_Cno : Node_Id; Loc : Source_Ptr) is
+   procedure Install_Static_Check
+     (R_Cno : Node_Id; Loc : Source_Ptr; Reason : RT_Exception_Code)
+   is
       Stat : constant Boolean   := Is_OK_Static_Expression (R_Cno);
       Typ  : constant Entity_Id := Etype (R_Cno);
 
    begin
       Rewrite (R_Cno,
         Make_Raise_Constraint_Error (Loc,
-          Reason => CE_Range_Check_Failed));
+          Reason => Reason));
       Set_Analyzed (R_Cno);
       Set_Etype (R_Cno, Typ);
       Set_Raises_Constraint_Error (R_Cno);
-- 
2.43.2


  parent reply	other threads:[~2024-05-16  9:26 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-16  9:25 [COMMITTED 01/35] ada: Fix docs and comments about pragmas for Boolean-valued aspects Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 02/35] ada: Fix casing in error messages Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 03/35] ada: Fix ordering of code for pragma Preelaborable_Initialization Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 04/35] ada: Fix alphabetic ordering of aspect identifiers Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 05/35] ada: Cleanup reporting locations for Ada 2022 and GNAT extension aspects Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 06/35] ada: Reuse existing expression when rewriting aspects to pragmas Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 07/35] ada: Remove Aspect_Specifications field from N_Procedure_Specification Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 08/35] ada: Fix bug in maintaining dimension info Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 09/35] ada: Formal_Derived_Type'Size is not static Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 10/35] ada: Implement per-finalization-collection spinlocks Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 11/35] ada: Follow up fixes for Put_Image/streaming regressions Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 12/35] ada: Fix crash with -gnatdJ and -gnatw_q Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 13/35] ada: Fix casing of CUDA in error messages Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 14/35] ada: Fix bogus error on function returning noncontrolling result in private part Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 15/35] ada: Fix resolving tagged operations in array aggregates Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 16/35] ada: Fix latent alignment issue for dynamically-allocated controlled objects Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 17/35] ada: Fix typo in CUDA error message Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 18/35] ada: Fixup one more pattern of broken scope information Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 19/35] ada: Minor performance improvement for dynamically-allocated controlled objects Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 20/35] ada: Fix comments about Get_Ranged_Checks Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 21/35] ada: Fix detection of if_expressions that are known on entry Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 22/35] ada: No need to follow New_Occurrence_Of with Set_Etype Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 23/35] ada: Improve recovery from illegal occurrence of 'Old in if_expression Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 24/35] ada: Propagate Program_Error from failed finalization of collection Marc Poulhiès
2024-05-16  9:25 ` Marc Poulhiès [this message]
2024-05-16  9:25 ` [COMMITTED 26/35] ada: Ignore ghost nodes in call graph information for dispatching calls Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 27/35] ada: Avoid checking parameters of protected procedures Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 28/35] ada: Fix standalone Windows builds of adaint.c Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 29/35] ada: Fix missing length checks with case expressions Marc Poulhiès
2024-05-16  9:25 ` [COMMITTED 30/35] ada: Fix reference to RM clause in comment Marc Poulhiès
2024-05-16  9:26 ` [COMMITTED 31/35] ada: Implement new experimental attribute 'Super Marc Poulhiès
2024-05-16  9:26 ` [COMMITTED 32/35] ada: Exception on Indefinite_Vector aggregate with loop_parameter_specification Marc Poulhiès
2024-05-16  9:26 ` [COMMITTED 33/35] ada: Redundant validity checks Marc Poulhiès
2024-05-16  9:26 ` [COMMITTED 34/35] ada: Reset scope of top level object declaration during unnesting Marc Poulhiès
2024-05-16  9:26 ` [COMMITTED 35/35] ada: Remove obsolete reference in comment Marc Poulhiès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240516092606.41242-25-poulhies@adacore.com \
    --to=poulhies@adacore.com \
    --cc=desplanques@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).