Commit e7f11067 by Arnaud Charlet

[multiple changes]

2013-04-11  Johannes Kanig  <kanig@adacore.com>

	* debug.adb: Document usage of -gnatd.Q switch.

2013-04-11  Matthew Heaney  <heaney@adacore.com>

	* a-crbtgk.adb (Ceiling, Find, Floor): Adjust locks
	before element comparisons.
	(Generic_Conditional_Insert, Generic_Conditional_Insert_With_Hint):
	Ditto.
	* a-crbtgo.adb, a-rbtgbo.adb (Generic_Equal): Adjust locks before
	element comparisons.
	* a-rbtgso.adb (Difference, Intersection): Adjust locks
	before element comparisons.
	(Is_Subset, Overlap): Ditto
	(Symmetric_Difference, Union): Ditto
	* a-btgbso.adb (Set_Difference, Set_Intersection): Adjust locks
	before element comparisons.
	(Set_Subset, Set_Overlap): Ditto
	(Set_Symmetric_Difference, Set_Union): Ditto
	* a-coorse.adb, a-ciorse.adb, a-cborse.adb
	(Update_Element_Preserving_Key): Adjust locks before element
	comparisons (Replace_Element): Ditto

2013-04-11  Pascal Obry  <obry@adacore.com>

	* prj-attr.adb, projects.texi, snames.ads-tmpl: Remove Build_Slaves
	attribute.

2013-04-11  Ed Schonberg  <schonberg@adacore.com>

	* exp_ch3.adb (Build_Equivalent_Aggregate): Subsidiary of
	Expand_N_Object_Declaration, used to construct an aggregate
	with static components whenever possible, so that objects of a
	discriminated type can be initialized without calling the init.
	proc for the type.

2013-04-11  Vincent Celier  <celier@adacore.com>

	* prj-makr.adb (Process_Directory): On VMS, always delete,
	then recreate the temporary file with Create_Output_Text_File,
	otherwise the output redirection does not work properly.

2013-04-11  Eric Botcazou  <ebotcazou@adacore.com>

	* urealp.ads: Fix minor typo.

2013-04-11  Fabien Chouteau  <chouteau@adacore.com>

	* cio.c (mktemp): Don't use tmpnam function from the
	system on VxWorks in kernel mode.

