From: Claire Dross Date: Tue, 21 Jul 2020 15:37:23 +0000 (+0200) Subject: [Ada] Raise Capacity_Error on formal vector insertion X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=73764bae1d416524fc06e0f01f81c7274ec0937b;p=gcc.git [Ada] Raise Capacity_Error on formal vector insertion gcc/ada/ * libgnat/a-cofove.adb (Copy): Add explanation in case of Capacity_Error. (Insert_Space): Raise Capacity_Error if the new length is greater than the capacity. (Reserve_Capacity): Raise Capacity_Error instead of Constraint_Error. --- diff --git a/gcc/ada/libgnat/a-cofove.adb b/gcc/ada/libgnat/a-cofove.adb index c8a60df2a3d..d467384f242 100644 --- a/gcc/ada/libgnat/a-cofove.adb +++ b/gcc/ada/libgnat/a-cofove.adb @@ -171,7 +171,7 @@ is elsif Capacity >= LS then C := Capacity; else - raise Capacity_Error; + raise Capacity_Error with "Capacity too small"; end if; return Target : Vector (C) do @@ -956,6 +956,12 @@ is if New_Length > Max_Length then raise Constraint_Error with "Count is out of range"; + + -- Raise Capacity_Error if the new length exceeds the container's + -- capacity. + + elsif New_Length > Container.Capacity then + raise Capacity_Error with "New length is larger than capacity"; end if; J := To_Array_Index (Before); @@ -1104,7 +1110,7 @@ is is begin if Capacity > Container.Capacity then - raise Constraint_Error with "Capacity is out of range"; + raise Capacity_Error with "Capacity is out of range"; end if; end Reserve_Capacity;