This patch fixes a bug in unnesting, which is used by the llvm back end.
Exp_Unst relies on the Scope field of nodes to detect up-level
references. Temps created by Prepend_Constructor_Procedure_Prologue
could have an incorrect Scope, causing Exp_Unst to use an up-level
reference to an activation record to implement up-level references. That
won't work; Exp_Unst is supposed to REMOVE up-level references.
This patch corrects the Scope of such temps.
gcc/ada/ChangeLog:
* exp_ch6.adb (Prepend_Constructor_Procedure_Prologue):
Push/Pop the procedure scope, so that temps created herein
get the right Scope.
procedure Prepend_Constructor_Procedure_Prologue
(Spec_Id : Entity_Id; Body_Id : Entity_Id; L : List_Id);
-
-- If N is the body of a constructor procedure (that is, a procedure
-- named in a Constructor aspect specification for the type of the
-- procedure's first parameter), then prepend and analyze the
return; -- the usual case
end if;
+ Push_Scope (Spec_Id);
+
-- Initialize the first parameter.
-- First_Param_Type is a record type (tagged or untagged) or
-- a type extension. If it is a type extension, then we begin by
Insert_List_Before_And_Analyze (First (L), Init_List);
end;
+
+ Pop_Scope;
end Prepend_Constructor_Procedure_Prologue;
-- Local variables