From 23832bc7f13e9a430418a9096c768420c71e842c Mon Sep 17 00:00:00 2001 From: Bob Duff Date: Thu, 30 Apr 2020 14:40:26 -0400 Subject: [Ada] AI12-0293-1 Remove pragma Assert 2020-06-19 Bob Duff gcc/ada/ * libgnat/a-ststbo.adb (Write): Replace pragma Assert with "if ... raise Constraint_Error". --- gcc/ada/libgnat/a-ststbo.adb | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/libgnat/a-ststbo.adb b/gcc/ada/libgnat/a-ststbo.adb index 3b31acc..4bd3c17 100644 --- a/gcc/ada/libgnat/a-ststbo.adb +++ b/gcc/ada/libgnat/a-ststbo.adb @@ -79,16 +79,19 @@ package body Ada.Streams.Storage.Bounded is overriding procedure Write (Stream : in out Stream_Type; Item : Stream_Element_Array) is - pragma Assert - (Element_Count (Stream) + Item'Length <= Stream.Max_Elements - or else (raise Constraint_Error)); - -- That is a precondition in the RM - - New_Count : constant Stream_Element_Count := - Element_Count (Stream) + Item'Length; begin - Stream.Elements (Element_Count (Stream) + 1 .. New_Count) := Item; - Stream.Count := New_Count; + if Element_Count (Stream) + Item'Length > Stream.Max_Elements then + -- That is a precondition in the RM + raise Constraint_Error; + end if; + + declare + New_Count : constant Stream_Element_Count := + Element_Count (Stream) + Item'Length; + begin + Stream.Elements (Element_Count (Stream) + 1 .. New_Count) := Item; + Stream.Count := New_Count; + end; end Write; ------------------- -- cgit v1.1