When unnesting, we may add static links to the actual parameters. This
will cause duplication if a the Parameter_Associations list is shared,
so ensure that we make a new one in this situation.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* atree.adb (Relocate_Node): If relocating a subprgram call and
we're doing unnesting, make a new Parameter_Associations, if
any.
diff --git a/gcc/ada/atree.adb b/gcc/ada/atree.adb
--- a/gcc/ada/atree.adb
+++ b/gcc/ada/atree.adb
@@ -1962,6 +1962,22 @@ package body Atree is
Set_Original_Node (New_Node, Original_Node (Source));
end if;
+ -- If we're relocating a subprogram call and we're doing
+ -- unnesting, be sure we make a new copy of any parameter associations
+ -- so that we don't share them.
+
+ if Nkind (Source) in N_Subprogram_Call
+ and then Opt.Unnest_Subprogram_Mode
+ and then Present (Parameter_Associations (Source))
+ then
+ declare
+ New_Assoc : constant List_Id := Parameter_Associations (Source);
+ begin
+ Set_Parent (New_Assoc, New_Node);
+ Set_Parameter_Associations (New_Node, New_Assoc);
+ end;
+ end if;
+
return New_Node;
end Relocate_Node;