]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] AI12-0339: Empty function for Aggregate aspect of Ada containers
authorEd Schonberg <schonberg@adacore.com>
Thu, 23 Jul 2020 15:51:39 +0000 (11:51 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 20 Oct 2020 07:21:52 +0000 (03:21 -0400)
gcc/ada/

* sinfo.ads, sinfo.adb: The flag Box_Present can appear in
Iterated_Element_Association nodes.
* sem_aggr.adb (Resolve_Aggregate): Call
Resolve_Container_Aggregate when type of context has
corresponding aspect.
* sem_type.adb (Covers): In Ada_2020 an aggregate is compatible
with a type that carries the corresponding aspect.
* exp_ch3.adb (Make_Controlling_Function_Wrappers): Do not
create declarations and bodies for inherited primitive functions
of null extensions that dispatch on result, when current scope
includes an immediately visible non-overloadable homonym of the
function.
* libgnat/a-cborse.adb, libgnat/a-cborse.ads,
libgnat/a-cbhase.ads, libgnat/a-cbhase.adb,
libgnat/a-cborma.adb, libgnat/a-cborma.ads,
libgnat/a-cbhama.adb, libgnat/a-cbhama.ads,
libgnat/a-cbdlli.adb, libgnat/a-cbdlli.ads,
libgnat/a-convec.ads, libgnat/a-ciorse.ads,
libgnat/a-cihase.ads, libgnat/a-cihase.adb,
libgnat/a-ciorma.ads, libgnat/a-cihama.ads,
libgnat/a-cihama.adb, libgnat/a-cidlli.ads,
libgnat/a-cidlli.adb, libgnat/a-coinve.adb,
libgnat/a-cobove.adb, libgnat/a-cobove.ads,
libgnat/a-convec.adb, libgnat/a-coinve.ads,
libgnat/a-coorse.ads, libgnat/a-cohase.adb,
libgnat/a-cohase.ads, libgnat/a-coorma.ads,
libgnat/a-cohama.adb, libgnat/a-cohama.ads,
libgnat/a-cdlili.ads: Add primitive function Empty for use in
aspect Aggregate, and add corresponding body or expression
function.

36 files changed:
gcc/ada/exp_ch3.adb
gcc/ada/libgnat/a-cbdlli.adb
gcc/ada/libgnat/a-cbdlli.ads
gcc/ada/libgnat/a-cbhama.adb
gcc/ada/libgnat/a-cbhama.ads
gcc/ada/libgnat/a-cbhase.adb
gcc/ada/libgnat/a-cbhase.ads
gcc/ada/libgnat/a-cborma.adb
gcc/ada/libgnat/a-cborma.ads
gcc/ada/libgnat/a-cborse.adb
gcc/ada/libgnat/a-cborse.ads
gcc/ada/libgnat/a-cdlili.ads
gcc/ada/libgnat/a-cidlli.adb
gcc/ada/libgnat/a-cidlli.ads
gcc/ada/libgnat/a-cihama.adb
gcc/ada/libgnat/a-cihama.ads
gcc/ada/libgnat/a-cihase.adb
gcc/ada/libgnat/a-cihase.ads
gcc/ada/libgnat/a-ciorma.ads
gcc/ada/libgnat/a-ciorse.ads
gcc/ada/libgnat/a-cobove.adb
gcc/ada/libgnat/a-cobove.ads
gcc/ada/libgnat/a-cohama.adb
gcc/ada/libgnat/a-cohama.ads
gcc/ada/libgnat/a-cohase.adb
gcc/ada/libgnat/a-cohase.ads
gcc/ada/libgnat/a-coinve.adb
gcc/ada/libgnat/a-coinve.ads
gcc/ada/libgnat/a-convec.adb
gcc/ada/libgnat/a-convec.ads
gcc/ada/libgnat/a-coorma.ads
gcc/ada/libgnat/a-coorse.ads
gcc/ada/sem_aggr.adb
gcc/ada/sem_type.adb
gcc/ada/sinfo.adb
gcc/ada/sinfo.ads

index 8b8462a846b58bd6cbf64739d3c0a06effd4b387..c5cc4965ed46ed5723fad32065e0f028b6a93e92 100644 (file)
@@ -9471,6 +9471,31 @@ package body Exp_Ch3 is
              (Is_Null_Extension (Etype (Subp))
                and then Etype (Alias (Subp)) /= Etype (Subp))
          then
+            --  If there is a non-overloadable homonym in the current
+            --  scope, the implicit declaration remains invisible.
+            --  We check the current entity with the same name, or its
+            --  homonym in case the derivation takes place after the
+            --  hiding object declaration.
+
+            if Present (Current_Entity (Subp)) then
+               declare
+                  Curr : constant Entity_Id := Current_Entity (Subp);
+                  Prev : constant Entity_Id := Homonym (Curr);
+               begin
+                  if (Comes_From_Source (Curr)
+                    and then Scope (Curr) = Current_Scope
+                    and then not Is_Overloadable (Curr))
+                  or else
+                    (Present (Prev)
+                      and then Comes_From_Source (Prev)
+                      and then Scope (Prev) = Current_Scope
+                      and then not Is_Overloadable (Prev))
+                  then
+                     goto Next_Prim;
+                  end if;
+               end;
+            end if;
+
             Formal_List := No_List;
             Formal := First_Formal (Subp);
 
index fa8174b5c3ff77401c4054b857d022356c75b813..a0c356d3adaa6209b98d4a54da9d6e8f194a1e2b 100644 (file)
@@ -518,6 +518,17 @@ is
       return Position.Container.Nodes (Position.Node).Element;
    end Element;
 
+   -----------
+   -- Empty --
+   -----------
+
+   function Empty (Capacity : Count_Type := 10) return List is
+   begin
+      return Result : List (Capacity) do
+         null;
+      end return;
+   end Empty;
+
    --------------
    -- Finalize --
    --------------
index 7e8627aeca8a907cb7e3637427f97f74013f3484..183c01e26dcf1cefa5af89523f6ec82fc9ee2add 100644 (file)
@@ -56,7 +56,7 @@ is
       Variable_Indexing => Reference,
       Default_Iterator  => Iterate,
       Iterator_Element  => Element_Type,
-      Aggregate         => (Empty        => Empty_List,
+      Aggregate         => (Empty        => Empty,
                             Add_Unnamed  => Append_One);
    pragma Preelaborable_Initialization (List);
 
@@ -67,6 +67,8 @@ is
 
    No_Element : constant Cursor;
 
+   function Empty (Capacity : Count_Type := 10) return List;
+
    function Has_Element (Position : Cursor) return Boolean;
 
    package List_Iterator_Interfaces is new
index b2137c1619b4ed751276726900ddb21f7e73612f..7f0c0e686c97dc545e23435a4ff544e864891165 100644 (file)
@@ -364,6 +364,17 @@ is
       return Position.Container.Nodes (Position.Node).Element;
    end Element;
 
+   -----------
+   -- Empty --
+   -----------
+
+   function Empty (Capacity : Count_Type) return Map is
+   begin
+      return Result : Map (Capacity, 0) do
+         null;
+      end return;
+   end Empty;
+
    -------------------------
    -- Equivalent_Key_Node --
    -------------------------
index 9a1aee97c4f6f222ad271fb0f0caf9326b6498f9..7a1d0f648ac2a8928badf3530e51d5adea59c94a 100644 (file)
@@ -58,7 +58,7 @@ is
       Variable_Indexing => Reference,
       Default_Iterator  => Iterate,
       Iterator_Element  => Element_Type,
-      Aggregate         => (Empty     => Empty_Map,
+      Aggregate         => (Empty     => Empty,
                             Add_Named => Insert);
 
    pragma Preelaborable_Initialization (Map);
@@ -70,6 +70,8 @@ is
    --  Map objects declared without an initialization expression are
    --  initialized to the value Empty_Map.
 
+   function Empty (Capacity : Count_Type) return Map;
+
    No_Element : constant Cursor;
    --  Cursor objects declared without an initialization expression are
    --  initialized to the value No_Element.
index db61f77f1cdabbef24597e25bceed3f9be82183d..293d722d202f66ad8c294c02adee19f12fc1e62f 100644 (file)
@@ -456,6 +456,17 @@ is
       end;
    end Element;
 
+   -----------
+   -- Empty --
+   -----------
+
+   function Empty (Capacity : Count_Type := 10) return Set is
+   begin
+      return Result : Set (Capacity, 0) do
+         Reserve_Capacity (Result, Capacity);
+      end return;
+   end Empty;
+
    ---------------------
    -- Equivalent_Sets --
    ---------------------
index 70a311931d5ebb96cc6c7a8517bcf588e0d8eabc..c82a123d9cd98e7da7be0bf05b2e9f189a2514eb 100644 (file)
@@ -60,7 +60,7 @@ is
      with Constant_Indexing => Constant_Reference,
           Default_Iterator  => Iterate,
           Iterator_Element  => Element_Type,
-          Aggregate         => (Empty       => Empty_Set,
+          Aggregate         => (Empty       => Empty,
                                 Add_Unnamed => Include);
 
    pragma Preelaborable_Initialization (Set);
@@ -72,6 +72,8 @@ is
    --  Set objects declared without an initialization expression are
    --  initialized to the value Empty_Set.
 
+   function Empty (Capacity : Count_Type := 10) return Set;
+
    No_Element : constant Cursor;
    --  Cursor objects declared without an initialization expression are
    --  initialized to the value No_Element.
index 23e21dac073c25828fe2b96a905826d7b2481360..54018479d685ce1ef72b00f68577f334cc07973b 100644 (file)
@@ -573,6 +573,17 @@ is
       return Container.Nodes (Node).Element;
    end Element;
 
+   -----------
+   -- Empty --
+   -----------
+
+   function Empty (Capacity : Count_Type := 10) return Map is
+   begin
+      return Result : Map (Capacity) do
+         null;
+      end return;
+   end Empty;
+
    ---------------------
    -- Equivalent_Keys --
    ---------------------
index b10b0d05edb59bd7b9b192e2721851dacfb49900..4da71bc151eba28af1f1b7efb0d2e3780b0620ac 100644 (file)
@@ -59,7 +59,7 @@ is
       Variable_Indexing => Reference,
       Default_Iterator  => Iterate,
       Iterator_Element  => Element_Type,
-      Aggregate         => (Empty     => Empty_Map,
+      Aggregate         => (Empty     => Empty,
                             Add_Named => Insert);
 
    pragma Preelaborable_Initialization (Map);
@@ -69,6 +69,8 @@ is
 
    Empty_Map : constant Map;
 
+   function Empty (Capacity : Count_Type := 10) return Map;
+
    No_Element : constant Cursor;
 
    function Has_Element (Position : Cursor) return Boolean;
index 2daad8e17da51fb297d7c88e7ee826b48f5f6819..e4a2de80c9bb82e30ebc1f9df19f0fc258548819 100644 (file)
@@ -549,6 +549,17 @@ is
       return Position.Container.Nodes (Position.Node).Element;
    end Element;
 
+   -----------
+   -- Empty --
+   -----------
+
+   function Empty (Capacity : Count_Type := 10) return Set is
+   begin
+      return Result : Set (Capacity) do
+         null;
+      end return;
+   end Empty;
+
    -------------------------
    -- Equivalent_Elements --
    -------------------------
index 90e68e3c4d02c9816780d2f757481365017da81a..92a6df7dd76e4a003a8e2902dfa36ee2f1e8d716 100644 (file)
@@ -58,7 +58,7 @@ is
    with Constant_Indexing => Constant_Reference,
         Default_Iterator  => Iterate,
         Iterator_Element  => Element_Type,
-        Aggregate         => (Empty       => Empty_Set,
+        Aggregate         => (Empty       => Empty,
                               Add_Unnamed => Include);
 
    pragma Preelaborable_Initialization (Set);
@@ -68,6 +68,8 @@ is
 
    Empty_Set : constant Set;
 
+   function Empty (Capacity : Count_Type := 10) return Set;
+
    No_Element : constant Cursor;
 
    function Has_Element (Position : Cursor) return Boolean;
index dc52564961929e6d97d1e47ea47df7f4f113d3ff..35c4352c8ca029b4288cc6b073dd74442d035289 100644 (file)
@@ -57,7 +57,7 @@ is
       Variable_Indexing => Reference,
       Default_Iterator  => Iterate,
       Iterator_Element  => Element_Type,
-      Aggregate         => (Empty       => Empty_List,
+      Aggregate         => (Empty       => Empty,
                             Add_Unnamed => Append_One);
 
    pragma Preelaborable_Initialization (List);
@@ -66,6 +66,7 @@ is
    pragma Preelaborable_Initialization (Cursor);
 
    Empty_List : constant List;
+   function Empty return List;
 
    No_Element : constant Cursor;
 
@@ -391,6 +392,7 @@ private
    --  Returns a pointer to the element designated by Position.
 
    Empty_List : constant List := (Controlled with others => <>);
+   function Empty return List is (Empty_List);
 
    No_Element : constant Cursor := Cursor'(null, null);
 
index 29286063d39c4c62eed4bce1d748e68693dff3f7..a62338f9665859818d5489908232d46a8238e89a 100644 (file)
@@ -185,6 +185,18 @@ is
       Insert (Container, No_Element, New_Item, Count);
    end Append;
 
+   ---------------
+   -- Append_One --
+   ---------------
+
+   procedure Append_One
+     (Container : in out List;
+      New_Item  : Element_Type)
+   is
+   begin
+      Insert (Container, No_Element, New_Item, 1);
+   end Append_One;
+
    ------------
    -- Assign --
    ------------
index fe9c7e10471ddbe94b15d6cdee8e018433272c3b..5e63cf22e89e0406511ff7be913cfac77a8aec96 100644 (file)
@@ -55,7 +55,9 @@ is
       Constant_Indexing => Constant_Reference,
       Variable_Indexing => Reference,
       Default_Iterator  => Iterate,
-      Iterator_Element  => Element_Type;
+      Iterator_Element  => Element_Type,
+      Aggregate         => (Empty       => Empty,
+                            Add_Unnamed => Append_One);
 
    pragma Preelaborable_Initialization (List);
 
@@ -63,6 +65,7 @@ is
    pragma Preelaborable_Initialization (Cursor);
 
    Empty_List : constant List;
+   function Empty return List;
 
    No_Element : constant Cursor;
 
@@ -146,6 +149,10 @@ is
       New_Item  : Element_Type;
       Count     : Count_Type := 1);
 
+   procedure Append_One
+     (Container : in out List;
+      New_Item  : Element_Type);
+
    procedure Delete
      (Container : in out List;
       Position  : in out Cursor;
@@ -376,6 +383,7 @@ private
    --  Returns a pointer to the element designated by Position.
 
    Empty_List : constant List := List'(Controlled with others => <>);
+   function Empty return List is (Empty_List);
 
    No_Element : constant Cursor := Cursor'(null, null);
 
index 2b4499c6eb5cd3ab5f7108bd4ad092b0776c20e8..64f662f332bd29a55687410cf15d0c9b02a94b35 100644 (file)
@@ -385,6 +385,17 @@ is
       return Position.Node.Element.all;
    end Element;
 
+   -----------
+   -- Empty --
+   -----------
+
+   function Empty (Capacity : Count_Type := 1000) return Map is
+   begin
+      return Result : Map do
+         Reserve_Capacity (Result, Capacity);
+      end return;
+   end Empty;
+
    -------------------------
    -- Equivalent_Key_Node --
    -------------------------
index f92331415d2de27d68380db6052a7ad0eb87fa27..ccf5f4e58ec3027fc81fd04a7fbd0d8624e02472 100644 (file)
@@ -58,7 +58,7 @@ is
       Variable_Indexing => Reference,
       Default_Iterator  => Iterate,
       Iterator_Element  => Element_Type,
-      Aggregate         => (Empty     => Empty_Map,
+      Aggregate         => (Empty     => Empty,
                             Add_Named => Insert);
 
    pragma Preelaborable_Initialization (Map);
@@ -70,6 +70,8 @@ is
    --  Map objects declared without an initialization expression are
    --  initialized to the value Empty_Map.
 
+   function Empty (Capacity : Count_Type := 1000) return Map;
+
    No_Element : constant Cursor;
    --  Cursor objects declared without an initialization expression are
    --  initialized to the value No_Element.
index dc0cfed58f81cf60f6ead7039421d210d03a369c..ebc9152dd62177489cfc0b78e4355216089b58d4 100644 (file)
@@ -506,6 +506,17 @@ is
       return Position.Node.Element.all;
    end Element;
 
+   -----------
+   -- Empty --
+   -----------
+
+   function Empty (Capacity : Count_Type := 1000) return Set is
+   begin
+      return Result : Set do
+         Reserve_Capacity (Result, Capacity);
+      end return;
+   end Empty;
+
    ---------------------
    -- Equivalent_Sets --
    ---------------------
index 965071cc39d0369059ea4a52e13e79ff4931b51b..cdfd86e35cc91c9ac8ad8839055dded45b827fc4 100644 (file)
@@ -60,7 +60,7 @@ is
      with Constant_Indexing => Constant_Reference,
           Default_Iterator  => Iterate,
           Iterator_Element  => Element_Type,
-          Aggregate         => (Empty       => Empty_Set,
+          Aggregate         => (Empty       => Empty,
                                 Add_Unnamed => Include);
 
    pragma Preelaborable_Initialization (Set);
@@ -72,6 +72,8 @@ is
    --  Set objects declared without an initialization expression are
    --  initialized to the value Empty_Set.
 
+   function Empty (Capacity : Count_Type := 1000) return Set;
+
    No_Element : constant Cursor;
    --  Cursor objects declared without an initialization expression are
    --  initialized to the value No_Element.
index dbc59488d2596a9dc9946a8d5d894172d1c795fb..17f5dfda5d7984861fb95d477d4f1102e3a748e7 100644 (file)
@@ -59,7 +59,7 @@ is
         Variable_Indexing => Reference,
         Default_Iterator  => Iterate,
         Iterator_Element  => Element_Type,
-        Aggregate         => (Empty     => Empty_Map,
+        Aggregate         => (Empty     => Empty,
                               Add_Named => Insert);
 
    pragma Preelaborable_Initialization (Map);
@@ -69,6 +69,8 @@ is
 
    Empty_Map : constant Map;
 
+   function Empty return Map;
+
    No_Element : constant Cursor;
    function Has_Element (Position : Cursor) return Boolean;
 
@@ -369,6 +371,7 @@ private
    --  Returns a pointer to the element designated by Position.
 
    Empty_Map : constant Map := (Controlled with others => <>);
+   function Empty return Map is (Empty_Map);
 
    No_Element : constant Cursor := Cursor'(null, null);
 
index b75a7a34cf3314679d062ce9dc6f7ebb53b5f0e2..1b6e3179cc0de22067803e379d9b3d3b215b0453 100644 (file)
@@ -58,7 +58,7 @@ is
       Constant_Indexing => Constant_Reference,
       Default_Iterator  => Iterate,
       Iterator_Element  => Element_Type,
-      Aggregate         => (Empty       => Empty_Set,
+      Aggregate         => (Empty       => Empty,
                             Add_Unnamed => Include);
 
    pragma Preelaborable_Initialization (Set);
@@ -67,6 +67,7 @@ is
    pragma Preelaborable_Initialization (Cursor);
 
    Empty_Set : constant Set;
+   function Empty  return Set;
 
    No_Element : constant Cursor;
 
@@ -448,6 +449,7 @@ private
    --  Returns a pointer to the element designated by Position.
 
    Empty_Set : constant Set := (Controlled with others => <>);
+   function Empty  return Set is (Empty_Set);
 
    No_Element : constant Cursor := Cursor'(null, null);
 
index ba105a2a59f6016b0bd95103bc989ebb81fc91a2..0408741b44f10d7e7be09be90fd115f05f45cbee 100644 (file)
@@ -708,6 +708,17 @@ package body Ada.Containers.Bounded_Vectors is
       end if;
    end Element;
 
+   -----------
+   -- Empty --
+   -----------
+
+   function Empty (Capacity : Count_Type := 10) return Vector is
+   begin
+      return Result : Vector (Capacity) do
+         Reserve_Capacity (Result, Capacity);
+      end return;
+   end Empty;
+
    --------------
    -- Finalize --
    --------------
index d0a125103056ded64fa59b154caa03568add8491..ab4ce4e2f9925c45fa2239504a1770e21605130d 100644 (file)
@@ -60,7 +60,7 @@ package Ada.Containers.Bounded_Vectors is
       Variable_Indexing => Reference,
       Default_Iterator  => Iterate,
       Iterator_Element  => Element_Type,
-      Aggregate         => (Empty          => Empty_Vector,
+      Aggregate         => (Empty          => Empty,
                             Add_Unnamed    => Append_One,
                             New_Indexed    => New_Vector,
                             Assign_Indexed => Replace_Element);
@@ -79,6 +79,8 @@ package Ada.Containers.Bounded_Vectors is
    package Vector_Iterator_Interfaces is new
       Ada.Iterator_Interfaces (Cursor, Has_Element);
 
+   function Empty (Capacity : Count_Type := 10) return Vector;
+
    overriding function "=" (Left, Right : Vector) return Boolean;
 
    function New_Vector (First, Last : Index_Type) return Vector
index 44bf3d5b72982cc576d8afdeb3cb3c078cd54714..1475330693d0fb2d0fe61aa64f80e4bb3d752194 100644 (file)
@@ -367,6 +367,17 @@ is
       return Position.Node.Element;
    end Element;
 
+   -----------
+   -- Empty --
+   -----------
+
+   function Empty (Capacity : Count_Type := 1000) return Map is
+   begin
+      return Result : Map do
+         Reserve_Capacity (Result, Capacity);
+      end return;
+   end Empty;
+
    -------------------------
    -- Equivalent_Key_Node --
    -------------------------
index cb5d2c5bf3e2b9195788539ae6d8407c5c74d1cf..21b69354db0284a53795092837bb589e22eb27e0 100644 (file)
@@ -102,7 +102,7 @@ is
       Variable_Indexing => Reference,
       Default_Iterator  => Iterate,
       Iterator_Element  => Element_Type,
-      Aggregate         => (Empty     => Empty_Map,
+      Aggregate         => (Empty     => Empty,
                             Add_Named => Insert);
 
    pragma Preelaborable_Initialization (Map);
@@ -118,6 +118,8 @@ is
    --  Cursor objects declared without an initialization expression are
    --  initialized to the value No_Element.
 
+   function Empty (Capacity : Count_Type := 1000) return Map;
+
    function Has_Element (Position : Cursor) return Boolean;
    --  Returns True if Position designates an element, and returns False
    --  otherwise.
index 4de3dacf714f882d44962fa51281a1b788e6d56e..63e44e12790e3cbd423c8f81fb84453079ba05fb 100644 (file)
@@ -468,6 +468,17 @@ is
       return Position.Node.Element;
    end Element;
 
+   -----------
+   -- Empty --
+   -----------
+
+   function Empty (Capacity : Count_Type := 1000) return Set is
+   begin
+      return Result : Set do
+         Reserve_Capacity (Result, Capacity);
+      end return;
+   end Empty;
+
    ---------------------
    -- Equivalent_Sets --
    ---------------------
index 451f592ce47b263c327f591fcc847809dba89294..a0aca526db96e4a15d228f2bc62f9a3468619d10 100644 (file)
@@ -61,7 +61,7 @@ is
       Constant_Indexing => Constant_Reference,
       Default_Iterator  => Iterate,
       Iterator_Element  => Element_Type,
-      Aggregate         => (Empty       => Empty_Set,
+      Aggregate         => (Empty       => Empty,
                             Add_Unnamed => Include);
 
    pragma Preelaborable_Initialization (Set);
@@ -83,6 +83,8 @@ is
    package Set_Iterator_Interfaces is new
      Ada.Iterator_Interfaces (Cursor, Has_Element);
 
+   function Empty (Capacity : Count_Type := 1000) return Set;
+
    function "=" (Left, Right : Set) return Boolean;
    --  For each element in Left, set equality attempts to find the equal
    --  element in Right; if a search fails, then set equality immediately
index 48e81f15cb0e8afc4b6d62aaa86d87f142714a3f..10711ffeca98e1eeb67a0520247f2ece5bfb8699 100644 (file)
@@ -745,6 +745,17 @@ is
       end;
    end Element;
 
+   -----------
+   -- Empty --
+   -----------
+
+   function Empty (Capacity : Count_Type := 10) return Vector is
+   begin
+      return Result : Vector do
+         Reserve_Capacity (Result, Capacity);
+      end return;
+   end Empty;
+
    --------------
    -- Finalize --
    --------------
index 1f15722319a4cdf55b4d26d21a7c6b7a95b79f66..593b63e8dca411b278454b6b81d9e06195c67ec0 100644 (file)
@@ -77,6 +77,8 @@ is
 
    No_Element : constant Cursor;
 
+   function Empty (Capacity : Count_Type := 10) return Vector;
+
    function Has_Element (Position : Cursor) return Boolean;
 
    package Vector_Iterator_Interfaces is new
index 0a793763500bd4454666253647c700b931b7d30a..a43be970e34f8468b0768e3d4cf8773262860b53 100644 (file)
@@ -614,6 +614,17 @@ is
       return Position.Container.Elements.EA (Position.Index);
    end Element;
 
+   -----------
+   -- Empty --
+   -----------
+
+   function Empty (Capacity : Count_Type := 10) return Vector is
+   begin
+      return Result : Vector do
+         Reserve_Capacity (Result, Capacity);
+      end return;
+   end Empty;
+
    --------------
    -- Finalize --
    --------------
index ebc90cf576617d669aeaa02791ad445c60830bac..f969e6f691e2e046f0af7a05f7d9f55b3a60630b 100644 (file)
@@ -94,7 +94,7 @@ is
       Variable_Indexing => Reference,
       Default_Iterator  => Iterate,
       Iterator_Element  => Element_Type,
-      Aggregate         => (Empty          => Empty_Vector,
+      Aggregate         => (Empty          => Empty,
                             Add_Unnamed    => Append_One,
                             New_Indexed    => New_Vector,
                             Assign_Indexed => Replace_Element);
@@ -122,6 +122,8 @@ is
    Empty_Vector : constant Vector;
    --  Empty_Vector represents the empty vector object. It has a length of 0.
 
+   function Empty (Capacity : Count_Type := 10) return Vector;
+
    overriding function "=" (Left, Right : Vector) return Boolean;
    --  If Left and Right denote the same vector object, then the function
    --  returns True. If Left and Right have different lengths, then the
index f80836e96eac84969264633944b2006264dc4789..7f65a7f3b37be0c1d4a2af5cb2e09a75e8199107 100644 (file)
@@ -59,13 +59,14 @@ is
       Variable_Indexing => Reference,
       Default_Iterator  => Iterate,
       Iterator_Element  => Element_Type,
-      Aggregate         => (Empty     => Empty_Map,
+      Aggregate         => (Empty     => Empty,
                             Add_Named => Insert);
 
    type Cursor is private;
    pragma Preelaborable_Initialization (Cursor);
 
    Empty_Map : constant Map;
+   function Empty return Map;
 
    No_Element : constant Cursor;
 
@@ -373,6 +374,7 @@ private
    --  Returns a pointer to the element designated by Position.
 
    Empty_Map : constant Map := (Controlled with others => <>);
+   function Empty return Map is (Empty_Map);
 
    No_Element : constant Cursor := Cursor'(null, null);
 
index a5577e9e85876897448d94728822ad4206cbea5d..1ccf290fbee00fbd96cf744f4cf9ed93901c9b10 100644 (file)
@@ -58,7 +58,7 @@ is
    with Constant_Indexing => Constant_Reference,
         Default_Iterator  => Iterate,
         Iterator_Element  => Element_Type;
-        --  Aggregate         => (Empty       => Empty_Set,
+        --  Aggregate         => (Empty       => Empty,
         --                        Add_Unnamed => Include);
 
    pragma Preelaborable_Initialization (Set);
@@ -69,6 +69,7 @@ is
    function Has_Element (Position : Cursor) return Boolean;
 
    Empty_Set : constant Set;
+   function Empty  return Set;
 
    No_Element : constant Cursor;
 
@@ -434,6 +435,7 @@ private
    --  Returns a pointer to the element designated by Position.
 
    Empty_Set : constant Set := (Controlled with others => <>);
+   function Empty  return Set is (Empty_Set);
 
    No_Element : constant Cursor := Cursor'(null, null);
 
index e5cdb4f9b118598abb4610a7b4335d89ab34ddd8..c7d1e49d91eda6e018f30f397b28710a80f5e65f 100644 (file)
@@ -899,6 +899,11 @@ package body Sem_Aggr is
       elsif Is_Array_Type (Typ) and then Null_Record_Present (N) then
          Error_Msg_N ("null record forbidden in array aggregate", N);
 
+      elsif Present (Find_Aspect (Typ, Aspect_Aggregate))
+        and then Ekind (Typ) /= E_Record_Type
+      then
+         Resolve_Container_Aggregate (N, Typ);
+
       elsif Is_Record_Type (Typ) then
          Resolve_Record_Aggregate (N, Typ);
 
index a5e62a72cd92d469d0f3237e69c1999a840a412f..3b1f48e02f7797fc81f75e1936e12444994487f4 100644 (file)
@@ -1009,6 +1009,15 @@ package body Sem_Type is
       elsif T2 = Any_Composite and then Is_Aggregate_Type (T1) then
          return True;
 
+      --  In Ada_2020, an aggregate is compatible with the type that
+      --  as the ccorrespoding aspect.
+
+      elsif Ada_Version >= Ada_2020
+        and then T2 = Any_Composite
+        and then Present (Find_Aspect (T1, Aspect_Aggregate))
+      then
+         return True;
+
       --  If the expected type is an anonymous access, the designated type must
       --  cover that of the expression. Use the base type for this check: even
       --  though access subtypes are rare in sources, they are generated for
index 065d3c6509bee9b0401ae1c941e6412c592923ee..82bc8a5623ae259e93ace7f59400902ee2d0df73 100644 (file)
@@ -368,7 +368,8 @@ package body Sinfo is
         or else NT (N).Nkind = N_Formal_Concrete_Subprogram_Declaration
         or else NT (N).Nkind = N_Formal_Package_Declaration
         or else NT (N).Nkind = N_Generic_Association
-        or else NT (N).Nkind = N_Iterated_Component_Association);
+        or else NT (N).Nkind = N_Iterated_Component_Association
+        or else NT (N).Nkind = N_Iterated_Element_Association);
       return Flag15 (N);
    end Box_Present;
 
@@ -3873,7 +3874,8 @@ package body Sinfo is
         or else NT (N).Nkind = N_Formal_Concrete_Subprogram_Declaration
         or else NT (N).Nkind = N_Formal_Package_Declaration
         or else NT (N).Nkind = N_Generic_Association
-        or else NT (N).Nkind = N_Iterated_Component_Association);
+        or else NT (N).Nkind = N_Iterated_Component_Association
+        or else NT (N).Nkind = N_Iterated_Element_Association);
       Set_Flag15 (N, Val);
    end Set_Box_Present;
 
index 4f0a41f01b1f32f84740e6dc52129fbfbdb49018..551f43f5a42271936b8eb87da160be3a2edab6b2 100644 (file)
@@ -4251,6 +4251,7 @@ package Sinfo is
       --  Expression (Node3)
       --  Loop_Parameter_Specification (Node4)
       --  Loop_Actions (List5-Sem)
+      --  Box_Present (Flag15)
 
       --  Exactly one of Iterator_Specification or Loop_Parameter_
       --  specification is present. If the Key_Expression is absent,