From: Bob Duff Date: Thu, 30 Apr 2020 18:40:26 +0000 (-0400) Subject: [Ada] AI12-0293-1 Remove pragma Assert X-Git-Tag: upstream/12.2.0~15416 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=74d09f3ee936c7e08539beba6f5bb2547b4640b9;p=platform%2Fupstream%2Fgcc.git [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". --- 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; -------------------