]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Restore parent link for both lists and nodes in class-wide condition
authorPiotr Trojanek <trojanek@adacore.com>
Mon, 3 Apr 2023 14:54:39 +0000 (16:54 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 29 May 2023 08:23:19 +0000 (10:23 +0200)
When preanalysing class-wide conditions, we restore "Function (Object)"
to its original "Object.Function" notation. This requires the Parent
links to be fixed. We did it for nodes; now we do it for lists as well.

This patch is enough to fix assertion failure in CCG and to make the
tree well-connected. Perhaps there is a more elegant solution, but that
remains to be investigated.

gcc/ada/

* contracts.adb (Fix_Parent): Fir part both for lists and nodes.

gcc/ada/contracts.adb

index 65f341abc8f20ebacb3a0875c9b38085eeb08826..15b65ee4c062f7dd55c7093a0e3501f81a3519fa 100644 (file)
@@ -4936,9 +4936,11 @@ package body Contracts is
 
             begin
                if Par /= Parent_Node then
-                  pragma Assert (not Is_List_Member (Node)
-                                   or else Nkind (Par) = N_Function_Call);
-                  Set_Parent (Node, Parent_Node);
+                  if Is_List_Member (Node) then
+                     Set_List_Parent (List_Containing (Node), Parent_Node);
+                  else
+                     Set_Parent (Node, Parent_Node);
+                  end if;
                end if;
 
                return OK;