]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] If unnesting and relocating subprogram call, make new Parameter_Associations
authorRichard Kenner <kenner@adacore.com>
Tue, 27 Jul 2021 16:23:23 +0000 (12:23 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 23 Sep 2021 13:06:14 +0000 (13:06 +0000)
gcc/ada/

* atree.adb (Relocate_Node): If relocating a subprgram call and
we're doing unnesting, make a new Parameter_Associations, if
any.

gcc/ada/atree.adb

index 00565d66d85c0a76f02334c3ea5613698d0616ca..e7fa8e05c3f95bb3c708bad2b6997d79e89eec05 100644 (file)
@@ -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;