public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-1500] [Ada] ACATS 4.1R-c611a04: Class-wide preconditions in dispatching calls
Date: Wed, 16 Jun 2021 08:44:22 +0000 (GMT)	[thread overview]
Message-ID: <20210616084422.40A6E398A86D@sourceware.org> (raw)

https://gcc.gnu.org/g:cbb64f6b9ac870176700a2fa723a3b21a53b9b29

commit r12-1500-gcbb64f6b9ac870176700a2fa723a3b21a53b9b29
Author: Javier Miranda <miranda@adacore.com>
Date:   Thu Feb 18 13:47:10 2021 -0500

    [Ada] ACATS 4.1R-c611a04: Class-wide preconditions in dispatching calls
    
    gcc/ada/
    
            * exp_disp.adb (Build_Class_Wide_Check): Ensure that evaluation
            of actuals is side effects free (since the check duplicates
            actuals).

Diff:
---
 gcc/ada/exp_disp.adb | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb
index 20a32cd9576..eb6b352bef9 100644
--- a/gcc/ada/exp_disp.adb
+++ b/gcc/ada/exp_disp.adb
@@ -868,6 +868,7 @@ package body Exp_Disp is
 
          Str_Loc : constant String := Build_Location_String (Loc);
 
+         A    : Node_Id;
          Cond : Node_Id;
          Msg  : Node_Id;
          Prec : Node_Id;
@@ -900,6 +901,15 @@ package body Exp_Disp is
                return;
             end if;
 
+            --  Ensure that the evaluation of the actuals will not produce side
+            --  effects (since the check will use a copy of the actuals).
+
+            A := First_Actual (Call_Node);
+            while Present (A) loop
+               Remove_Side_Effects (A);
+               Next_Actual (A);
+            end loop;
+
             --  The expression for the precondition is analyzed within the
             --  generated pragma. The message text is the last parameter of
             --  the generated pragma, indicating source of precondition.


                 reply	other threads:[~2021-06-16  8:44 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=20210616084422.40A6E398A86D@sourceware.org \
    --to=pmderodat@gcc.gnu.org \
    --cc=gcc-cvs@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).