[Ada] Wrong source locations in the profile of an instantiated subprogram
Arnaud Charlet
charlet@adacore.com
Mon Aug 4 07:56:00 GMT 2014
This patch modifies the formal subprogram instantiation machinery to preserve
the source locations of all formal parameters when creating the corresponding
renaming declaration. No reproducer as this requires ASIS.
Tested on x86_64-pc-linux-gnu, committed on trunk
2014-08-04 Hristian Kirtchev <kirtchev@adacore.com>
* sem_ch12.adb (Instantiate_Formal_Subprogram):
Move variable to their own section. Propagate the source
location of a formal parameter to the corresponding formal of
the subprogram renaming declaration. Code reformatting.
-------------- next part --------------
Index: sem_ch12.adb
===================================================================
--- sem_ch12.adb (revision 213530)
+++ sem_ch12.adb (working copy)
@@ -9454,14 +9454,10 @@
Actual : Node_Id;
Analyzed_Formal : Node_Id) return Node_Id
is
- Loc : Source_Ptr;
+ Analyzed_S : constant Entity_Id :=
+ Defining_Unit_Name (Specification (Analyzed_Formal));
Formal_Sub : constant Entity_Id :=
Defining_Unit_Name (Specification (Formal));
- Analyzed_S : constant Entity_Id :=
- Defining_Unit_Name (Specification (Analyzed_Formal));
- Decl_Node : Node_Id;
- Nam : Node_Id;
- New_Spec : Node_Id;
function From_Parent_Scope (Subp : Entity_Id) return Boolean;
-- If the generic is a child unit, the parent has been installed on the
@@ -9528,9 +9524,15 @@
("expect subprogram or entry name in instantiation of&",
Instantiation_Node, Formal_Sub);
Abandon_Instantiation (Instantiation_Node);
-
end Valid_Actual_Subprogram;
+ -- Local variables
+
+ Decl_Node : Node_Id;
+ Loc : Source_Ptr;
+ Nam : Node_Id;
+ New_Spec : Node_Id;
+
-- Start of processing for Instantiate_Formal_Subprogram
begin
@@ -9547,18 +9549,21 @@
Set_Defining_Unit_Name
(New_Spec, Make_Defining_Identifier (Loc, Chars (Formal_Sub)));
- -- Create new entities for the each of the formals in the
- -- specification of the renaming declaration built for the actual.
+ -- Create new entities for the each of the formals in the specification
+ -- of the renaming declaration built for the actual.
if Present (Parameter_Specifications (New_Spec)) then
declare
- F : Node_Id;
+ F : Node_Id;
+ F_Id : Entity_Id;
+
begin
F := First (Parameter_Specifications (New_Spec));
while Present (F) loop
+ F_Id := Defining_Identifier (F);
+
Set_Defining_Identifier (F,
- Make_Defining_Identifier (Sloc (F),
- Chars => Chars (Defining_Identifier (F))));
+ Make_Defining_Identifier (Sloc (F_Id), Chars (F_Id)));
Next (F);
end loop;
end;
@@ -9607,9 +9612,10 @@
-- identifier or operator with the same name as the formal.
if Nkind (Formal_Sub) = N_Defining_Operator_Symbol then
- Nam := Make_Operator_Symbol (Loc,
- Chars => Chars (Formal_Sub),
- Strval => No_String);
+ Nam :=
+ Make_Operator_Symbol (Loc,
+ Chars => Chars (Formal_Sub),
+ Strval => No_String);
else
Nam := Make_Identifier (Loc, Chars (Formal_Sub));
end if;
@@ -9656,9 +9662,7 @@
-- instance. If overloaded, it will be resolved when analyzing the
-- renaming declaration.
- if Box_Present (Formal)
- and then No (Actual)
- then
+ if Box_Present (Formal) and then No (Actual) then
Analyze (Nam);
if Is_Child_Unit (Scope (Analyzed_S))
More information about the Gcc-patches
mailing list