From-SVN: r197784
parent e03c5253
2013-04-11 Johannes Kanig <kanig@adacore.com>
* debug.adb: Document usage of -gnatd.Q switch.
2013-04-11 Matthew Heaney <heaney@adacore.com>
* a-crbtgk.adb (Ceiling, Find, Floor): Adjust locks
before element comparisons.
(Generic_Conditional_Insert, Generic_Conditional_Insert_With_Hint):
Ditto.
* a-crbtgo.adb, a-rbtgbo.adb (Generic_Equal): Adjust locks before
element comparisons.
* a-rbtgso.adb (Difference, Intersection): Adjust locks
before element comparisons.
(Is_Subset, Overlap): Ditto
(Symmetric_Difference, Union): Ditto
* a-btgbso.adb (Set_Difference, Set_Intersection): Adjust locks
before element comparisons.
(Set_Subset, Set_Overlap): Ditto
(Set_Symmetric_Difference, Set_Union): Ditto
* a-coorse.adb, a-ciorse.adb, a-cborse.adb
(Update_Element_Preserving_Key): Adjust locks before element
comparisons (Replace_Element): Ditto
2013-04-11 Pascal Obry <obry@adacore.com>
* prj-attr.adb, projects.texi, snames.ads-tmpl: Remove Build_Slaves
attribute.
2013-04-11 Ed Schonberg <schonberg@adacore.com>
* exp_ch3.adb (Build_Equivalent_Aggregate): Subsidiary of
Expand_N_Object_Declaration, used to construct an aggregate
with static components whenever possible, so that objects of a
discriminated type can be initialized without calling the init.
proc for the type.
2013-04-11 Vincent Celier <celier@adacore.com>
* prj-makr.adb (Process_Directory): On VMS, always delete,
then recreate the temporary file with Create_Output_Text_File,
otherwise the output redirection does not work properly.
2013-04-11 Eric Botcazou <ebotcazou@adacore.com>
* urealp.ads: Fix minor typo.
2013-04-11 Fabien Chouteau <chouteau@adacore.com>
* cio.c (mktemp): Don't use tmpnam function from the
system on VxWorks in kernel mode.
2013-04-11 Vincent Celier <celier@adacore.com> 2013-04-11 Vincent Celier <celier@adacore.com>
* make.adb (Compile): Clarify the error message reported * make.adb (Compile): Clarify the error message reported
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2004-2012, Free Software Foundation, Inc. -- -- Copyright (C) 2004-2013, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -979,6 +979,9 @@ package body Ada.Containers.Bounded_Ordered_Sets is ...@@ -979,6 +979,9 @@ package body Ada.Containers.Bounded_Ordered_Sets is
pragma Assert (Vet (Container, Position.Node), pragma Assert (Vet (Container, Position.Node),
"bad cursor in Update_Element_Preserving_Key"); "bad cursor in Update_Element_Preserving_Key");
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
declare declare
N : Node_Type renames Container.Nodes (Position.Node); N : Node_Type renames Container.Nodes (Position.Node);
E : Element_Type renames N.Element; E : Element_Type renames N.Element;
...@@ -987,12 +990,15 @@ package body Ada.Containers.Bounded_Ordered_Sets is ...@@ -987,12 +990,15 @@ package body Ada.Containers.Bounded_Ordered_Sets is
B : Natural renames Container.Busy; B : Natural renames Container.Busy;
L : Natural renames Container.Lock; L : Natural renames Container.Lock;
Eq : Boolean;
begin begin
B := B + 1; B := B + 1;
L := L + 1; L := L + 1;
begin begin
Process (E); Process (E);
Eq := Equivalent_Keys (K, Key (E));
exception exception
when others => when others =>
L := L - 1; L := L - 1;
...@@ -1003,7 +1009,7 @@ package body Ada.Containers.Bounded_Ordered_Sets is ...@@ -1003,7 +1009,7 @@ package body Ada.Containers.Bounded_Ordered_Sets is
L := L - 1; L := L - 1;
B := B - 1; B := B - 1;
if Equivalent_Keys (K, Key (E)) then if Eq then
return; return;
end if; end if;
end; end;
...@@ -1727,16 +1733,52 @@ package body Ada.Containers.Bounded_Ordered_Sets is ...@@ -1727,16 +1733,52 @@ package body Ada.Containers.Bounded_Ordered_Sets is
Hint : Count_Type; Hint : Count_Type;
Result : Count_Type; Result : Count_Type;
Inserted : Boolean; Inserted : Boolean;
Compare : Boolean;
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
B : Natural renames Container.Busy;
L : Natural renames Container.Lock;
-- Start of processing for Replace_Element -- Start of processing for Replace_Element
begin begin
if Item < Node.Element -- Replace_Element assigns value Item to the element designated by Node,
or else Node.Element < Item -- per certain semantic constraints, described as follows.
then
null; -- If Item is equivalent to the element, then element is replaced and
-- there's nothing else to do. This is the easy case.
-- If Item is not equivalent, then the node will (possibly) have to move
-- to some other place in the tree. This is slighly more complicated,
-- because we must ensure that Item is not equivalent to some other
-- element in the tree (in which case, the replacement is not allowed).
-- Determine whether Item is equivalent to element on the specified
-- node.
begin
B := B + 1;
L := L + 1;
Compare := (if Item < Node.Element then False
elsif Node.Element < Item then False
else True);
L := L - 1;
B := B - 1;
exception
when others =>
L := L - 1;
B := B - 1;
raise;
end;
if Compare then
-- Item is equivalent to the node's element, so we will not have to
-- move the node.
else
if Container.Lock > 0 then if Container.Lock > 0 then
raise Program_Error with raise Program_Error with
"attempt to tamper with elements (set is locked)"; "attempt to tamper with elements (set is locked)";
...@@ -1746,12 +1788,63 @@ package body Ada.Containers.Bounded_Ordered_Sets is ...@@ -1746,12 +1788,63 @@ package body Ada.Containers.Bounded_Ordered_Sets is
return; return;
end if; end if;
-- The replacement Item is not equivalent to the element on the
-- specified node, which means that it will need to be re-inserted in a
-- different position in the tree. We must now determine whether Item is
-- equivalent to some other element in the tree (which would prohibit
-- the assignment and hence the move).
-- Ceiling returns the smallest element equivalent or greater than the
-- specified Item; if there is no such element, then it returns 0.
Hint := Element_Keys.Ceiling (Container, Item); Hint := Element_Keys.Ceiling (Container, Item);
if Hint = 0 then if Hint /= 0 then -- Item <= Nodes (Hint).Element
null; begin
B := B + 1;
L := L + 1;
Compare := Item < Nodes (Hint).Element;
L := L - 1;
B := B - 1;
exception
when others =>
L := L - 1;
B := B - 1;
raise;
end;
if not Compare then -- Item is equivalent to Nodes (Hint).Element
-- Ceiling returns an element that is equivalent or greater than
-- Item. If Item is "not less than" the element, then by
-- elimination we know that Item is equivalent to the element.
-- But this means that it is not possible to assign the value of
-- Item to the specified element (on Node), because a different
-- element (on Hint) equivalent to Item already exsits. (Were we
-- to change Node's element value, we would have to move Node, but
-- we would be unable to move the Node, because its new position
-- in the tree is already occupied by an equivalent element.)
raise Program_Error with "attempt to replace existing element";
end if;
-- Item is not equivalent to any other element in the tree
-- (specifically, it is less then Nodes (Hint).Element), so it is
-- safe to assign the value of Item to Node.Element. This means that
-- the node will have to move to a different position in the tree
-- (because its element will have a different value).
-- The nearest (greater) neighbor of Item is Hint. This will be the
-- insertion position of Node (because its element will have Item as
-- its new value).
-- If Node equals Hint, the relative position of Node does not
-- change. This allows us to perform an optimization: we need not
-- remove Node from the tree and then reinsert it with its new value,
-- because it would only be placed in the exact same position.
elsif Item < Nodes (Hint).Element then
if Hint = Index then if Hint = Index then
if Container.Lock > 0 then if Container.Lock > 0 then
raise Program_Error with raise Program_Error with
...@@ -1761,12 +1854,14 @@ package body Ada.Containers.Bounded_Ordered_Sets is ...@@ -1761,12 +1854,14 @@ package body Ada.Containers.Bounded_Ordered_Sets is
Node.Element := Item; Node.Element := Item;
return; return;
end if; end if;
else
pragma Assert (not (Nodes (Hint).Element < Item));
raise Program_Error with "attempt to replace existing element";
end if; end if;
-- If we get here, it is because Item was greater than all elements in
-- the tree (Hint = 0), or because Item was less than some element at a
-- different place in the tree (Item < Nodes (Hint).Element and Hint /=
-- Index). In either case, we remove Node from the tree and then insert
-- Item into the tree, onto the same Node.
Tree_Operations.Delete_Node_Sans_Free (Container, Index); Tree_Operations.Delete_Node_Sans_Free (Container, Index);
Local_Insert_With_Hint Local_Insert_With_Hint
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2004-2012, Free Software Foundation, Inc. -- -- Copyright (C) 2004-2013, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -1088,12 +1088,15 @@ package body Ada.Containers.Indefinite_Ordered_Sets is ...@@ -1088,12 +1088,15 @@ package body Ada.Containers.Indefinite_Ordered_Sets is
B : Natural renames Tree.Busy; B : Natural renames Tree.Busy;
L : Natural renames Tree.Lock; L : Natural renames Tree.Lock;
Eq : Boolean;
begin begin
B := B + 1; B := B + 1;
L := L + 1; L := L + 1;
begin begin
Process (E); Process (E);
Eq := Equivalent_Keys (K, Key (E));
exception exception
when others => when others =>
L := L - 1; L := L - 1;
...@@ -1104,7 +1107,7 @@ package body Ada.Containers.Indefinite_Ordered_Sets is ...@@ -1104,7 +1107,7 @@ package body Ada.Containers.Indefinite_Ordered_Sets is
L := L - 1; L := L - 1;
B := B - 1; B := B - 1;
if Equivalent_Keys (K, Key (E)) then if Eq then
return; return;
end if; end if;
end; end;
...@@ -1884,16 +1887,54 @@ package body Ada.Containers.Indefinite_Ordered_Sets is ...@@ -1884,16 +1887,54 @@ package body Ada.Containers.Indefinite_Ordered_Sets is
Hint : Node_Access; Hint : Node_Access;
Result : Node_Access; Result : Node_Access;
Inserted : Boolean; Inserted : Boolean;
Compare : Boolean;
X : Element_Access := Node.Element; X : Element_Access := Node.Element;
-- Start of processing for Replace_Element -- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
B : Natural renames Tree.Busy;
L : Natural renames Tree.Lock;
-- Start of processing for Replace_Element
begin begin
if Item < Node.Element.all or else Node.Element.all < Item then -- Replace_Element assigns value Item to the element designated by Node,
null; -- per certain semantic constraints, described as follows.
-- If Item is equivalent to the element, then element is replaced and
-- there's nothing else to do. This is the easy case.
-- If Item is not equivalent, then the node will (possibly) have to move
-- to some other place in the tree. This is slighly more complicated,
-- because we must ensure that Item is not equivalent to some other
-- element in the tree (in which case, the replacement is not allowed).
-- Determine whether Item is equivalent to element on the specified
-- node.
begin
B := B + 1;
L := L + 1;
Compare := (if Item < Node.Element.all then False
elsif Node.Element.all < Item then False
else True);
L := L - 1;
B := B - 1;
exception
when others =>
L := L - 1;
B := B - 1;
raise;
end;
if Compare then
-- Item is equivalent to the node's element, so we will not have to
-- move the node.
else
if Tree.Lock > 0 then if Tree.Lock > 0 then
raise Program_Error with raise Program_Error with
"attempt to tamper with elements (set is locked)"; "attempt to tamper with elements (set is locked)";
...@@ -1914,12 +1955,62 @@ package body Ada.Containers.Indefinite_Ordered_Sets is ...@@ -1914,12 +1955,62 @@ package body Ada.Containers.Indefinite_Ordered_Sets is
return; return;
end if; end if;
-- The replacement Item is not equivalent to the element on the
-- specified node, which means that it will need to be re-inserted in a
-- different position in the tree. We must now determine whether Item is
-- equivalent to some other element in the tree (which would prohibit
-- the assignment and hence the move).
-- Ceiling returns the smallest element equivalent or greater than the
-- specified Item; if there is no such element, then it returns null.
Hint := Element_Keys.Ceiling (Tree, Item); Hint := Element_Keys.Ceiling (Tree, Item);
if Hint = null then if Hint /= null then
null; begin
B := B + 1;
L := L + 1;
Compare := Item < Hint.Element.all;
L := L - 1;
B := B - 1;
exception
when others =>
L := L - 1;
B := B - 1;
raise;
end;
if not Compare then -- Item >= Hint.Element
-- Ceiling returns an element that is equivalent or greater than
-- Item. If Item is "not less than" the element, then by
-- elimination we know that Item is equivalent to the element.
-- But this means that it is not possible to assign the value of
-- Item to the specified element (on Node), because a different
-- element (on Hint) equivalent to Item already exsits. (Were we
-- to change Node's element value, we would have to move Node, but
-- we would be unable to move the Node, because its new position
-- in the tree is already occupied by an equivalent element.)
raise Program_Error with "attempt to replace existing element";
end if;
-- Item is not equivalent to any other element in the tree, so it is
-- safe to assign the value of Item to Node.Element. This means that
-- the node will have to move to a different position in the tree
-- (because its element will have a different value).
-- The nearest (greater) neighbor of Item is Hint. This will be the
-- insertion position of Node (because its element will have Item as
-- its new value).
-- If Node equals Hint, the relative position of Node does not
-- change. This allows us to perform an optimization: we need not
-- remove Node from the tree and then reinsert it with its new value,
-- because it would only be placed in the exact same position.
elsif Item < Hint.Element.all then
if Hint = Node then if Hint = Node then
if Tree.Lock > 0 then if Tree.Lock > 0 then
raise Program_Error with raise Program_Error with
...@@ -1940,12 +2031,15 @@ package body Ada.Containers.Indefinite_Ordered_Sets is ...@@ -1940,12 +2031,15 @@ package body Ada.Containers.Indefinite_Ordered_Sets is
return; return;
end if; end if;
else
pragma Assert (not (Hint.Element.all < Item));
raise Program_Error with "attempt to replace existing element";
end if; end if;
-- If we get here, it is because Item was greater than all elements in
-- the tree (Hint = null), or because Item was less than some element at
-- a different place in the tree (Item < Hint.Element.all). In either
-- case, we remove Node from the tree (without actually deallocating
-- it), and then insert Item into the tree, onto the same Node (so no
-- new node is actually allocated).
Tree_Operations.Delete_Node_Sans_Free (Tree, Node); -- Checks busy-bit Tree_Operations.Delete_Node_Sans_Free (Tree, Node); -- Checks busy-bit
Local_Insert_With_Hint Local_Insert_With_Hint
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2004-2012, Free Software Foundation, Inc. -- -- Copyright (C) 2004-2013, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -987,12 +987,15 @@ package body Ada.Containers.Ordered_Sets is ...@@ -987,12 +987,15 @@ package body Ada.Containers.Ordered_Sets is
B : Natural renames Tree.Busy; B : Natural renames Tree.Busy;
L : Natural renames Tree.Lock; L : Natural renames Tree.Lock;
Eq : Boolean;
begin begin
B := B + 1; B := B + 1;
L := L + 1; L := L + 1;
begin begin
Process (E); Process (E);
Eq := Equivalent_Keys (K, Key (E));
exception exception
when others => when others =>
L := L - 1; L := L - 1;
...@@ -1003,7 +1006,7 @@ package body Ada.Containers.Ordered_Sets is ...@@ -1003,7 +1006,7 @@ package body Ada.Containers.Ordered_Sets is
L := L - 1; L := L - 1;
B := B - 1; B := B - 1;
if Equivalent_Keys (K, Key (E)) then if Eq then
return; return;
end if; end if;
end; end;
...@@ -1716,17 +1719,55 @@ package body Ada.Containers.Ordered_Sets is ...@@ -1716,17 +1719,55 @@ package body Ada.Containers.Ordered_Sets is
return Node; return Node;
end New_Node; end New_Node;
Hint : Node_Access; Hint : Node_Access;
Result : Node_Access; Result : Node_Access;
Inserted : Boolean; Inserted : Boolean;
Compare : Boolean;
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
B : Natural renames Tree.Busy;
L : Natural renames Tree.Lock;
-- Start of processing for Replace_Element -- Start of processing for Replace_Element
begin begin
if Item < Node.Element or else Node.Element < Item then -- Replace_Element assigns value Item to the element designated by Node,
null; -- per certain semantic constraints.
-- If Item is equivalent to the element, then element is replaced and
-- there's nothing else to do. This is the easy case.
-- If Item is not equivalent, then the node will (possibly) have to move
-- to some other place in the tree. This is slighly more complicated,
-- because we must ensure that Item is not equivalent to some other
-- element in the tree (in which case, the replacement is not allowed).
-- Determine whether Item is equivalent to element on the specified
-- node.
begin
B := B + 1;
L := L + 1;
Compare := (if Item < Node.Element then False
elsif Node.Element < Item then False
else True);
L := L - 1;
B := B - 1;
exception
when others =>
L := L - 1;
B := B - 1;
raise;
end;
if Compare then
-- Item is equivalent to the node's element, so we will not have to
-- move the node.
else
if Tree.Lock > 0 then if Tree.Lock > 0 then
raise Program_Error with raise Program_Error with
"attempt to tamper with elements (set is locked)"; "attempt to tamper with elements (set is locked)";
...@@ -1736,12 +1777,62 @@ package body Ada.Containers.Ordered_Sets is ...@@ -1736,12 +1777,62 @@ package body Ada.Containers.Ordered_Sets is
return; return;
end if; end if;
-- The replacement Item is not equivalent to the element on the
-- specified node, which means that it will need to be re-inserted in a
-- different position in the tree. We must now determine whether Item is
-- equivalent to some other element in the tree (which would prohibit
-- the assignment and hence the move).
-- Ceiling returns the smallest element equivalent or greater than the
-- specified Item; if there is no such element, then it returns null.
Hint := Element_Keys.Ceiling (Tree, Item); Hint := Element_Keys.Ceiling (Tree, Item);
if Hint = null then if Hint /= null then
null; begin
B := B + 1;
L := L + 1;
Compare := Item < Hint.Element;
L := L - 1;
B := B - 1;
exception
when others =>
L := L - 1;
B := B - 1;
raise;
end;
if not Compare then -- Item >= Hint.Element
-- Ceiling returns an element that is equivalent or greater than
-- Item. If Item is "not less than" the element, then by
-- elimination we know that Item is equivalent to the element.
-- But this means that it is not possible to assign the value of
-- Item to the specified element (on Node), because a different
-- element (on Hint) equivalent to Item already exsits. (Were we
-- to change Node's element value, we would have to move Node, but
-- we would be unable to move the Node, because its new position
-- in the tree is already occupied by an equivalent element.)
raise Program_Error with "attempt to replace existing element";
end if;
-- Item is not equivalent to any other element in the tree, so it is
-- safe to assign the value of Item to Node.Element. This means that
-- the node will have to move to a different position in the tree
-- (because its element will have a different value).
-- The nearest (greater) neighbor of Item is Hint. This will be the
-- insertion position of Node (because its element will have Item as
-- its new value).
-- If Node equals Hint, the relative position of Node does not
-- change. This allows us to perform an optimization: we need not
-- remove Node from the tree and then reinsert it with its new value,
-- because it would only be placed in the exact same position.
elsif Item < Hint.Element then
if Hint = Node then if Hint = Node then
if Tree.Lock > 0 then if Tree.Lock > 0 then
raise Program_Error with raise Program_Error with
...@@ -1751,15 +1842,18 @@ package body Ada.Containers.Ordered_Sets is ...@@ -1751,15 +1842,18 @@ package body Ada.Containers.Ordered_Sets is
Node.Element := Item; Node.Element := Item;
return; return;
end if; end if;
else
pragma Assert (not (Hint.Element < Item));
raise Program_Error with "attempt to replace existing element";
end if; end if;
-- If we get here, it is because Item was greater than all elements in
-- the tree (Hint = null), or because Item was less than some element at
-- a different place in the tree (Item < Hint.Element). In either case,
-- we remove Node from the tree (without actually deallocating it), and
-- then insert Item into the tree, onto the same Node (so no new node is
-- actually allocated).
Tree_Operations.Delete_Node_Sans_Free (Tree, Node); -- Checks busy-bit Tree_Operations.Delete_Node_Sans_Free (Tree, Node); -- Checks busy-bit
Local_Insert_With_Hint Local_Insert_With_Hint -- use unconditional insert here instead???
(Tree => Tree, (Tree => Tree,
Position => Hint, Position => Hint,
Key => Item, Key => Item,
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2004-2009, Free Software Foundation, Inc. -- -- Copyright (C) 2004-2013, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -626,9 +626,17 @@ package body Ada.Containers.Red_Black_Trees.Generic_Operations is ...@@ -626,9 +626,17 @@ package body Ada.Containers.Red_Black_Trees.Generic_Operations is
------------------- -------------------
function Generic_Equal (Left, Right : Tree_Type) return Boolean is function Generic_Equal (Left, Right : Tree_Type) return Boolean is
BL : Natural renames Left'Unrestricted_Access.Busy;
LL : Natural renames Left'Unrestricted_Access.Lock;
BR : Natural renames Right'Unrestricted_Access.Busy;
LR : Natural renames Right'Unrestricted_Access.Lock;
L_Node : Node_Access; L_Node : Node_Access;
R_Node : Node_Access; R_Node : Node_Access;
Result : Boolean;
begin begin
if Left'Address = Right'Address then if Left'Address = Right'Address then
return True; return True;
...@@ -638,18 +646,44 @@ package body Ada.Containers.Red_Black_Trees.Generic_Operations is ...@@ -638,18 +646,44 @@ package body Ada.Containers.Red_Black_Trees.Generic_Operations is
return False; return False;
end if; end if;
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
BL := BL + 1;
LL := LL + 1;
BR := BR + 1;
LR := LR + 1;
L_Node := Left.First; L_Node := Left.First;
R_Node := Right.First; R_Node := Right.First;
Result := True;
while L_Node /= null loop while L_Node /= null loop
if not Is_Equal (L_Node, R_Node) then if not Is_Equal (L_Node, R_Node) then
return False; Result := False;
exit;
end if; end if;
L_Node := Next (L_Node); L_Node := Next (L_Node);
R_Node := Next (R_Node); R_Node := Next (R_Node);
end loop; end loop;
return True; BL := BL - 1;
LL := LL - 1;
BR := BR - 1;
LR := LR - 1;
return Result;
exception
when others =>
BL := BL - 1;
LL := LL - 1;
BR := BR - 1;
LR := LR - 1;
raise;
end Generic_Equal; end Generic_Equal;
----------------------- -----------------------
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2004-2011, Free Software Foundation, Inc. -- -- Copyright (C) 2004-2013, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -606,9 +606,17 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is ...@@ -606,9 +606,17 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
------------------- -------------------
function Generic_Equal (Left, Right : Tree_Type'Class) return Boolean is function Generic_Equal (Left, Right : Tree_Type'Class) return Boolean is
BL : Natural renames Left'Unrestricted_Access.Busy;
LL : Natural renames Left'Unrestricted_Access.Lock;
BR : Natural renames Right'Unrestricted_Access.Busy;
LR : Natural renames Right'Unrestricted_Access.Lock;
L_Node : Count_Type; L_Node : Count_Type;
R_Node : Count_Type; R_Node : Count_Type;
Result : Boolean;
begin begin
if Left'Address = Right'Address then if Left'Address = Right'Address then
return True; return True;
...@@ -618,18 +626,43 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is ...@@ -618,18 +626,43 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
return False; return False;
end if; end if;
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
BL := BL + 1;
LL := LL + 1;
BR := BR + 1;
LR := LR + 1;
L_Node := Left.First; L_Node := Left.First;
R_Node := Right.First; R_Node := Right.First;
while L_Node /= 0 loop while L_Node /= 0 loop
if not Is_Equal (Left.Nodes (L_Node), Right.Nodes (R_Node)) then if not Is_Equal (Left.Nodes (L_Node), Right.Nodes (R_Node)) then
return False; Result := False;
exit;
end if; end if;
L_Node := Next (Left, L_Node); L_Node := Next (Left, L_Node);
R_Node := Next (Right, R_Node); R_Node := Next (Right, R_Node);
end loop; end loop;
return True; BL := BL - 1;
LL := LL - 1;
BR := BR - 1;
LR := LR - 1;
return Result;
exception
when others =>
BL := BL - 1;
LL := LL - 1;
BR := BR - 1;
LR := LR - 1;
raise;
end Generic_Equal; end Generic_Equal;
----------------------- -----------------------
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* * * *
* C Implementation File * * C Implementation File *
* * * *
* Copyright (C) 1992-2012, Free Software Foundation, Inc. * * Copyright (C) 1992-2013, Free Software Foundation, Inc. *
* * * *
* GNAT is free software; you can redistribute it and/or modify it under * * GNAT is free software; you can redistribute it and/or modify it under *
* terms of the GNU General Public License as published by the Free Soft- * * terms of the GNU General Public License as published by the Free Soft- *
...@@ -40,6 +40,9 @@ ...@@ -40,6 +40,9 @@
#include "adaint.h" #include "adaint.h"
/* We need L_tmpnam definition */
#include <stdio.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
...@@ -135,7 +138,18 @@ put_char_stderr (int c) ...@@ -135,7 +138,18 @@ put_char_stderr (int c)
char * char *
mktemp (char *template) mktemp (char *template)
{ {
#if !(defined (__RTP__) || defined (VTHREADS))
static char buf[L_tmpnam]; /* Internal buffer for name */
/* If parameter is NULL use internal buffer */
if (template == NULL)
template = buf;
__gnat_tmp_name (template);
return template;
#else
return tmpnam (NULL); return tmpnam (NULL);
#endif
} }
#endif #endif
......
...@@ -134,7 +134,7 @@ package body Debug is ...@@ -134,7 +134,7 @@ package body Debug is
-- d.N Add node to all entities -- d.N Add node to all entities
-- d.O Dump internal SCO tables -- d.O Dump internal SCO tables
-- d.P Previous (non-optimized) handling of length comparisons -- d.P Previous (non-optimized) handling of length comparisons
-- d.Q -- d.Q Flow Analysis mode for gnat2why
-- d.R Restrictions in ali files in positional form -- d.R Restrictions in ali files in positional form
-- d.S Force Optimize_Alignment (Space) -- d.S Force Optimize_Alignment (Space)
-- d.T Force Optimize_Alignment (Time) -- d.T Force Optimize_Alignment (Time)
...@@ -648,6 +648,9 @@ package body Debug is ...@@ -648,6 +648,9 @@ package body Debug is
-- This is there in case we find a situation where the optimization -- This is there in case we find a situation where the optimization
-- malfunctions, to provide a work around. -- malfunctions, to provide a work around.
-- d.Q Flow Analysis mode for gnat2why. When this flag is given,
-- gnat2why will do flow analysis, and no translation to Why is done.
-- d.R As documented in lib-writ.ads, restrictions in the ali file can -- d.R As documented in lib-writ.ads, restrictions in the ali file can
-- have two forms, positional and named. The named notation is the -- have two forms, positional and named. The named notation is the
-- current preferred form, but the use of this debug switch will force -- current preferred form, but the use of this debug switch will force
......
...@@ -4825,10 +4825,146 @@ package body Exp_Ch3 is ...@@ -4825,10 +4825,146 @@ package body Exp_Ch3 is
-- which case the init proc call must be inserted only after the bodies -- which case the init proc call must be inserted only after the bodies
-- of the shared variable procedures have been seen. -- of the shared variable procedures have been seen.
function Build_Equivalent_Aggregate return Boolean;
-- If the object has a constrained discriminated type and no initial
-- value, it may be possible to build an equivalent aggregate instead,
-- and prevent an actual call to the initialization procedure.
function Rewrite_As_Renaming return Boolean; function Rewrite_As_Renaming return Boolean;
-- Indicate whether to rewrite a declaration with initialization into an -- Indicate whether to rewrite a declaration with initialization into an
-- object renaming declaration (see below). -- object renaming declaration (see below).
--------------------------------
-- Build_Equivalent_Aggregate --
--------------------------------
function Build_Equivalent_Aggregate return Boolean is
Aggr : Node_Id;
Comp : Entity_Id;
Discr : Elmt_Id;
Full_Type : Entity_Id;
begin
Full_Type := Typ;
if Is_Private_Type (Typ)
and then Present (Full_View (Typ))
then
Full_Type := Full_View (Typ);
end if;
-- Only perform this transformation if Elaboration_Code is forbidden
-- or undesirable, and if this is a global entity of a constrained
-- record type.
-- If Initialize_Scalars might be active this transformation cannot
-- be performed either, because it will lead to different semantics
-- or because elaboration code will in fact be created.
if Ekind (Full_Type) /= E_Record_Subtype
or else not Has_Discriminants (Full_Type)
or else not Is_Constrained (Full_Type)
or else Is_Controlled (Full_Type)
or else Is_Limited_Type (Full_Type)
or else not Restriction_Active (No_Initialize_Scalars)
then
return False;
end if;
if Ekind (Current_Scope) = E_Package
and then
(Restriction_Active (No_Elaboration_Code)
or else Is_Preelaborated (Current_Scope))
then
-- Building a static aggregate is possible if the discriminants
-- have static values and the other components have static
-- defaults or none.
Discr := First_Elmt (Discriminant_Constraint (Full_Type));
while Present (Discr) loop
if not Is_OK_Static_Expression (Node (Discr)) then
return False;
end if;
Next_Elmt (Discr);
end loop;
-- Check that initialized components are OK, and that non-
-- initialized components do not require a call to their own
-- initialization procedure.
Comp := First_Component (Full_Type);
while Present (Comp) loop
if Ekind (Comp) = E_Component
and then Present (Expression (Parent (Comp)))
and then
not Is_OK_Static_Expression (Expression (Parent (Comp)))
then
return False;
elsif Has_Non_Null_Base_Init_Proc (Etype (Comp)) then
return False;
end if;
Next_Component (Comp);
end loop;
-- Everything is static, assemble the aggregate, discriminant
-- values first.
Aggr :=
Make_Aggregate (Loc,
Expressions => New_List,
Component_Associations => New_List);
Discr := First_Elmt (Discriminant_Constraint (Full_Type));
while Present (Discr) loop
Append_To (Expressions (Aggr), New_Copy (Node (Discr)));
Next_Elmt (Discr);
end loop;
-- Now collect values of initialized components.
Comp := First_Component (Full_Type);
while Present (Comp) loop
if Ekind (Comp) = E_Component
and then Present (Expression (Parent (Comp)))
then
Append_To (Component_Associations (Aggr),
Make_Component_Association (Loc,
Choices => New_List (New_Occurrence_Of (Comp, Loc)),
Expression => New_Copy_Tree
(Expression (Parent (Comp)))));
end if;
Next_Component (Comp);
end loop;
-- Finally, box-initialize remaining components.
Append_To (Component_Associations (Aggr),
Make_Component_Association (Loc,
Choices => New_List (Make_Others_Choice (Loc)),
Expression => Empty));
Set_Box_Present (Last (Component_Associations (Aggr)));
Set_Expression (N, Aggr);
if Typ /= Full_Type then
Analyze_And_Resolve (Aggr, Full_View (Base_Type (Full_Type)));
Rewrite (Aggr, Unchecked_Convert_To (Typ, Aggr));
Analyze_And_Resolve (Aggr, Typ);
else
Analyze_And_Resolve (Aggr, Full_Type);
end if;
return True;
else
return False;
end if;
end Build_Equivalent_Aggregate;
------------------------- -------------------------
-- Rewrite_As_Renaming -- -- Rewrite_As_Renaming --
------------------------- -------------------------
...@@ -5033,6 +5169,14 @@ package body Exp_Ch3 is ...@@ -5033,6 +5169,14 @@ package body Exp_Ch3 is
(N, New_Copy_Tree (Init_Expr, New_Scope => Current_Scope)); (N, New_Copy_Tree (Init_Expr, New_Scope => Current_Scope));
return; return;
-- If type has discriminants, try to build equivalent
-- aggregate using discriminant values from the declaration.
-- This is a useful optimization, in particular if restriction
-- No_Elaboration_Code is active.
elsif Build_Equivalent_Aggregate then
return;
else else
Initialization_Warning (Id_Ref); Initialization_Warning (Id_Ref);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2001-2012, Free Software Foundation, Inc. -- -- Copyright (C) 2001-2013, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -365,7 +365,6 @@ package body Prj.Attr is ...@@ -365,7 +365,6 @@ package body Prj.Attr is
-- package Remote -- package Remote
"Premote#" & "Premote#" &
"LVbuild_slaves#" &
"SVroot_dir#" & "SVroot_dir#" &
-- package Stack -- package Stack
......
...@@ -1271,6 +1271,15 @@ package body Prj.Makr is ...@@ -1271,6 +1271,15 @@ package body Prj.Makr is
new String'(Get_Name_String (Tmp_File)); new String'(Get_Name_String (Tmp_File));
end if; end if;
-- On VMS, a file created with Create_Temp_File cannot
-- be used to redirect output.
if Hostparm.OpenVMS then
Close (FD);
Delete_File (Temp_File_Name.all, Success);
FD := Create_Output_Text_File (Temp_File_Name.all);
end if;
Args (Args'Last) := new String' Args (Args'Last) := new String'
(Dir_Name & (Dir_Name &
Directory_Separator & Directory_Separator &
......
...@@ -1101,31 +1101,6 @@ The following attributes can be defined in package @code{Remote}: ...@@ -1101,31 +1101,6 @@ The following attributes can be defined in package @code{Remote}:
@table @asis @table @asis
@item @b{Build_Slaves}
@cindex @code{Build_Slaves}
A list of string referencing the remote build slaves to use for the
compilation phase. The format is:
@code{[protocol://]name.domain[:port]}.
Where @code{protocol} is one of:
@table @asis
@item rsync
@cindex @code{rsync}
The sources are copied using the external @code{rsync} tool.
@item file
The sources are accessed via a shared directory or mount point.
@end table
The default port used to communicate with @command{gprslave} is
@code{8484}.
@item @b{Root_Dir}: @item @b{Root_Dir}:
@cindex @code{Root_Dir} @cindex @code{Root_Dir}
......
...@@ -1205,7 +1205,6 @@ package Snames is ...@@ -1205,7 +1205,6 @@ package Snames is
Name_Archive_Suffix : constant Name_Id := N + $; Name_Archive_Suffix : constant Name_Id := N + $;
Name_Binder : constant Name_Id := N + $; Name_Binder : constant Name_Id := N + $;
Name_Body_Suffix : constant Name_Id := N + $; Name_Body_Suffix : constant Name_Id := N + $;
Name_Build_Slaves : constant Name_Id := N + $;
Name_Builder : constant Name_Id := N + $; Name_Builder : constant Name_Id := N + $;
Name_Clean : constant Name_Id := N + $; Name_Clean : constant Name_Id := N + $;
Name_Compiler : constant Name_Id := N + $; Name_Compiler : constant Name_Id := N + $;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2013, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -46,7 +46,7 @@ package Urealp is ...@@ -46,7 +46,7 @@ package Urealp is
-- use the UR_Eq function). -- use the UR_Eq function).
-- A Ureal value represents an arbitrary precision universal real value, -- A Ureal value represents an arbitrary precision universal real value,
-- stored internally using four components -- stored internally using four components:
-- the numerator (Uint, always non-negative) -- the numerator (Uint, always non-negative)
-- the denominator (Uint, always non-zero, always positive if base = 0) -- the denominator (Uint, always non-zero, always positive if base = 0)
...@@ -125,7 +125,7 @@ package Urealp is ...@@ -125,7 +125,7 @@ package Urealp is
-- Returns value 10.0 ** 36 -- Returns value 10.0 ** 36
function Ureal_M_10_36 return Ureal; function Ureal_M_10_36 return Ureal;
-- Returns value -(10.0 -- Returns value -10.0 ** 36
----------------- -----------------
-- Subprograms -- -- Subprograms --
......
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