]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Only build access-to-subprogram wrappers when expander is active
authorPiotr Trojanek <trojanek@adacore.com>
Tue, 11 Apr 2023 22:19:23 +0000 (00:19 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 30 May 2023 07:12:16 +0000 (09:12 +0200)
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.

gcc/ada/exp_ch3.adb
gcc/ada/sem_ch3.adb

index 5f651bacafb1bbc048d3cd36b26caeee4bddf61e..f8c99470dd7504ea812e1655fc3b87d4f19f7969 100644 (file)
@@ -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.
 
index f360be810b432159b246aab536cf1a83480338e7..29733e9d31fd9c710d1e213d0a852f1002287f86 100644 (file)
@@ -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);