]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix spurious freezing error on nonabstract null extension
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 8 Feb 2023 15:26:46 +0000 (16:26 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Wed, 27 Sep 2023 08:16:25 +0000 (10:16 +0200)
This prevents the wrapper function created for each nonoverridden inherited
function with a controlling result of nonabstract null extensions of tagged
types from causing premature freezing of types referenced in its profile.

gcc/ada/

* exp_ch3.adb (Make_Controlling_Function_Wrappers): Create the body
as the expanded body of an expression function.

gcc/ada/exp_ch3.adb

index da4d52a3d168ad351c5cdfe0619202b9f7e269f2..3d546a8cb28e6e33a8e9f344113190824e1f4af9 100644 (file)
@@ -11109,9 +11109,10 @@ package body Exp_Ch3 is
                 Null_Record_Present => True);
 
             --  GNATprove will use expression of an expression function as an
-            --  implicit postcondition. GNAT will not benefit from expression
-            --  function (and would struggle if we add an expression function
-            --  to freezing actions).
+            --  implicit postcondition. GNAT will also benefit from expression
+            --  function to avoid premature freezing, but would struggle if we
+            --  added an expression function to freezing actions, so we create
+            --  the expanded form directly.
 
             if GNATprove_Mode then
                Func_Body :=
@@ -11130,6 +11131,7 @@ package body Exp_Ch3 is
                        Statements => New_List (
                          Make_Simple_Return_Statement (Loc,
                            Expression => Ext_Aggr))));
+               Set_Was_Expression_Function (Func_Body);
             end if;
 
             Append_To (Body_List, Func_Body);