diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2011-08-05 17:32:47 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2011-08-05 17:32:47 +0200 |
commit | 23b6decabf0a733a8d4aa3ebf452ac8ba4623fef (patch) | |
tree | f8390ea2012871d27ab62dacec81c19158fa933a /gcc/ada/a-comutr.adb | |
parent | 24911a5088aa3e48ff4e0cf0f731957b9cbfc28f (diff) | |
download | gcc-23b6decabf0a733a8d4aa3ebf452ac8ba4623fef.zip gcc-23b6decabf0a733a8d4aa3ebf452ac8ba4623fef.tar.gz gcc-23b6decabf0a733a8d4aa3ebf452ac8ba4623fef.tar.bz2 |
[multiple changes]
2011-08-05 Matthew Heaney <heaney@adacore.com>
* a-comutr.adb, a-cimutr.adb, a-cbmutr.adb (Read): do not use T'Valid
to check count, check sign of value instead.
* a-comutr.adb, a-cimutr.adb (Write): return immediately if tree empty
(Copy_Subtree): allocate copy of source element
(Equal_Subtree): compare elements, not access objects
2011-08-05 Vincent Celier <celier@adacore.com>
* gnat_ugn.texi: Fix VMS alternative.
From-SVN: r177457
Diffstat (limited to 'gcc/ada/a-comutr.adb')
-rw-r--r-- | gcc/ada/a-comutr.adb | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/gcc/ada/a-comutr.adb b/gcc/ada/a-comutr.adb index 7c7661d..dfe50c1 100644 --- a/gcc/ada/a-comutr.adb +++ b/gcc/ada/a-comutr.adb @@ -1681,7 +1681,11 @@ package body Ada.Containers.Multiway_Trees is function Read_Subtree (Parent : Tree_Node_Access) return Tree_Node_Access; - Total_Count, Read_Count : Count_Type; + Total_Count : Count_Type'Base; + -- Value read from the stream that says how many elements follow + + Read_Count : Count_Type'Base; + -- Actual number of elements read from the stream ------------------- -- Read_Children -- @@ -1692,13 +1696,15 @@ package body Ada.Containers.Multiway_Trees is pragma Assert (Subtree.Children.First = null); pragma Assert (Subtree.Children.Last = null); - Count : Count_Type; -- number of child subtrees - C : Children_Type; + Count : Count_Type'Base; + -- Number of child subtrees + + C : Children_Type; begin Count_Type'Read (Stream, Count); - if not Count'Valid then -- Is this check necessary??? + if Count < 0 then raise Program_Error with "attempt to read from corrupt stream"; end if; @@ -1749,7 +1755,7 @@ package body Ada.Containers.Multiway_Trees is Count_Type'Read (Stream, Total_Count); - if not Total_Count'Valid then -- Is this check necessary??? + if Total_Count < 0 then raise Program_Error with "attempt to read from corrupt stream"; end if; @@ -2428,6 +2434,11 @@ package body Ada.Containers.Multiway_Trees is begin Count_Type'Write (Stream, Container.Count); + + if Container.Count = 0 then + return; + end if; + Write_Children (Root_Node (Container)); end Write; |