diff options
author | Javier Miranda <miranda@adacore.com> | 2022-02-27 11:42:46 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2022-05-13 08:04:39 +0000 |
commit | 6d22fb118f5c292c6c35c9177074485be0159810 (patch) | |
tree | 69a5efff7c73daaa761a5730856004b79e549ecb /gcc/ada/freeze.adb | |
parent | 17a89d82142be1fd9d9a8a584977f41204e13463 (diff) | |
download | gcc-6d22fb118f5c292c6c35c9177074485be0159810.zip gcc-6d22fb118f5c292c6c35c9177074485be0159810.tar.gz gcc-6d22fb118f5c292c6c35c9177074485be0159810.tar.bz2 |
[Ada] Ada ABI change when building with assertions
Compiling with and without assertions enabled the name of some generated
symbols differ; this is an issue when using pre-built libraries.
gcc/ada/
* freeze.adb (Check_Inherited_Conditions): Dispatch table
wrappers must be placed in the list of entities of their scope
at the same place of their wrapped primitive. This is required
for private types since these wrappers are built when their full
tagged type declaration is frozen but they may override a
primitive defined in the public part of the package (and it is
important to maintain the wrapper in the list of public entities
of the package to ensure their correct visibility).
Diffstat (limited to 'gcc/ada/freeze.adb')
-rw-r--r-- | gcc/ada/freeze.adb | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 25bad46..bc8d958 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -1981,6 +1981,9 @@ package body Freeze is DTW_Id : Entity_Id; DTW_Spec : Node_Id; + Prim_Next_E : constant Entity_Id := Next_Entity (Prim); + Prim_Prev_E : constant Entity_Id := Prev_Entity (Prim); + begin -- The wrapper must be analyzed in the scope of its wrapped -- primitive (to ensure its correct decoration). @@ -2049,9 +2052,46 @@ package body Freeze is Insert_Before_And_Analyze (Freeze_Node (R), DTW_Decl); else Append_Freeze_Action (R, DTW_Decl); + Analyze (DTW_Decl); end if; - Analyze (DTW_Decl); + -- The analyis of DTW_Decl has removed Prim from its scope + -- chain and added DTW_Id at the end of the scope chain. Move + -- DTW_Id to its correct place in the scope chain: the analysis + -- of the wrapper declaration has just added DTW_Id at the end + -- of the list of entities of its scope. However, given that + -- this wrapper overrides Prim, we must move DTW_Id to the + -- original place of Prim in its scope chain. This is required + -- for wrappers of private type primitives to ensure their + -- correct visibility since wrappers are built when the full + -- tagged type declaration is frozen (in the private part of + -- the package) but they may override primitives defined in the + -- public part of the package. + + declare + DTW_Prev_E : constant Entity_Id := Prev_Entity (DTW_Id); + + begin + pragma Assert (Last_Entity (Current_Scope) = DTW_Id); + pragma Assert + (Ekind (Current_Scope) not in E_Package | E_Generic_Package + or else No (First_Private_Entity (Current_Scope)) + or else First_Private_Entity (Current_Scope) /= DTW_Id); + + -- Remove DTW_Id from the end of the doubly-linked list of + -- entities of this scope; no need to handle removing it + -- from the beginning of the chain since such case can never + -- occur for this entity. + + Set_Last_Entity (Current_Scope, DTW_Prev_E); + Set_Next_Entity (DTW_Prev_E, Empty); + + -- Place DTW_Id back in the original place of its wrapped + -- primitive in the list of entities of this scope. + + Link_Entities (Prim_Prev_E, DTW_Id); + Link_Entities (DTW_Id, Prim_Next_E); + end; -- Insert the body of the wrapper in the freeze actions of -- its record type declaration to ensure that it is placed |