aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/exp_ch8.adb
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2023-06-23 19:01:05 +0200
committerMarc Poulhiès <poulhies@adacore.com>2023-07-03 15:26:13 +0200
commit37449332ddb5d34ac1cb4f25b0d8b5ba2ad9d0f4 (patch)
treef4d8af80f045ce9605958c3316a5861429cbaa57 /gcc/ada/exp_ch8.adb
parentabc202d8c58e75940e27b324756c68504965f0ee (diff)
downloadgcc-37449332ddb5d34ac1cb4f25b0d8b5ba2ad9d0f4.zip
gcc-37449332ddb5d34ac1cb4f25b0d8b5ba2ad9d0f4.tar.gz
gcc-37449332ddb5d34ac1cb4f25b0d8b5ba2ad9d0f4.tar.bz2
ada: Fix renaming of predefined equality operator for unchecked union types
The problem is that the predefined equality operator for unchecked union types is implemented out of line by invoking a function that takes more parameters than the two operands, which means that the renaming is not seen as type conforming with this function and, therefore, is rejected. The way out is to implement these additional parameters as "extra" formal parameters, since this kind of parameters is not taken into account for semantic checks. The change also factors out the duplicated generation of actuals for these additional parameters into a single procedure. gcc/ada/ * exp_ch3.ads (Build_Variant_Record_Equality): Add Spec_Id as second parameter. * exp_ch3.adb (Build_Variant_Record_Equality): For unchecked union types, build the additional parameters as extra formal parameters. (Expand_Freeze_Record_Type.Build_Variant_Record_Equality): Pass Empty as Spec_Id in call to Build_Variant_Record_Equality. * exp_ch4.ads (Expand_Unchecked_Union_Equality): New procedure. * exp_ch4.adb (Expand_Composite_Equality): In the presence of a function implementing composite equality, do not special case the unchecked union types, and only convert the operands if the base types are not the same like in Build_Equality_Call. (Build_Equality_Call): Do not special case the unchecked union types and relocate the operands only once. (Expand_N_Op_Eq): Do not special case the unchecked union types. (Expand_Unchecked_Union_Equality): New procedure implementing the specific expansion of calls to the predefined equality function. * exp_ch6.adb (Is_Unchecked_Union_Equality): New predicate. (Expand_Call): Call Is_Unchecked_Union_Equality to determine whether to call Expand_Unchecked_Union_Equality or Expand_Call_Helper. * exp_ch8.adb (Build_Body_For_Renaming): Set Has_Delayed_Freeze flag earlier on Id and pass Id in call to Build_Variant_Record_Equality.
Diffstat (limited to 'gcc/ada/exp_ch8.adb')
-rw-r--r--gcc/ada/exp_ch8.adb3
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/ada/exp_ch8.adb b/gcc/ada/exp_ch8.adb
index 09c364c..411e5db 100644
--- a/gcc/ada/exp_ch8.adb
+++ b/gcc/ada/exp_ch8.adb
@@ -294,10 +294,10 @@ package body Exp_Ch8 is
begin
Set_Alias (Id, Empty);
Set_Has_Completion (Id, False);
+ Set_Has_Delayed_Freeze (Id);
Rewrite (N,
Make_Subprogram_Declaration (Loc,
Specification => Specification (N)));
- Set_Has_Delayed_Freeze (Id);
Body_Id := Make_Defining_Identifier (Loc, Chars (Id));
Set_Debug_Info_Needed (Body_Id);
@@ -306,6 +306,7 @@ package body Exp_Ch8 is
Decl :=
Build_Variant_Record_Equality
(Typ => Typ,
+ Spec_Id => Id,
Body_Id => Body_Id,
Param_Specs => Copy_Parameter_List (Id));