aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaire Dross <dross@adacore.com>2020-07-21 17:37:23 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2020-10-21 03:22:43 -0400
commit73764bae1d416524fc06e0f01f81c7274ec0937b (patch)
tree2c2b4b1603887bf2adc5e1e115e2f14b0204d1c6
parent19e9cf7a1782100c1f8740c9ead67cc5d372b1c9 (diff)
downloadgcc-73764bae1d416524fc06e0f01f81c7274ec0937b.zip
gcc-73764bae1d416524fc06e0f01f81c7274ec0937b.tar.gz
gcc-73764bae1d416524fc06e0f01f81c7274ec0937b.tar.bz2
[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.
-rw-r--r--gcc/ada/libgnat/a-cofove.adb10
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/ada/libgnat/a-cofove.adb b/gcc/ada/libgnat/a-cofove.adb
index c8a60df..d467384 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;