aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/exp_util.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/exp_util.adb')
-rw-r--r--gcc/ada/exp_util.adb41
1 files changed, 41 insertions, 0 deletions
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 27d8233..e449d45 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -36,6 +36,7 @@ with Exp_Aggr; use Exp_Aggr;
with Exp_Ch6; use Exp_Ch6;
with Exp_Ch7; use Exp_Ch7;
with Exp_Ch11; use Exp_Ch11;
+with Exp_Dbug; use Exp_Dbug;
with Freeze; use Freeze;
with Ghost; use Ghost;
with Inline; use Inline;
@@ -13556,6 +13557,46 @@ package body Exp_Util is
return False;
end Requires_Cleanup_Actions;
+ --------------------------------------------
+ -- Rewrite_Object_Declaration_As_Renaming --
+ --------------------------------------------
+
+ procedure Rewrite_Object_Declaration_As_Renaming (N, Nam : Node_Id) is
+ Def_Id : constant Entity_Id := Defining_Identifier (N);
+ Loc : constant Source_Ptr := Sloc (N);
+
+ begin
+ Rewrite (N,
+ Make_Object_Renaming_Declaration (Loc,
+ Defining_Identifier => Def_Id,
+ Subtype_Mark => New_Occurrence_Of (Etype (Def_Id), Loc),
+ Name => Nam));
+
+ -- Keep original aspects
+
+ Move_Aspects (Original_Node (N), N);
+
+ -- We do not analyze this renaming declaration, because all its
+ -- components have already been analyzed, and if we were to go
+ -- ahead and analyze it, we would in effect be trying to generate
+ -- another declaration of X, which won't do.
+
+ Set_Renamed_Object (Def_Id, Nam);
+ Set_Analyzed (N);
+
+ -- We do need to deal with debug issues for this renaming
+
+ -- First, if entity comes from source, then mark it as needing
+ -- debug information, even though it is defined by a generated
+ -- renaming that does not come from source.
+
+ Set_Debug_Info_Defining_Id (N);
+
+ -- Now call the routine to generate debug info for the renaming
+
+ Insert_Action (N, Debug_Renaming_Declaration (N));
+ end Rewrite_Object_Declaration_As_Renaming;
+
------------------------------------
-- Safe_Unchecked_Type_Conversion --
------------------------------------