summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2011-08-05 17:32:47 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2011-08-05 17:32:47 +0200
commit23b6decabf0a733a8d4aa3ebf452ac8ba4623fef (patch)
treef8390ea2012871d27ab62dacec81c19158fa933a
parent24911a5088aa3e48ff4e0cf0f731957b9cbfc28f (diff)
downloadgcc-23b6decabf0a733a8d4aa3ebf452ac8ba4623fef.tar.gz
[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
-rw-r--r--gcc/ada/ChangeLog12
-rw-r--r--gcc/ada/a-cbmutr.adb16
-rw-r--r--gcc/ada/a-cimutr.adb24
-rw-r--r--gcc/ada/a-comutr.adb21
-rw-r--r--gcc/ada/gnat_ugn.texi2
5 files changed, 57 insertions, 18 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 3ca2a71c1df..061010c533f 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,15 @@
+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.
+
2011-08-05 Thomas Quinot <quinot@adacore.com>
* sem_ch11.adb: Add comment.
diff --git a/gcc/ada/a-cbmutr.adb b/gcc/ada/a-cbmutr.adb
index 6e22e0e8756..1392a4fdc17 100644
--- a/gcc/ada/a-cbmutr.adb
+++ b/gcc/ada/a-cbmutr.adb
@@ -2117,20 +2117,26 @@ package body Ada.Containers.Bounded_Multiway_Trees is
NN : Tree_Node_Array renames Container.Nodes;
- 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 --
-------------------
procedure Read_Children (Subtree : Count_Type) is
- Count : Count_Type; -- number of child subtrees
- CC : Children_Type;
+ Count : Count_Type'Base;
+ -- number of child subtrees
+
+ CC : 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;
@@ -2180,7 +2186,7 @@ package body Ada.Containers.Bounded_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;
diff --git a/gcc/ada/a-cimutr.adb b/gcc/ada/a-cimutr.adb
index 1e035ec62f7..d5736fc3ffe 100644
--- a/gcc/ada/a-cimutr.adb
+++ b/gcc/ada/a-cimutr.adb
@@ -556,8 +556,10 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
Target : out Tree_Node_Access;
Count : in out Count_Type)
is
+ E : constant Element_Access := new Element_Type'(Source.Element.all);
+
begin
- Target := new Tree_Node_Type'(Element => Source.Element,
+ Target := new Tree_Node_Type'(Element => E,
Parent => Parent,
others => <>);
@@ -886,7 +888,7 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
Right_Subtree : Tree_Node_Access) return Boolean
is
begin
- if Left_Subtree.Element /= Right_Subtree.Element then
+ if Left_Subtree.Element.all /= Right_Subtree.Element.all then
return False;
end if;
@@ -1638,8 +1640,11 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
function Read_Subtree
(Parent : Tree_Node_Access) return Tree_Node_Access;
- Total_Count : Count_Type;
- 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 --
@@ -1650,7 +1655,7 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
pragma Assert (Subtree.Children.First = null);
pragma Assert (Subtree.Children.Last = null);
- Count : Count_Type;
+ Count : Count_Type'Base;
-- Number of child subtrees
C : Children_Type;
@@ -1658,7 +1663,7 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
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;
@@ -1712,7 +1717,7 @@ package body Ada.Containers.Indefinite_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;
@@ -2383,6 +2388,11 @@ package body Ada.Containers.Indefinite_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;
diff --git a/gcc/ada/a-comutr.adb b/gcc/ada/a-comutr.adb
index 7c7661d7e4f..dfe50c18f4e 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;
diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi
index 48725cff908..7f2d655540e 100644
--- a/gcc/ada/gnat_ugn.texi
+++ b/gcc/ada/gnat_ugn.texi
@@ -6312,7 +6312,7 @@ example:
@item ^C^COMMENTS1^ (single space)
@emph{Check comments, single space.}
-This is identical to @code{^c^COMMENTS} except that only one space
+This is identical to @code{^c^COMMENTS^} except that only one space
is required following the @code{--} of a comment instead of two.
@item ^d^DOS_LINE_ENDINGS^