From 74d09f3ee936c7e08539beba6f5bb2547b4640b9 Mon Sep 17 00:00:00 2001 From: Bob Duff Date: Thu, 30 Apr 2020 14:40:26 -0400 Subject: [PATCH] [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(-) diff --git a/gcc/ada/libgnat/a-ststbo.adb b/gcc/ada/libgnat/a-ststbo.adb index 3b31acc0a5d..4bd3c174254 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; ------------------- -- 2.30.2