Commit ce72a9a3 by Arnaud Charlet

[multiple changes]

2011-10-06  Robert Dewar  <dewar@adacore.com>

	* a-ciorse.adb, a-cihase.adb, a-cihase.ads, a-coorse.adb,
	a-cborse.adb, a-comutr.adb, a-ciorma.adb, a-cbmutr.adb,
	a-cbmutr.ads, a-cbhase.adb, a-cbhase.ads: Minor reformatting and code
	reorganization (use conditional expressions).

2011-10-06  Robert Dewar  <dewar@adacore.com>

	* sem_res.adb (Resolve_Arithmetic_Op): Fix bad warning for
	floating divide by zero.

2011-10-06  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch6.adb: Limited interfaces that are not immutably limited
	are OK in return statements.

From-SVN: r179629
parent 908e19d0
2011-10-06 Robert Dewar <dewar@adacore.com>
* a-ciorse.adb, a-cihase.adb, a-cihase.ads, a-coorse.adb,
a-cborse.adb, a-comutr.adb, a-ciorma.adb, a-cbmutr.adb,
a-cbmutr.ads, a-cbhase.adb, a-cbhase.ads: Minor reformatting and code
reorganization (use conditional expressions).
2011-10-06 Robert Dewar <dewar@adacore.com>
* sem_res.adb (Resolve_Arithmetic_Op): Fix bad warning for
floating divide by zero.
2011-10-06 Ed Schonberg <schonberg@adacore.com>
* sem_ch6.adb: Limited interfaces that are not immutably limited
are OK in return statements.
2011-09-30 Iain Sandoe <iains@gcc.gnu.org>
* gcc-interface/Makefile.in (Darwin): Partial reversion of previous
......
......@@ -47,7 +47,7 @@ package body Ada.Containers.Bounded_Hashed_Sets is
overriding function First (Object : Iterator) return Cursor;
overriding function Next
(Object : Iterator;
(Object : Iterator;
Position : Cursor) return Cursor;
-----------------------
......@@ -68,9 +68,7 @@ package body Ada.Containers.Bounded_Hashed_Sets is
Node : out Count_Type;
Inserted : out Boolean);
function Is_In
(HT : Set;
Key : Node_Type) return Boolean;
function Is_In (HT : Set; Key : Node_Type) return Boolean;
pragma Inline (Is_In);
procedure Set_Element (Node : in out Node_Type; Item : Element_Type);
......@@ -169,7 +167,6 @@ package body Ada.Containers.Bounded_Hashed_Sets is
N : Node_Type renames Source.Nodes (Source_Node);
X : Count_Type;
B : Boolean;
begin
Insert (Target, N.Element, X, B);
pragma Assert (B);
......@@ -233,10 +230,8 @@ package body Ada.Containers.Bounded_Hashed_Sets is
begin
if Capacity = 0 then
C := Source.Length;
elsif Capacity >= Source.Length then
C := Capacity;
else
raise Capacity_Error with "Capacity value too small";
end if;
......@@ -396,7 +391,6 @@ package body Ada.Containers.Bounded_Hashed_Sets is
N : Node_Type renames Left.Nodes (L_Node);
X : Count_Type;
B : Boolean;
begin
if not Is_In (Right, N) then
Insert (Result, N.Element, X, B); -- optimize this ???
......@@ -428,7 +422,6 @@ package body Ada.Containers.Bounded_Hashed_Sets is
declare
S : Set renames Position.Container.all;
N : Node_Type renames S.Nodes (Position.Node);
begin
return N.Element;
end;
......@@ -488,6 +481,7 @@ package body Ada.Containers.Bounded_Hashed_Sets is
function Equivalent_Elements (Left, Right : Cursor)
return Boolean is
begin
if Left.Node = 0 then
raise Constraint_Error with
......@@ -505,14 +499,15 @@ package body Ada.Containers.Bounded_Hashed_Sets is
declare
LN : Node_Type renames Left.Container.Nodes (Left.Node);
RN : Node_Type renames Right.Container.Nodes (Right.Node);
begin
return Equivalent_Elements (LN.Element, RN.Element);
end;
end Equivalent_Elements;
function Equivalent_Elements (Left : Cursor; Right : Element_Type)
return Boolean is
function Equivalent_Elements
(Left : Cursor;
Right : Element_Type) return Boolean
is
begin
if Left.Node = 0 then
raise Constraint_Error with
......@@ -528,8 +523,10 @@ package body Ada.Containers.Bounded_Hashed_Sets is
end;
end Equivalent_Elements;
function Equivalent_Elements (Left : Element_Type; Right : Cursor)
return Boolean is
function Equivalent_Elements
(Left : Element_Type;
Right : Cursor) return Boolean
is
begin
if Right.Node = 0 then
raise Constraint_Error with
......@@ -551,8 +548,10 @@ package body Ada.Containers.Bounded_Hashed_Sets is
-- Equivalent_Keys --
---------------------
function Equivalent_Keys (Key : Element_Type; Node : Node_Type)
return Boolean is
function Equivalent_Keys
(Key : Element_Type;
Node : Node_Type) return Boolean
is
begin
return Equivalent_Elements (Key, Node.Element);
end Equivalent_Keys;
......@@ -580,13 +579,9 @@ package body Ada.Containers.Bounded_Hashed_Sets is
Item : Element_Type) return Cursor
is
Node : constant Count_Type := Element_Keys.Find (Container, Item);
begin
if Node = 0 then
return No_Element;
end if;
return Cursor'(Container'Unrestricted_Access, Node);
return (if Node = 0 then No_Element
else Cursor'(Container'Unrestricted_Access, Node));
end Find;
-----------
......@@ -595,23 +590,16 @@ package body Ada.Containers.Bounded_Hashed_Sets is
function First (Container : Set) return Cursor is
Node : constant Count_Type := HT_Ops.First (Container);
begin
if Node = 0 then
return No_Element;
end if;
return Cursor'(Container'Unrestricted_Access, Node);
return (if Node = 0 then No_Element
else Cursor'(Container'Unrestricted_Access, Node));
end First;
overriding function First (Object : Iterator) return Cursor is
Node : constant Count_Type := HT_Ops.First (Object.Container.all);
begin
if Node = 0 then
return No_Element;
end if;
return Cursor'(Object.Container, Node);
return (if Node = 0 then No_Element
else Cursor'(Object.Container, Node));
end First;
-----------------
......@@ -999,11 +987,7 @@ package body Ada.Containers.Bounded_Hashed_Sets is
"Position cursor designates wrong set";
end if;
if Position.Node = 0 then
return No_Element;
end if;
return Next (Position);
return (if Position.Node = 0 then No_Element else Next (Position));
end Next;
-------------
......@@ -1143,12 +1127,10 @@ package body Ada.Containers.Bounded_Hashed_Sets is
(Container : aliased Set;
Position : Cursor) return Constant_Reference_Type
is
pragma Unreferenced (Container);
S : Set renames Position.Container.all;
N : Node_Type renames S.Nodes (Position.Node);
begin
pragma Unreferenced (Container);
return (Element => N.Element'Unrestricted_Access);
end Constant_Reference;
......@@ -1316,7 +1298,6 @@ package body Ada.Containers.Bounded_Hashed_Sets is
N : Node_Type renames Left.Nodes (L_Node);
X : Count_Type;
B : Boolean;
begin
if not Is_In (Right, N) then
Insert (Result, N.Element, X, B);
......@@ -1344,7 +1325,6 @@ package body Ada.Containers.Bounded_Hashed_Sets is
N : Node_Type renames Right.Nodes (R_Node);
X : Count_Type;
B : Boolean;
begin
if not Is_In (Left, N) then
Insert (Result, N.Element, X, B);
......@@ -1367,7 +1347,6 @@ package body Ada.Containers.Bounded_Hashed_Sets is
function To_Set (New_Item : Element_Type) return Set is
X : Count_Type;
B : Boolean;
begin
return Result : Set (1, 1) do
Insert (Result, New_Item, X, B);
......@@ -1396,7 +1375,6 @@ package body Ada.Containers.Bounded_Hashed_Sets is
N : Node_Type renames Source.Nodes (Src_Node);
X : Count_Type;
B : Boolean;
begin
Insert (Target, N.Element, X, B);
end Process;
......@@ -1413,7 +1391,7 @@ package body Ada.Containers.Bounded_Hashed_Sets is
"attempt to tamper with cursors (set is busy)";
end if;
-- ???
-- ??? why is this code commented out ???
-- declare
-- N : constant Count_Type := Target.Length + Source.Length;
-- begin
......@@ -1661,15 +1639,10 @@ package body Ada.Containers.Bounded_Hashed_Sets is
(Container : Set;
Key : Key_Type) return Cursor
is
Node : constant Count_Type :=
Key_Keys.Find (Container, Key);
Node : constant Count_Type := Key_Keys.Find (Container, Key);
begin
if Node = 0 then
return No_Element;
end if;
return Cursor'(Container'Unrestricted_Access, Node);
return (if Node = 0 then No_Element
else Cursor'(Container'Unrestricted_Access, Node));
end Find;
---------
......@@ -1684,7 +1657,6 @@ package body Ada.Containers.Bounded_Hashed_Sets is
end if;
pragma Assert (Vet (Position), "bad cursor in function Key");
return Key (Position.Container.Nodes (Position.Node).Element);
end Key;
......@@ -1697,8 +1669,7 @@ package body Ada.Containers.Bounded_Hashed_Sets is
Key : Key_Type;
New_Item : Element_Type)
is
Node : constant Count_Type :=
Key_Keys.Find (Container, Key);
Node : constant Count_Type := Key_Keys.Find (Container, Key);
begin
if Node = 0 then
......@@ -1733,7 +1704,7 @@ package body Ada.Containers.Bounded_Hashed_Sets is
"Position cursor designates wrong set";
end if;
-- ???
-- ??? why is this code commented out ???
-- if HT.Buckets = null
-- or else HT.Buckets'Length = 0
-- or else HT.Length = 0
......@@ -1747,7 +1718,8 @@ package body Ada.Containers.Bounded_Hashed_Sets is
(Vet (Position),
"bad cursor in Update_Element_Preserving_Key");
-- Record bucket now, in case key is changed.
-- Record bucket now, in case key is changed
Indx := HT_Ops.Index (Container.Buckets, N (Position.Node));
declare
......@@ -1823,10 +1795,10 @@ package body Ada.Containers.Bounded_Hashed_Sets is
function Reference_Preserving_Key
(Container : aliased in out Set;
Key : Key_Type) return Reference_Type
Key : Key_Type) return Reference_Type
is
Position : constant Cursor := Find (Container, Key);
N : Node_Type renames Container.Nodes (Position.Node);
N : Node_Type renames Container.Nodes (Position.Node);
begin
return (Element => N.Element'Unrestricted_Access);
end Reference_Preserving_Key;
......
......@@ -148,8 +148,7 @@ package Ada.Containers.Bounded_Hashed_Sets is
function Constant_Reference
(Container : aliased Set;
Position : Cursor)
return Constant_Reference_Type;
Position : Cursor) return Constant_Reference_Type;
procedure Assign (Target : in out Set; Source : Set);
-- If Target denotes the same object as Source, then the operation has no
......@@ -355,8 +354,9 @@ package Ada.Containers.Bounded_Hashed_Sets is
Process : not null access procedure (Position : Cursor));
-- Calls Process for each node in the set
function Iterate (Container : Set)
return Set_Iterator_Interfaces.Forward_Iterator'Class;
function Iterate
(Container : Set)
return Set_Iterator_Interfaces.Forward_Iterator'Class;
generic
type Key_Type (<>) is private;
......@@ -431,13 +431,11 @@ package Ada.Containers.Bounded_Hashed_Sets is
function Reference_Preserving_Key
(Container : aliased in out Set;
Position : Cursor)
return Reference_Type;
Position : Cursor) return Reference_Type;
function Reference_Preserving_Key
(Container : aliased in out Set;
Key : Key_Type)
return Reference_Type;
Key : Key_Type) return Reference_Type;
private
type Reference_Type (Element : not null access Element_Type)
......@@ -446,7 +444,6 @@ package Ada.Containers.Bounded_Hashed_Sets is
end Generic_Keys;
private
pragma Inline (Next);
type Node_Type is record
......@@ -519,6 +516,6 @@ private
for Constant_Reference_Type'Write use Write;
Empty_Set : constant Set :=
(Hash_Table_Type with Capacity => 0, Modulus => 0);
(Hash_Table_Type with Capacity => 0, Modulus => 0);
end Ada.Containers.Bounded_Hashed_Sets;
......@@ -54,11 +54,11 @@ package body Ada.Containers.Bounded_Multiway_Trees is
overriding function First (Object : Child_Iterator) return Cursor;
overriding function Next
(Object : Child_Iterator;
(Object : Child_Iterator;
Position : Cursor) return Cursor;
overriding function Previous
(Object : Child_Iterator;
(Object : Child_Iterator;
Position : Cursor) return Cursor;
overriding function Last (Object : Child_Iterator) return Cursor;
......@@ -599,10 +599,8 @@ package body Ada.Containers.Bounded_Multiway_Trees is
begin
if Capacity = 0 then
C := Source.Count;
elsif Capacity >= Source.Count then
C := Capacity;
else
raise Capacity_Error with "Capacity value too small";
end if;
......@@ -841,12 +839,12 @@ package body Ada.Containers.Bounded_Multiway_Trees is
-- nodes that contain elements that have been inserted onto the tree,
-- and another for the "inactive" nodes of the free store, from which
-- nodes are allocated when a new child is inserted in the tree.
--
-- We desire that merely declaring a tree object should have only
-- minimal cost; specially, we want to avoid having to initialize the
-- free store (to fill in the links), especially if the capacity of the
-- tree object is large.
--
-- The head of the free list is indicated by Container.Free. If its
-- value is non-negative, then the free store has been initialized in
-- the "normal" way: Container.Free points to the head of the list of
......@@ -854,20 +852,20 @@ package body Ada.Containers.Bounded_Multiway_Trees is
-- empty. Each node on the free list has been initialized to point to
-- the next free node (via its Next component), and the value 0 means
-- that this is the last node of the free list.
--
-- If Container.Free is negative, then the links on the free store have
-- not been initialized. In this case the link values are implied: the
-- free store comprises the components of the node array started with
-- the absolute value of Container.Free, and continuing until the end of
-- the array (Nodes'Last).
--
-- We prefer to lazy-init the free store (in fact, we would prefer to
-- not initialize it at all, because such initialization is an O(n)
-- operation). The time when we need to actually initialize the nodes in
-- the free store is when the node that becomes inactive is not at the
-- end of the active list. The free store would then be discontigous and
-- so its nodes would need to be linked in the traditional way.
--
-- It might be possible to perform an optimization here. Suppose that
-- the free store can be represented as having two parts: one comprising
-- the non-contiguous inactive nodes linked together in the normal way,
......@@ -1218,8 +1216,8 @@ package body Ada.Containers.Bounded_Multiway_Trees is
Right_Subtree : Count_Type) return Boolean
is
begin
if Left_Tree.Elements (Left_Subtree)
/= Right_Tree.Elements (Right_Subtree)
if Left_Tree.Elements (Left_Subtree) /=
Right_Tree.Elements (Right_Subtree)
then
return False;
end if;
......@@ -1262,7 +1260,6 @@ package body Ada.Containers.Bounded_Multiway_Trees is
function First (Object : Child_Iterator) return Cursor is
Node : Count_Type'Base;
begin
Node := Object.Container.Nodes (Object.Position.Node).Children.First;
return (Object.Container, Node);
......@@ -1722,11 +1719,9 @@ package body Ada.Containers.Bounded_Multiway_Trees is
function Is_Root (Position : Cursor) return Boolean is
begin
if Position.Container = null then
return False;
end if;
return Position.Node = Root_Node (Position.Container.all);
return
(if Position.Container = null then False
else Position.Node = Root_Node (Position.Container.all));
end Is_Root;
-------------
......@@ -1839,7 +1834,7 @@ package body Ada.Containers.Bounded_Multiway_Trees is
function Iterate_Children
(Container : Tree;
Parent : Cursor)
return Tree_Iterator_Interfaces.Reversible_Iterator'Class
return Tree_Iterator_Interfaces.Reversible_Iterator'Class
is
pragma Unreferenced (Container);
begin
......@@ -2039,10 +2034,9 @@ package body Ada.Containers.Bounded_Multiway_Trees is
end Next;
function Next
(Object : Child_Iterator;
(Object : Child_Iterator;
Position : Cursor) return Cursor
is
begin
if Object.Container /= Position.Container then
raise Program_Error;
......@@ -2201,7 +2195,7 @@ package body Ada.Containers.Bounded_Multiway_Trees is
--------------
overriding function Previous
(Object : Child_Iterator;
(Object : Child_Iterator;
Position : Cursor) return Cursor
is
begin
......
......@@ -182,7 +182,7 @@ package Ada.Containers.Bounded_Multiway_Trees is
function Iterate_Children
(Container : Tree;
Parent : Cursor)
return Tree_Iterator_Interfaces.Reversible_Iterator'Class;
return Tree_Iterator_Interfaces.Reversible_Iterator'Class;
function Child_Count (Parent : Cursor) return Count_Type;
......
......@@ -49,7 +49,7 @@ package body Ada.Containers.Indefinite_Hashed_Sets is
overriding function First (Object : Iterator) return Cursor;
overriding function Next
(Object : Iterator;
(Object : Iterator;
Position : Cursor) return Cursor;
-----------------------
......@@ -426,8 +426,7 @@ package body Ada.Containers.Indefinite_Hashed_Sets is
-- Equivalent_Elements --
-------------------------
function Equivalent_Elements (Left, Right : Cursor)
return Boolean is
function Equivalent_Elements (Left, Right : Cursor) return Boolean is
begin
if Left.Node = null then
raise Constraint_Error with
......@@ -457,8 +456,10 @@ package body Ada.Containers.Indefinite_Hashed_Sets is
Right.Node.Element.all);
end Equivalent_Elements;
function Equivalent_Elements (Left : Cursor; Right : Element_Type)
return Boolean is
function Equivalent_Elements
(Left : Cursor;
Right : Element_Type) return Boolean
is
begin
if Left.Node = null then
raise Constraint_Error with
......@@ -475,8 +476,10 @@ package body Ada.Containers.Indefinite_Hashed_Sets is
return Equivalent_Elements (Left.Node.Element.all, Right);
end Equivalent_Elements;
function Equivalent_Elements (Left : Element_Type; Right : Cursor)
return Boolean is
function Equivalent_Elements
(Left : Element_Type;
Right : Cursor) return Boolean
is
begin
if Right.Node = null then
raise Constraint_Error with
......@@ -497,8 +500,10 @@ package body Ada.Containers.Indefinite_Hashed_Sets is
-- Equivalent_Keys --
---------------------
function Equivalent_Keys (Key : Element_Type; Node : Node_Access)
return Boolean is
function Equivalent_Keys
(Key : Element_Type;
Node : Node_Access) return Boolean
is
begin
return Equivalent_Elements (Key, Node.Element.all);
end Equivalent_Keys;
......@@ -535,13 +540,9 @@ package body Ada.Containers.Indefinite_Hashed_Sets is
Item : Element_Type) return Cursor
is
Node : constant Node_Access := Element_Keys.Find (Container.HT, Item);
begin
if Node = null then
return No_Element;
end if;
return Cursor'(Container'Unrestricted_Access, Node);
return (if Node = null then No_Element
else Cursor'(Container'Unrestricted_Access, Node));
end Find;
--------------------
......@@ -604,23 +605,16 @@ package body Ada.Containers.Indefinite_Hashed_Sets is
function First (Container : Set) return Cursor is
Node : constant Node_Access := HT_Ops.First (Container.HT);
begin
if Node = null then
return No_Element;
end if;
return Cursor'(Container'Unrestricted_Access, Node);
return (if Node = null then No_Element
else Cursor'(Container'Unrestricted_Access, Node));
end First;
function First (Object : Iterator) return Cursor is
Node : constant Node_Access := HT_Ops.First (Object.Container.HT);
begin
if Node = null then
return No_Element;
end if;
return Cursor'(Object.Container, Node);
return (if Node = null then No_Element
else Cursor'(Object.Container, Node));
end First;
----------
......@@ -750,7 +744,6 @@ package body Ada.Containers.Indefinite_Hashed_Sets is
function New_Node (Next : Node_Access) return Node_Access is
Element : Element_Access := new Element_Type'(New_Item);
begin
return new Node_Type'(Element, Next);
exception
......@@ -1025,13 +1018,9 @@ package body Ada.Containers.Indefinite_Hashed_Sets is
declare
HT : Hash_Table_Type renames Position.Container.HT;
Node : constant Node_Access := HT_Ops.Next (HT, Position.Node);
begin
if Node = null then
return No_Element;
end if;
return Cursor'(Position.Container, Node);
return (if Node = null then No_Element
else Cursor'(Position.Container, Node));
end;
end Next;
......@@ -1041,7 +1030,7 @@ package body Ada.Containers.Indefinite_Hashed_Sets is
end Next;
function Next
(Object : Iterator;
(Object : Iterator;
Position : Cursor) return Cursor
is
begin
......@@ -1050,11 +1039,7 @@ package body Ada.Containers.Indefinite_Hashed_Sets is
"Position cursor designates wrong set";
end if;
if Position.Node = null then
return No_Element;
end if;
return Next (Position);
return (if Position.Node = null then No_Element else Next (Position));
end Next;
-------------
......@@ -1166,7 +1151,6 @@ package body Ada.Containers.Indefinite_Hashed_Sets is
(Stream : not null access Root_Stream_Type'Class) return Node_Access
is
X : Element_Access := new Element_Type'(Element_Type'Input (Stream));
begin
return new Node_Type'(X, null);
exception
......@@ -1183,9 +1167,8 @@ package body Ada.Containers.Indefinite_Hashed_Sets is
(Container : aliased Set;
Position : Cursor) return Constant_Reference_Type
is
begin
pragma Unreferenced (Container);
begin
return (Element => Position.Node.Element);
end Constant_Reference;
......@@ -1301,8 +1284,7 @@ package body Ada.Containers.Indefinite_Hashed_Sets is
Iterate_Source_When_Empty_Target : declare
procedure Process (Src_Node : Node_Access);
procedure Iterate is
new HT_Ops.Generic_Iteration (Process);
procedure Iterate is new HT_Ops.Generic_Iteration (Process);
-------------
-- Process --
......@@ -1535,12 +1517,10 @@ package body Ada.Containers.Indefinite_Hashed_Sets is
------------
function To_Set (New_Item : Element_Type) return Set is
HT : Hash_Table_Type;
HT : Hash_Table_Type;
Node : Node_Access;
Inserted : Boolean;
pragma Unreferenced (Node, Inserted);
begin
Insert (HT, New_Item, Node, Inserted);
return Set'(Controlled with HT);
......@@ -1578,7 +1558,6 @@ package body Ada.Containers.Indefinite_Hashed_Sets is
function New_Node (Next : Node_Access) return Node_Access is
Tgt : Element_Access := new Element_Type'(Src);
begin
return new Node_Type'(Tgt, Next);
exception
......@@ -1655,14 +1634,10 @@ package body Ada.Containers.Indefinite_Hashed_Sets is
-------------
procedure Process (L_Node : Node_Access) is
Src : Element_Type renames L_Node.Element.all;
J : constant Hash_Type := Hash (Src) mod Buckets'Length;
Src : Element_Type renames L_Node.Element.all;
J : constant Hash_Type := Hash (Src) mod Buckets'Length;
Bucket : Node_Access renames Buckets (J);
Tgt : Element_Access := new Element_Type'(Src);
Tgt : Element_Access := new Element_Type'(Src);
begin
Bucket := new Node_Type'(Tgt, Bucket);
exception
......@@ -1940,13 +1915,9 @@ package body Ada.Containers.Indefinite_Hashed_Sets is
Key : Key_Type) return Cursor
is
Node : constant Node_Access := Key_Keys.Find (Container.HT, Key);
begin
if Node = null then
return No_Element;
end if;
return Cursor'(Container'Unrestricted_Access, Node);
return (if Node = null then No_Element
else Cursor'(Container'Unrestricted_Access, Node));
end Find;
---------
......@@ -2106,7 +2077,7 @@ package body Ada.Containers.Indefinite_Hashed_Sets is
function Reference_Preserving_Key
(Container : aliased in out Set;
Key : Key_Type) return Reference_Type
Key : Key_Type) return Reference_Type
is
Position : constant Cursor := Find (Container, Key);
begin
......
......@@ -414,13 +414,11 @@ package Ada.Containers.Indefinite_Hashed_Sets is
function Reference_Preserving_Key
(Container : aliased in out Set;
Position : Cursor)
return Reference_Type;
Position : Cursor) return Reference_Type;
function Reference_Preserving_Key
(Container : aliased in out Set;
Key : Key_Type)
return Reference_Type;
Key : Key_Type) return Reference_Type;
private
type Reference_Type (Element : not null access Element_Type)
......@@ -428,7 +426,6 @@ package Ada.Containers.Indefinite_Hashed_Sets is
end Generic_Keys;
private
pragma Inline (Next);
type Node_Type;
......
......@@ -279,8 +279,7 @@ package body Ada.Containers.Indefinite_Ordered_Maps is
-- Adjust --
------------
procedure Adjust is
new Tree_Operations.Generic_Adjust (Copy_Tree);
procedure Adjust is new Tree_Operations.Generic_Adjust (Copy_Tree);
procedure Adjust (Container : in out Map) is
begin
......@@ -293,21 +292,16 @@ package body Ada.Containers.Indefinite_Ordered_Maps is
function Ceiling (Container : Map; Key : Key_Type) return Cursor is
Node : constant Node_Access := Key_Ops.Ceiling (Container.Tree, Key);
begin
if Node = null then
return No_Element;
end if;
return Cursor'(Container'Unrestricted_Access, Node);
return (if Node = null then No_Element
else Cursor'(Container'Unrestricted_Access, Node));
end Ceiling;
-----------
-- Clear --
-----------
procedure Clear is
new Tree_Operations.Generic_Clear (Delete_Tree);
procedure Clear is new Tree_Operations.Generic_Clear (Delete_Tree);
procedure Clear (Container : in out Map) is
begin
......@@ -331,7 +325,8 @@ package body Ada.Containers.Indefinite_Ordered_Maps is
(Container : Map;
Key : Key_Type) return Constant_Reference_Type
is
begin return (Element => Container.Element (Key)'Unrestricted_Access);
begin
return (Element => Container.Element (Key)'Unrestricted_Access);
end Constant_Reference;
--------------
......@@ -350,6 +345,7 @@ package body Ada.Containers.Indefinite_Ordered_Maps is
function Copy_Node (Source : Node_Access) return Node_Access is
K : Key_Access := new Key_Type'(Source.Key.all);
E : Element_Access;
begin
E := new Element_Type'(Source.Element.all);
......@@ -418,7 +414,6 @@ package body Ada.Containers.Indefinite_Ordered_Maps is
procedure Delete_First (Container : in out Map) is
X : Node_Access := Container.Tree.First;
begin
if X /= null then
Tree_Operations.Delete_Node_Sans_Free (Container.Tree, X);
......@@ -432,7 +427,6 @@ package body Ada.Containers.Indefinite_Ordered_Maps is
procedure Delete_Last (Container : in out Map) is
X : Node_Access := Container.Tree.Last;
begin
if X /= null then
Tree_Operations.Delete_Node_Sans_Free (Container.Tree, X);
......@@ -479,13 +473,7 @@ package body Ada.Containers.Indefinite_Ordered_Maps is
function Equivalent_Keys (Left, Right : Key_Type) return Boolean is
begin
if Left < Right
or else Right < Left
then
return False;
else
return True;
end if;
return (if Left < Right or else Right < Left then False else True);
end Equivalent_Keys;
-------------
......@@ -494,7 +482,6 @@ package body Ada.Containers.Indefinite_Ordered_Maps is
procedure Exclude (Container : in out Map; Key : Key_Type) is
X : Node_Access := Key_Ops.Find (Container.Tree, Key);
begin
if X /= null then
Tree_Operations.Delete_Node_Sans_Free (Container.Tree, X);
......@@ -508,13 +495,9 @@ package body Ada.Containers.Indefinite_Ordered_Maps is
function Find (Container : Map; Key : Key_Type) return Cursor is
Node : constant Node_Access := Key_Ops.Find (Container.Tree, Key);
begin
if Node = null then
return No_Element;
end if;
return Cursor'(Container'Unrestricted_Access, Node);
return (if Node = null then No_Element
else Cursor'(Container'Unrestricted_Access, Node));
end Find;
-----------
......@@ -523,25 +506,17 @@ package body Ada.Containers.Indefinite_Ordered_Maps is
function First (Container : Map) return Cursor is
T : Tree_Type renames Container.Tree;
begin
if T.First = null then
return No_Element;
end if;
return Cursor'(Container'Unrestricted_Access, T.First);
return (if T.First = null then No_Element
else Cursor'(Container'Unrestricted_Access, T.First));
end First;
function First (Object : Iterator) return Cursor is
M : constant Map_Access := Object.Container;
N : constant Node_Access := M.Tree.First;
begin
if N = null then
return No_Element;
else
return Cursor'(Object.Container.all'Unchecked_Access, N);
end if;
return (if N = null then No_Element
else Cursor'(Object.Container.all'Unchecked_Access, N));
end First;
-------------------
......@@ -580,13 +555,9 @@ package body Ada.Containers.Indefinite_Ordered_Maps is
function Floor (Container : Map; Key : Key_Type) return Cursor is
Node : constant Node_Access := Key_Ops.Floor (Container.Tree, Key);
begin
if Node = null then
return No_Element;
end if;
return Cursor'(Container'Unrestricted_Access, Node);
return (if Node = null then No_Element
else Cursor'(Container'Unrestricted_Access, Node));
end Floor;
----------
......@@ -608,6 +579,7 @@ package body Ada.Containers.Indefinite_Ordered_Maps is
begin
Free_Key (X.Key);
exception
when others =>
X.Key := null;
......@@ -625,6 +597,7 @@ package body Ada.Containers.Indefinite_Ordered_Maps is
begin
Free_Element (X.Element);
exception
when others =>
X.Element := null;
......@@ -771,18 +744,11 @@ package body Ada.Containers.Indefinite_Ordered_Maps is
-- Is_Equal_Node_Node --
------------------------
function Is_Equal_Node_Node
(L, R : Node_Access) return Boolean is
function Is_Equal_Node_Node (L, R : Node_Access) return Boolean is
begin
if L.Key.all < R.Key.all then
return False;
elsif R.Key.all < L.Key.all then
return False;
else
return L.Element.all = R.Element.all;
end if;
return (if L.Key.all < R.Key.all then False
elsif R.Key.all < L.Key.all then False
else L.Element.all = R.Element.all);
end Is_Equal_Node_Node;
-------------------------
......@@ -856,12 +822,13 @@ package body Ada.Containers.Indefinite_Ordered_Maps is
is
Node : constant Node_Access := Container.Tree.First;
It : constant Iterator := (Container'Unrestricted_Access, Node);
begin
return It;
end Iterate;
function Iterate (Container : Map; Start : Cursor)
function Iterate
(Container : Map;
Start : Cursor)
return Map_Iterator_Interfaces.Reversible_Iterator'class
is
It : constant Iterator := (Container'Unrestricted_Access, Start.Node);
......@@ -897,24 +864,17 @@ package body Ada.Containers.Indefinite_Ordered_Maps is
function Last (Container : Map) return Cursor is
T : Tree_Type renames Container.Tree;
begin
if T.Last = null then
return No_Element;
end if;
return Cursor'(Container'Unrestricted_Access, T.Last);
return (if T.Last = null then No_Element
else Cursor'(Container'Unrestricted_Access, T.Last));
end Last;
function Last (Object : Iterator) return Cursor is
M : constant Map_Access := Object.Container;
N : constant Node_Access := M.Tree.Last;
begin
if N = null then
return No_Element;
else
return Cursor'(Object.Container.all'Unchecked_Access, N);
end if;
return (if N = null then No_Element
else Cursor'(Object.Container.all'Unchecked_Access, N));
end Last;
------------------
......@@ -969,8 +929,7 @@ package body Ada.Containers.Indefinite_Ordered_Maps is
-- Move --
----------
procedure Move is
new Tree_Operations.Generic_Move (Clear);
procedure Move is new Tree_Operations.Generic_Move (Clear);
procedure Move (Target : in out Map; Source : in out Map) is
begin
......@@ -996,13 +955,9 @@ package body Ada.Containers.Indefinite_Ordered_Maps is
declare
Node : constant Node_Access :=
Tree_Operations.Next (Position.Node);
begin
if Node = null then
return No_Element;
else
return Cursor'(Position.Container, Node);
end if;
return (if Node = null then No_Element
else Cursor'(Position.Container, Node));
end;
end Next;
......@@ -1016,11 +971,8 @@ package body Ada.Containers.Indefinite_Ordered_Maps is
Position : Cursor) return Cursor
is
begin
if Position.Node = null then
return No_Element;
else
return (Object.Container, Tree_Operations.Next (Position.Node));
end if;
return (if Position.Node = null then No_Element
else (Object.Container, Tree_Operations.Next (Position.Node)));
end Next;
------------
......@@ -1051,13 +1003,9 @@ package body Ada.Containers.Indefinite_Ordered_Maps is
declare
Node : constant Node_Access :=
Tree_Operations.Previous (Position.Node);
begin
if Node = null then
return No_Element;
end if;
return Cursor'(Position.Container, Node);
return (if Node = null then No_Element
else Cursor'(Position.Container, Node));
end;
end Previous;
......@@ -1071,11 +1019,9 @@ package body Ada.Containers.Indefinite_Ordered_Maps is
Position : Cursor) return Cursor
is
begin
if Position.Node = null then
return No_Element;
else
return (Object.Container, Tree_Operations.Previous (Position.Node));
end if;
return
(if Position.Node = null then No_Element
else (Object.Container, Tree_Operations.Previous (Position.Node)));
end Previous;
-------------------
......
......@@ -48,16 +48,16 @@ package body Ada.Containers.Multiway_Trees is
overriding function First (Object : Iterator) return Cursor;
overriding function Next
(Object : Iterator;
(Object : Iterator;
Position : Cursor) return Cursor;
overriding function First (Object : Child_Iterator) return Cursor;
overriding function Next
(Object : Child_Iterator;
(Object : Child_Iterator;
Position : Cursor) return Cursor;
overriding function Previous
(Object : Child_Iterator;
(Object : Child_Iterator;
Position : Cursor) return Cursor;
overriding function Last (Object : Child_Iterator) return Cursor;
......@@ -327,11 +327,8 @@ package body Ada.Containers.Multiway_Trees is
function Child_Count (Parent : Cursor) return Count_Type is
begin
if Parent = No_Element then
return 0;
else
return Child_Count (Parent.Node.Children);
end if;
return (if Parent = No_Element
then 0 else Child_Count (Parent.Node.Children));
end Child_Count;
function Child_Count (Children : Children_Type) return Count_Type is
......@@ -1010,12 +1007,10 @@ package body Ada.Containers.Multiway_Trees is
-- raise Program_Error with "Position cursor not in container";
-- end if;
if Is_Root (Position) then
Result := Find_In_Children (Position.Node, Item);
else
Result := Find_In_Subtree (Position.Node, Item);
end if;
Result :=
(if Is_Root (Position)
then Find_In_Children (Position.Node, Item)
else Find_In_Subtree (Position.Node, Item));
if Result = null then
return No_Element;
......@@ -1437,7 +1432,7 @@ package body Ada.Containers.Multiway_Trees is
function Iterate_Children
(Container : Tree;
Parent : Cursor)
return Tree_Iterator_Interfaces.Reversible_Iterator'Class
return Tree_Iterator_Interfaces.Reversible_Iterator'Class
is
pragma Unreferenced (Container);
begin
......@@ -1457,8 +1452,8 @@ package body Ada.Containers.Multiway_Trees is
end Iterate_Subtree;
procedure Iterate_Subtree
(Position : Cursor;
Process : not null access procedure (Position : Cursor))
(Position : Cursor;
Process : not null access procedure (Position : Cursor))
is
begin
if Position = No_Element then
......@@ -1515,6 +1510,7 @@ package body Ada.Containers.Multiway_Trees is
function Last_Child (Parent : Cursor) return Cursor is
Node : Tree_Node_Access;
begin
if Parent = No_Element then
raise Constraint_Error with "Parent cursor has no element";
......@@ -1575,7 +1571,7 @@ package body Ada.Containers.Multiway_Trees is
----------
function Next
(Object : Iterator;
(Object : Iterator;
Position : Cursor) return Cursor
is
T : Tree renames Position.Container.all;
......@@ -1635,18 +1631,12 @@ package body Ada.Containers.Multiway_Trees is
end Next;
function Next
(Object : Child_Iterator;
(Object : Child_Iterator;
Position : Cursor) return Cursor
is
C : constant Tree_Node_Access := Position.Node.Next;
begin
if C = null then
return No_Element;
else
return (Object.Container, C);
end if;
return (if C = null then No_Element else (Object.Container, C));
end Next;
------------------
......@@ -1773,18 +1763,12 @@ package body Ada.Containers.Multiway_Trees is
--------------
overriding function Previous
(Object : Child_Iterator;
(Object : Child_Iterator;
Position : Cursor) return Cursor
is
C : constant Tree_Node_Access := Position.Node.Prev;
begin
if C = null then
return No_Element;
else
return (Object.Container, C);
end if;
return (if C = null then No_Element else (Object.Container, C));
end Previous;
----------------------
......@@ -1793,15 +1777,10 @@ package body Ada.Containers.Multiway_Trees is
function Previous_Sibling (Position : Cursor) return Cursor is
begin
if Position = No_Element then
return No_Element;
end if;
if Position.Node.Prev = null then
return No_Element;
end if;
return Cursor'(Position.Container, Position.Node.Prev);
return
(if Position = No_Element then No_Element
elsif Position.Node.Prev = null then No_Element
else Cursor'(Position.Container, Position.Node.Prev));
end Previous_Sibling;
procedure Previous_Sibling (Position : in out Cursor) is
......
......@@ -452,7 +452,18 @@ package body Sem_Ch6 is
-- incompatibility with Ada 95. Not clear whether this should be
-- enforced yet or perhaps controllable with special switch. ???
if Is_Limited_Type (R_Type)
-- A limited interface that is not immutably limited is OK.
if Is_Limited_Interface (R_Type)
and then
not (Is_Task_Interface (R_Type)
or else Is_Protected_Interface (R_Type)
or else Is_Synchronized_Interface (R_Type))
then
null;
elsif Is_Limited_Type (R_Type)
and then not Is_Interface (R_Type)
and then Comes_From_Source (N)
and then not In_Instance_Body
and then not OK_For_Limited_Init_In_05 (R_Type, Expr)
......
......@@ -64,6 +64,7 @@ with Sem_Elab; use Sem_Elab;
with Sem_Eval; use Sem_Eval;
with Sem_Intr; use Sem_Intr;
with Sem_Util; use Sem_Util;
with Targparm; use Targparm;
with Sem_Type; use Sem_Type;
with Sem_Warn; use Sem_Warn;
with Sinfo; use Sinfo;
......@@ -4874,13 +4875,33 @@ package body Sem_Res is
(Is_Real_Type (Etype (Rop))
and then Expr_Value_R (Rop) = Ureal_0))
then
-- Specialize the warning message according to the operation
-- Specialize the warning message according to the operation.
-- The following warnings are for the case
case Nkind (N) is
when N_Op_Divide =>
Apply_Compile_Time_Constraint_Error
(N, "division by zero?", CE_Divide_By_Zero,
Loc => Sloc (Right_Opnd (N)));
-- For division, we have two cases, for float division
-- of an unconstrained float type, on a machine where
-- Machine_Overflows is false, we don't get an exception
-- at run-time, but rather an infinity or Nan. The Nan
-- case is pretty obscure, so just warn about infinities.
if Is_Floating_Point_Type (Typ)
and then not Is_Constrained (Typ)
and then not Machine_Overflows_On_Target
then
Error_Msg_N
("float division by zero, " &
"may generate '+'/'- infinity?", Right_Opnd (N));
-- For all other cases, we get a Constraint_Error
else
Apply_Compile_Time_Constraint_Error
(N, "division by zero?", CE_Divide_By_Zero,
Loc => Sloc (Right_Opnd (N)));
end if;
when N_Op_Rem =>
Apply_Compile_Time_Constraint_Error
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment