public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Eric Botcazou <ebotcazou@adacore.com>
Subject: [Ada] Fix incorrect Do_Range_Check on type conversion
Date: Mon, 12 Aug 2019 09:10:00 -0000	[thread overview]
Message-ID: <20190812090248.GA22475@adacore.com> (raw)

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

This gets rid of another leak of the Do_Range_Check flag to the back-end
which is specific to expression functions.  No functional changes.

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

2019-08-12  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

	* checks.adb (Activate_Range_Check): Remove redundant argument.
	(Generate_Range_Check): Likewise.
	(Apply_Float_Conversion_Check): Reset the Do_Range_Check flag on
	entry and remove redundant condition.

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

--- gcc/ada/checks.adb
+++ gcc/ada/checks.adb
@@ -445,7 +445,7 @@ package body Checks is
 
    procedure Activate_Range_Check (N : Node_Id) is
    begin
-      Set_Do_Range_Check (N, True);
+      Set_Do_Range_Check (N);
       Possible_Local_Raise (N, Standard_Constraint_Error);
    end Activate_Range_Check;
 
@@ -2031,6 +2031,12 @@ package body Checks is
          return;
       end if;
 
+      --  Here we will generate an explicit range check, so we don't want to
+      --  set the Do_Range check flag, since the range check is taken care of
+      --  by the code we will generate.
+
+      Set_Do_Range_Check (Ck_Node, False);
+
       if not Compile_Time_Known_Value (LB)
           or not Compile_Time_Known_Value (HB)
       then
@@ -2079,7 +2085,6 @@ package body Checks is
       if Nkind (Ck_Node) = N_Real_Literal
         and then Etype (Ck_Node) = Universal_Real
         and then Is_Integer_Type (Target_Typ)
-        and then Nkind (Parent (Ck_Node)) = N_Type_Conversion
       then
          declare
             Int_Val : constant Uint := UR_To_Uint (Realval (Ck_Node));
@@ -6936,7 +6941,7 @@ package body Checks is
       --  flag set, we do not want to generate the explicit range check code.
 
       if GNATprove_Mode or else not Expander_Active then
-         Set_Do_Range_Check (N, True);
+         Set_Do_Range_Check (N);
          return;
       end if;
 


                 reply	other threads:[~2019-08-12  9:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20190812090248.GA22475@adacore.com \
    --to=derodat@adacore.com \
    --cc=ebotcazou@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).