From: Eric Botcazou <[email protected]>
The change unnecessarily prevents the profile of all dispatching operations
from being frozen by their subprogram body, which exposes a weakness in the
implementation of freezing for generic units. This just reverts that part.
gcc/ada/ChangeLog:
PR ada/93702
* exp_ch3.adb (Make_Controlling_Function_Wrappers): Revert latest
change.
* sem_ch12.adb (Analyze_One_Association): Remove redundant line.
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Freeze the profile
again for bodies that are not generated from expression functions.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/exp_ch3.adb | 6 +++++-
gcc/ada/sem_ch12.adb | 1 -
gcc/ada/sem_ch6.adb | 4 +++-
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb
index d1956c1a1be..1b7b4aae653 100644
--- a/gcc/ada/exp_ch3.adb
+++ b/gcc/ada/exp_ch3.adb
@@ -11683,7 +11683,10 @@ package body Exp_Ch3 is
Null_Record_Present => True);
-- GNATprove will use expression of an expression function as an
- -- implicit postcondition.
+ -- 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 :=
@@ -11702,6 +11705,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);
diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb
index 402aa216427..e25d9c67fce 100644
--- a/gcc/ada/sem_ch12.adb
+++ b/gcc/ada/sem_ch12.adb
@@ -2455,7 +2455,6 @@ package body Sem_Ch12 is
if Is_Expression_Function (Node (Elmt)) then
Expr := New_Occurrence_Of (Node (Elmt), Sloc (N));
Set_Comes_From_Source (Expr);
- Set_Entity (Expr, Node (Elmt));
Set_Parent (Expr, N);
Freeze_Expression (Expr);
else
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index d898fb40997..514ab6eb618 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -3848,7 +3848,9 @@ package body Sem_Ch6 is
Set_Has_Delayed_Freeze (Spec_Id);
Create_Extra_Formals (Spec_Id, Related_Nod => N);
Freeze_Before (N, Spec_Id,
- Do_Freeze_Profile => not Is_Dispatching_Operation (Spec_Id));
+ Do_Freeze_Profile => not
+ (From_Expression_Function
+ and then Is_Dispatching_Operation (Spec_Id)));
end if;
end if;
--
2.53.0