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: Piotr Trojanek <trojanek@adacore.com>
Subject: [COMMITTED] ada: Only build access-to-subprogram wrappers when expander is active
Date: Tue, 30 May 2023 09:20:53 +0200	[thread overview]
Message-ID: <20230530072053.2499889-1-poulhies@adacore.com> (raw)

From: Piotr Trojanek <trojanek@adacore.com>

For access-to-subprogram types with Pre/Post aspects we create a wrapper
routine that evaluates these aspects. Spec of this wrapper was created
always, while its body was only created when expansion was enabled.

Now we only create these wrappers when expansion is enabled. In
particular, we don't create them in GNATprove mode; instead, GNATprove
picks the Pre/Post expressions directly from the aspects.

gcc/ada/

	* exp_ch3.adb
	(Build_Access_Subprogram_Wrapper_Body): Build wrapper body if requested
	by routine that builds wrapper spec.
	* sem_ch3.adb
	(Analyze_Full_Type_Declaration): Only build wrapper when expander is
	active.
	(Build_Access_Subprogram_Wrapper):
	Remove special-case for GNATprove.

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

---
 gcc/ada/exp_ch3.adb |  4 ----
 gcc/ada/sem_ch3.adb | 12 ++----------
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb
index 5f651bacafb..f8c99470dd7 100644
--- a/gcc/ada/exp_ch3.adb
+++ b/gcc/ada/exp_ch3.adb
@@ -583,10 +583,6 @@ package body Exp_Ch3 is
       Ptr       : Entity_Id;
 
    begin
-      if not Expander_Active then
-         return;
-      end if;
-
       --  Create List of actuals for indirect call. The last parameter of the
       --  subprogram declaration is the access value for the indirect call.
 
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index f360be810b4..29733e9d31f 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -3224,6 +3224,7 @@ package body Sem_Ch3 is
 
                if Ada_Version >= Ada_2022
                  and then Present (Aspect_Specifications (N))
+                 and then Expander_Active
                then
                   Build_Access_Subprogram_Wrapper (N);
                end if;
@@ -6915,16 +6916,7 @@ package body Sem_Ch3 is
       --  may be handled as a dispatching operation and erroneously registered
       --  in a dispatch table.
 
-      if not GNATprove_Mode then
-         Append_Freeze_Action (Id, New_Decl);
-
-      --  Under GNATprove mode there is no such problem but we do not declare
-      --  it in the freezing actions since they are not analyzed under this
-      --  mode.
-
-      else
-         Insert_After (Decl, New_Decl);
-      end if;
+      Append_Freeze_Action (Id, New_Decl);
 
       Set_Access_Subprogram_Wrapper (Designated_Type (Id), Subp);
       Build_Access_Subprogram_Wrapper_Body (Decl, New_Decl);
-- 
2.40.0


                 reply	other threads:[~2023-05-30  7: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=20230530072053.2499889-1-poulhies@adacore.com \
    --to=poulhies@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).