aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/exp_spark.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/exp_spark.adb')
-rw-r--r--gcc/ada/exp_spark.adb32
1 files changed, 26 insertions, 6 deletions
diff --git a/gcc/ada/exp_spark.adb b/gcc/ada/exp_spark.adb
index 0fb5040..d1e97fc 100644
--- a/gcc/ada/exp_spark.adb
+++ b/gcc/ada/exp_spark.adb
@@ -31,6 +31,7 @@ with Exp_Util; use Exp_Util;
with Sem_Res; use Sem_Res;
with Sem_Util; use Sem_Util;
with Sinfo; use Sinfo;
+with Tbuild; use Tbuild;
package body Exp_SPARK is
@@ -117,16 +118,35 @@ package body Exp_SPARK is
-------------------------------
procedure Expand_Potential_Renaming (N : Node_Id) is
- E : constant Entity_Id := Entity (N);
- T : constant Entity_Id := Etype (N);
+ Id : constant Entity_Id := Entity (N);
+ Loc : constant Source_Ptr := Sloc (N);
+ Typ : constant Entity_Id := Etype (N);
+ Ren_Id : Node_Id;
begin
-- Replace a reference to a renaming with the actual renamed object
- if Ekind (E) in Object_Kind and then Present (Renamed_Object (E)) then
- Rewrite (N, New_Copy_Tree (Renamed_Object (E)));
- Reset_Analyzed_Flags (N);
- Analyze_And_Resolve (N, T);
+ if Ekind (Id) in Object_Kind then
+ Ren_Id := Renamed_Object (Id);
+
+ if Present (Ren_Id) then
+
+ -- The renamed object is an entity when instantiating generics
+ -- or inlining bodies. In this case the renaming is part of the
+ -- mapping "prologue" which links actuals to formals.
+
+ if Nkind (Ren_Id) in N_Entity then
+ Rewrite (N, New_Occurrence_Of (Ren_Id, Loc));
+
+ -- Otherwise the renamed object denotes a name
+
+ else
+ Rewrite (N, New_Copy_Tree (Ren_Id));
+ Reset_Analyzed_Flags (N);
+ end if;
+
+ Analyze_And_Resolve (N, Typ);
+ end if;
end if;
end Expand_Potential_Renaming;