From 73764bae1d416524fc06e0f01f81c7274ec0937b Mon Sep 17 00:00:00 2001 From: Claire Dross Date: Tue, 21 Jul 2020 17:37:23 +0200 Subject: [PATCH] [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. --- gcc/ada/libgnat/a-cofove.adb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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; -- 2.30.2