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: Piotr Trojanek <trojanek@adacore.com>
Subject: [Ada] Remove unnecessary parameter of Apply_Compile_Time_Constraint_Error
Date: Wed, 5 May 2021 04:20:04 -0400	[thread overview]
Message-ID: <20210505082004.GA31179@adacore.com> (raw)

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

In routine Apply_Compile_Time_Constraint_Error the Rep parameter was
disabling rewriting into N_Raise_Constraint_Error node. It is only
referenced when this routine is called from GNATprove, but in
GNATprove_Mode rewriting is disabled anyway.

It seems cleaner to remove this parameter and keep this routine as
simple as possible.

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

gcc/ada/

	* sem_util.ads (Apply_Compile_Time_Constraint_Error): Remove
	parameter Rep from the function spec and "and if the flag Rep is
	set" from the comment.
	* sem_util.adb (Apply_Compile_Time_Constraint_Error): Remove
	parameter Rep.

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

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
@@ -1412,7 +1412,6 @@ package body Sem_Util is
       Ent    : Entity_Id  := Empty;
       Typ    : Entity_Id  := Empty;
       Loc    : Source_Ptr := No_Location;
-      Rep    : Boolean    := True;
       Warn   : Boolean    := False)
    is
       Stat   : constant Boolean := Is_Static_Expression (N);
@@ -1436,7 +1435,7 @@ package body Sem_Util is
       --  a few cases where a suitable check flag is set for GNATprove to
       --  generate a check message.
 
-      if not Rep or GNATprove_Mode then
+      if GNATprove_Mode then
          return;
       end if;
 


diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads
--- a/gcc/ada/sem_util.ads
+++ b/gcc/ada/sem_util.ads
@@ -162,7 +162,6 @@ package Sem_Util is
       Ent    : Entity_Id  := Empty;
       Typ    : Entity_Id  := Empty;
       Loc    : Source_Ptr := No_Location;
-      Rep    : Boolean    := True;
       Warn   : Boolean    := False);
    --  N is a subexpression that will raise Constraint_Error when evaluated
    --  at run time. Msg is a message that explains the reason for raising the
@@ -171,21 +170,20 @@ package Sem_Util is
    --  (because of violation of static expression rules) in Ada 95 (but not
    --  in Ada 83). Typically this routine posts all messages at the Sloc of
    --  node N. However, if Loc /= No_Location, Loc is the Sloc used to output
-   --  the message. After posting the appropriate message, and if the flag
-   --  Rep is set, this routine replaces the expression with an appropriate
-   --  N_Raise_Constraint_Error node using the given Reason code. This node
-   --  is then marked as being static if the original node is static, but
-   --  sets the flag Raises_Constraint_Error, preventing further evaluation.
-   --  The error message may contain a } or & insertion character. This
-   --  normally references Etype (N), unless the Ent argument is given
-   --  explicitly, in which case it is used instead. The type of the raise
-   --  node that is built is normally Etype (N), but if the Typ parameter
-   --  is present, this is used instead. Warn is normally False. If it is
-   --  True then the message is treated as a warning even though it does
-   --  not end with a ? (this is used when the caller wants to parameterize
-   --  whether an error or warning is given), or when the message should be
-   --  treated as a warning even when SPARK_Mode is On (which otherwise would
-   --  force an error).
+   --  the message. After posting the appropriate message, this routine
+   --  replaces the expression with an appropriate N_Raise_Constraint_Error
+   --  node using the given Reason code. This node is then marked as being
+   --  static if the original node is static, but sets the flag
+   --  Raises_Constraint_Error, preventing further evaluation. The error
+   --  message may contain a } or & insertion character. This normally
+   --  references Etype (N), unless the Ent argument is given explicitly, in
+   --  which case it is used instead. The type of the raise node that is built
+   --  is normally Etype (N), but if the Typ parameter is present, this is used
+   --  instead. Warn is normally False. If it is True then the message is
+   --  treated as a warning even though it does not end with a ? (this is used
+   --  when the caller wants to parameterize whether an error or warning is
+   --  given), or when the message should be treated as a warning even when
+   --  SPARK_Mode is On (which otherwise would force an error).
 
    function Async_Readers_Enabled (Id : Entity_Id) return Boolean;
    --  Id should be the entity of a state abstraction, an object, or a type.



                 reply	other threads:[~2021-05-05  8:20 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=20210505082004.GA31179@adacore.com \
    --to=derodat@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=trojanek@adacore.com \
    /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).