]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Error on Disable_Controlled aspect in Multiway_Trees
authorsquirek <squirek@adacore.com>
Mon, 30 Dec 2024 19:59:45 +0000 (19:59 +0000)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 9 Jan 2025 08:22:46 +0000 (09:22 +0100)
This patch fixes an issue in the compiler whereby instantiating Multiway_Trees
with a formal type leads to a compile-time error due to the expression supplied
for aspect Disable_Controlled specified on types decalred within
Multiway_Trees' body not being static.

gcc/ada/ChangeLog:

* libgnat/a-comutr.adb, libgnat/a-comutr.ads:
Move the declarations of iterator types into the specification and
add additional comments.

gcc/ada/libgnat/a-comutr.adb
gcc/ada/libgnat/a-comutr.ads

index e866e2ff895484d118ddac66c75dfa0c5fc52f6e..df3741bbbb07bba93ac495a9b9a4561ca42f4ba9 100644 (file)
@@ -41,55 +41,6 @@ is
    pragma Warnings (Off, "variable ""Lock*"" is not referenced");
    --  See comment in Ada.Containers.Helpers
 
-   --------------------
-   --  Root_Iterator --
-   --------------------
-
-   type Root_Iterator is abstract new Limited_Controlled and
-     Tree_Iterator_Interfaces.Forward_Iterator with
-   record
-      Container : Tree_Access;
-      Subtree   : Tree_Node_Access;
-   end record
-     with Disable_Controlled => not T_Check;
-
-   overriding procedure Finalize (Object : in out Root_Iterator);
-
-   -----------------------
-   --  Subtree_Iterator --
-   -----------------------
-
-   --  ??? these headers are a bit odd, but for sure they do not substitute
-   --  for documenting things, what *is* a Subtree_Iterator?
-
-   type Subtree_Iterator is new Root_Iterator with null record;
-
-   overriding function First (Object : Subtree_Iterator) return Cursor;
-
-   overriding function Next
-     (Object   : Subtree_Iterator;
-      Position : Cursor) return Cursor;
-
-   ---------------------
-   --  Child_Iterator --
-   ---------------------
-
-   type Child_Iterator is new Root_Iterator and
-     Tree_Iterator_Interfaces.Reversible_Iterator with null record
-       with Disable_Controlled => not T_Check;
-
-   overriding function First (Object : Child_Iterator) return Cursor;
-
-   overriding function Next
-     (Object   : Child_Iterator;
-      Position : Cursor) return Cursor;
-
-   overriding function Last (Object : Child_Iterator) return Cursor;
-
-   overriding function Previous
-     (Object   : Child_Iterator;
-      Position : Cursor) return Cursor;
-
    -----------------------
    -- Local Subprograms --
    -----------------------
index b6d006fd6263a52846029889055ccf091851c7ed..adc2cad8e5e53db713c16967a01486e86be3c9a6 100644 (file)
@@ -491,6 +491,45 @@ private
 
    for Reference_Type'Write use Write;
 
+   --  Base iterator type for shared functionality between Child_Iterator
+   --  and Subtree_Iterator - namely finalization.
+   type Root_Iterator is abstract new Limited_Controlled and
+     Tree_Iterator_Interfaces.Forward_Iterator with
+   record
+      Container : Tree_Access;
+      Subtree   : Tree_Node_Access;
+   end record
+     with Disable_Controlled => not T_Check;
+
+   overriding procedure Finalize (Object : in out Root_Iterator);
+
+   --  Iterator to handle traversal within a specific subtree.
+   type Subtree_Iterator is new Root_Iterator with null record;
+
+   overriding function First (Object : Subtree_Iterator) return Cursor;
+
+   overriding function Next
+     (Object   : Subtree_Iterator;
+      Position : Cursor) return Cursor;
+
+   --  Iterator to handle bidirectional traversal of a node's immediate
+   --  children for operations like reverse enumeration and selective
+   --  insertion.
+   type Child_Iterator is new Root_Iterator and
+     Tree_Iterator_Interfaces.Reversible_Iterator with null record
+       with Disable_Controlled => not T_Check;
+
+   overriding function First (Object : Child_Iterator) return Cursor;
+
+   overriding function Next
+     (Object   : Child_Iterator;
+      Position : Cursor) return Cursor;
+
+   overriding function Last (Object : Child_Iterator) return Cursor;
+
+   overriding function Previous
+     (Object   : Child_Iterator;
+      Position : Cursor) return Cursor;
    --  See Ada.Containers.Vectors for documentation on the following
 
    function Pseudo_Reference