Commit d5fa5335 by Hristian Kirtchev Committed by Arnaud Charlet

exp_ch6.adb (Expand_N_Extended_Return_Statement): Use New_Copy_Tree instead of…

exp_ch6.adb (Expand_N_Extended_Return_Statement): Use New_Copy_Tree instead of Relocate_Node as any subsequent copies of the...

2017-04-28  Hristian Kirtchev  <kirtchev@adacore.com>

	* exp_ch6.adb (Expand_N_Extended_Return_Statement): Use
	New_Copy_Tree instead of Relocate_Node as any subsequent copies
	of the relocated node will have mangled Parent pointers.
	* sem_util.adb (Build_NCT_Hash_Tables): Reset both hash
	tables used in conjunction with entity and itype replication.
	(Visit_Entity): Rewrite the restriction on which entities
	require duplication.  The restriction now includes all types.

2017-04-28  Hristian Kirtchev  <kirtchev@adacore.com>

	* a-cofuse.ads, a-cfdlli.ads, a-cfhase.adb, a-cfhase.ads, a-cfinve.adb,
	a-cfinve.ads, a-cforma.adb, a-cforma.ads, a-cofuma.adb, a-cofuma.ads,
	a-cfhama.adb, a-cfhama.ads, a-cforse.adb: Minor reformatting and code
	cleanups.

From-SVN: r247384
parent ef952fd5
2017-04-28 Hristian Kirtchev <kirtchev@adacore.com> 2017-04-28 Hristian Kirtchev <kirtchev@adacore.com>
* exp_ch6.adb (Expand_N_Extended_Return_Statement): Use
New_Copy_Tree instead of Relocate_Node as any subsequent copies
of the relocated node will have mangled Parent pointers.
* sem_util.adb (Build_NCT_Hash_Tables): Reset both hash
tables used in conjunction with entity and itype replication.
(Visit_Entity): Rewrite the restriction on which entities
require duplication. The restriction now includes all types.
2017-04-28 Hristian Kirtchev <kirtchev@adacore.com>
* a-cofuse.ads, a-cfdlli.ads, a-cfhase.adb, a-cfhase.ads, a-cfinve.adb,
a-cfinve.ads, a-cforma.adb, a-cforma.ads, a-cofuma.adb, a-cofuma.ads,
a-cfhama.adb, a-cfhama.ads, a-cforse.adb: Minor reformatting and code
cleanups.
2017-04-28 Hristian Kirtchev <kirtchev@adacore.com>
* exp_util.adb, g-dyntab.adb, par-ch4.adb, sem_util.adb, sem_attr.adb, * exp_util.adb, g-dyntab.adb, par-ch4.adb, sem_util.adb, sem_attr.adb,
gnat1drv.adb, exp_disp.adb, namet.adb, alloc.ads: Minor reformatting. gnat1drv.adb, exp_disp.adb, namet.adb, alloc.ads: Minor reformatting.
......
...@@ -1541,9 +1541,9 @@ is ...@@ -1541,9 +1541,9 @@ is
Post => Post =>
M_Elements_Sorted'Result = M_Elements_Sorted'Result =
(for all I in 1 .. M.Length (Container) => (for all I in 1 .. M.Length (Container) =>
(for all J in I .. M.Length (Container) => (for all J in I .. M.Length (Container) =>
Element (Container, I) = Element (Container, J) Element (Container, I) = Element (Container, J)
or Element (Container, I) < Element (Container, J))); or Element (Container, I) < Element (Container, J)));
pragma Annotate (GNATprove, Inline_For_Proof, M_Elements_Sorted); pragma Annotate (GNATprove, Inline_For_Proof, M_Elements_Sorted);
end Formal_Model; end Formal_Model;
......
...@@ -370,7 +370,9 @@ is ...@@ -370,7 +370,9 @@ is
-- Find -- -- Find --
---------- ----------
function Find (Container : K.Sequence; Key : Key_Type) return Count_Type function Find
(Container : K.Sequence;
Key : Key_Type) return Count_Type
is is
begin begin
for I in 1 .. K.Length (Container) loop for I in 1 .. K.Length (Container) loop
...@@ -385,8 +387,9 @@ is ...@@ -385,8 +387,9 @@ is
-- K_Keys_Included -- -- K_Keys_Included --
--------------------- ---------------------
function K_Keys_Included (Left : K.Sequence; function K_Keys_Included
Right : K.Sequence) return Boolean (Left : K.Sequence;
Right : K.Sequence) return Boolean
is is
begin begin
for I in 1 .. K.Length (Left) loop for I in 1 .. K.Length (Left) loop
......
...@@ -126,8 +126,8 @@ is ...@@ -126,8 +126,8 @@ is
Global => null, Global => null,
Post => Post =>
(if Find'Result > 0 then (if Find'Result > 0 then
Find'Result <= K.Length (Container) Find'Result <= K.Length (Container)
and Equivalent_Keys (Key, K.Get (Container, Find'Result))); and Equivalent_Keys (Key, K.Get (Container, Find'Result)));
function K_Keys_Included function K_Keys_Included
(Left : K.Sequence; (Left : K.Sequence;
...@@ -139,9 +139,9 @@ is ...@@ -139,9 +139,9 @@ is
Post => Post =>
K_Keys_Included'Result = K_Keys_Included'Result =
(for all I in 1 .. K.Length (Left) => (for all I in 1 .. K.Length (Left) =>
Find (Right, K.Get (Left, I)) > 0 Find (Right, K.Get (Left, I)) > 0
and then K.Get (Right, Find (Right, K.Get (Left, I))) = and then K.Get (Right, Find (Right, K.Get (Left, I))) =
K.Get (Left, I)); K.Get (Left, I));
package P is new Ada.Containers.Functional_Maps package P is new Ada.Containers.Functional_Maps
(Key_Type => Cursor, (Key_Type => Cursor,
...@@ -203,14 +203,15 @@ is ...@@ -203,14 +203,15 @@ is
-- It only contains keys contained in Model -- It only contains keys contained in Model
and (for all Key of Keys'Result => and (for all Key of Keys'Result =>
M.Has_Key (Model (Container), Key)) M.Has_Key (Model (Container), Key))
-- It contains all the keys contained in Model -- It contains all the keys contained in Model
and (for all Key of Model (Container) => and (for all Key of Model (Container) =>
(Find (Keys'Result, Key) > 0 (Find (Keys'Result, Key) > 0
and then Equivalent_Keys and then Equivalent_Keys
(K.Get (Keys'Result, Find (Keys'Result, Key)), Key))) (K.Get (Keys'Result, Find (Keys'Result, Key)),
Key)))
-- It has no duplicate -- It has no duplicate
...@@ -221,7 +222,8 @@ is ...@@ -221,7 +222,8 @@ is
(for all J in 1 .. Length (Container) => (for all J in 1 .. Length (Container) =>
(if Equivalent_Keys (if Equivalent_Keys
(K.Get (Keys'Result, I), K.Get (Keys'Result, J)) (K.Get (Keys'Result, I), K.Get (Keys'Result, J))
then I = J))); then
I = J)));
pragma Annotate (GNATprove, Iterable_For_Proof, "Model", Keys); pragma Annotate (GNATprove, Iterable_For_Proof, "Model", Keys);
function Positions (Container : Map) return P.Map with function Positions (Container : Map) return P.Map with
...@@ -246,7 +248,7 @@ is ...@@ -246,7 +248,7 @@ is
and then and then
(for all J of Positions'Result => (for all J of Positions'Result =>
(if P.Get (Positions'Result, I) = P.Get (Positions'Result, J) (if P.Get (Positions'Result, I) = P.Get (Positions'Result, J)
then I = J))); then I = J)));
procedure Lift_Abstraction_Level (Container : Map) with procedure Lift_Abstraction_Level (Container : Map) with
-- Lift_Abstraction_Level is a ghost procedure that does nothing but -- Lift_Abstraction_Level is a ghost procedure that does nothing but
...@@ -547,9 +549,9 @@ is ...@@ -547,9 +549,9 @@ is
-- Key is inserted in Container -- Key is inserted in Container
and K.Get (Keys (Container), and K.Get
P.Get (Positions (Container), Find (Container, Key))) = (Keys (Container),
Key P.Get (Positions (Container), Find (Container, Key))) = Key
-- Mapping from cursors to keys is preserved -- Mapping from cursors to keys is preserved
......
...@@ -705,12 +705,11 @@ is ...@@ -705,12 +705,11 @@ is
function "<" (Left : Holder; Right : Holder) return Boolean is function "<" (Left : Holder; Right : Holder) return Boolean is
(E (Left) < E (Right)); (E (Left) < E (Right));
procedure Sort is procedure Sort is new Generic_Array_Sort
new Generic_Array_Sort (Index_Type => Array_Index,
(Index_Type => Array_Index, Element_Type => Holder,
Element_Type => Holder, Array_Type => Elements_Array,
Array_Type => Elements_Array, "<" => "<");
"<" => "<");
Len : constant Capacity_Range := Length (Container); Len : constant Capacity_Range := Length (Container);
...@@ -1065,8 +1064,9 @@ is ...@@ -1065,8 +1064,9 @@ is
then then
Reserve_Capacity Reserve_Capacity
(Container, (Container,
Capacity_Range'Max (Current_Capacity (Container) * Growth_Factor, Capacity_Range'Max
Capacity_Range (New_Length))); (Current_Capacity (Container) * Growth_Factor,
Capacity_Range (New_Length)));
end if; end if;
declare declare
...@@ -1348,10 +1348,10 @@ is ...@@ -1348,10 +1348,10 @@ is
-- hence we also know that -- hence we also know that
-- Index - Index_Type'First >= 0 -- Index - Index_Type'First >= 0
-- The issue is that even though 0 is guaranteed to be a value in -- The issue is that even though 0 is guaranteed to be a value in the
-- the type Index_Type'Base, there's no guarantee that the difference -- type Index_Type'Base, there's no guarantee that the difference is a
-- is a value in that type. To prevent overflow we use the wider -- value in that type. To prevent overflow we use the wider of
-- of Count_Type'Base and Index_Type'Base to perform intermediate -- Count_Type'Base and Index_Type'Base to perform intermediate
-- calculations. -- calculations.
if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then
...@@ -1362,8 +1362,8 @@ is ...@@ -1362,8 +1362,8 @@ is
Count_Type'Base (Index_Type'First); Count_Type'Base (Index_Type'First);
end if; end if;
-- The array index subtype for all container element arrays -- The array index subtype for all container element arrays always
-- always starts with 1. -- starts with 1.
return 1 + Offset; return 1 + Offset;
end To_Array_Index; end To_Array_Index;
......
...@@ -830,9 +830,9 @@ is ...@@ -830,9 +830,9 @@ is
Post => Post =>
M_Elements_Sorted'Result = M_Elements_Sorted'Result =
(for all I in Index_Type'First .. M.Last (Container) => (for all I in Index_Type'First .. M.Last (Container) =>
(for all J in I .. M.Last (Container) => (for all J in I .. M.Last (Container) =>
Element (Container, I) = Element (Container, J) Element (Container, I) = Element (Container, J)
or Element (Container, I) < Element (Container, J))); or Element (Container, I) < Element (Container, J)));
pragma Annotate (GNATprove, Inline_For_Proof, M_Elements_Sorted); pragma Annotate (GNATprove, Inline_For_Proof, M_Elements_Sorted);
end Formal_Model; end Formal_Model;
......
...@@ -518,7 +518,9 @@ is ...@@ -518,7 +518,9 @@ is
-- Find -- -- Find --
---------- ----------
function Find (Container : K.Sequence; Key : Key_Type) return Count_Type function Find
(Container : K.Sequence;
Key : Key_Type) return Count_Type
is is
begin begin
for I in 1 .. K.Length (Container) loop for I in 1 .. K.Length (Container) loop
...@@ -634,9 +636,12 @@ is ...@@ -634,9 +636,12 @@ is
-- for their postconditions. -- for their postconditions.
while Position /= 0 loop while Position /= 0 loop
R := M.Add (Container => R, R :=
New_Key => Container.Nodes (Position).Key, M.Add
New_Item => Container.Nodes (Position).Element); (Container => R,
New_Key => Container.Nodes (Position).Key,
New_Item => Container.Nodes (Position).Element);
Position := Tree_Operations.Next (Container, Position); Position := Tree_Operations.Next (Container, Position);
end loop; end loop;
......
...@@ -159,16 +159,16 @@ is ...@@ -159,16 +159,16 @@ is
Pre => Position - 1 <= K.Length (Container), Pre => Position - 1 <= K.Length (Container),
Post => Post =>
K_Is_Find'Result = K_Is_Find'Result =
((if Position > 0 then
K_Bigger_Than_Range (Container, 1, Position - 1, Key))
((if Position > 0 then and
K_Bigger_Than_Range (Container, 1, Position - 1, Key)) (if Position < K.Length (Container) then
K_Smaller_Than_Range
and (if Position < K.Length (Container) then (Container,
K_Smaller_Than_Range Position + 1,
(Container, K.Length (Container),
Position + 1, Key)));
K.Length (Container),
Key)));
pragma Annotate (GNATprove, Inline_For_Proof, K_Is_Find); pragma Annotate (GNATprove, Inline_For_Proof, K_Is_Find);
function Find (Container : K.Sequence; Key : Key_Type) return Count_Type function Find (Container : K.Sequence; Key : Key_Type) return Count_Type
...@@ -178,8 +178,8 @@ is ...@@ -178,8 +178,8 @@ is
Global => null, Global => null,
Post => Post =>
(if Find'Result > 0 then (if Find'Result > 0 then
Find'Result <= K.Length (Container) Find'Result <= K.Length (Container)
and Equivalent_Keys (Key, K.Get (Container, Find'Result))); and Equivalent_Keys (Key, K.Get (Container, Find'Result)));
package P is new Ada.Containers.Functional_Maps package P is new Ada.Containers.Functional_Maps
(Key_Type => Cursor, (Key_Type => Cursor,
...@@ -246,20 +246,21 @@ is ...@@ -246,20 +246,21 @@ is
-- It only contains keys contained in Model -- It only contains keys contained in Model
and (for all Key of Keys'Result => and (for all Key of Keys'Result =>
M.Has_Key (Model (Container), Key)) M.Has_Key (Model (Container), Key))
-- It contains all the keys contained in Model -- It contains all the keys contained in Model
and (for all Key of Model (Container) => and (for all Key of Model (Container) =>
(Find (Keys'Result, Key) > 0 (Find (Keys'Result, Key) > 0
and then Equivalent_Keys and then Equivalent_Keys
(K.Get (Keys'Result, Find (Keys'Result, Key)), Key))) (K.Get (Keys'Result, Find (Keys'Result, Key)),
Key)))
-- It is sorted in increasing order -- It is sorted in increasing order
and (for all I in 1 .. Length (Container) => and (for all I in 1 .. Length (Container) =>
Find (Keys'Result, K.Get (Keys'Result, I)) = I Find (Keys'Result, K.Get (Keys'Result, I)) = I
and K_Is_Find (Keys'Result, K.Get (Keys'Result, I), I)); and K_Is_Find (Keys'Result, K.Get (Keys'Result, I), I));
pragma Annotate (GNATprove, Iterable_For_Proof, "Model", Keys); pragma Annotate (GNATprove, Iterable_For_Proof, "Model", Keys);
function Positions (Container : Map) return P.Map with function Positions (Container : Map) return P.Map with
...@@ -284,7 +285,7 @@ is ...@@ -284,7 +285,7 @@ is
and then and then
(for all J of Positions'Result => (for all J of Positions'Result =>
(if P.Get (Positions'Result, I) = P.Get (Positions'Result, J) (if P.Get (Positions'Result, I) = P.Get (Positions'Result, J)
then I = J))); then I = J)));
procedure Lift_Abstraction_Level (Container : Map) with procedure Lift_Abstraction_Level (Container : Map) with
-- Lift_Abstraction_Level is a ghost procedure that does nothing but -- Lift_Abstraction_Level is a ghost procedure that does nothing but
...@@ -942,7 +943,7 @@ is ...@@ -942,7 +943,7 @@ is
Contract_Cases => Contract_Cases =>
(Position = No_Element (Position = No_Element
or else P.Get (Positions (Container), Position) = 1 or else P.Get (Positions (Container), Position) = 1
=> =>
Position = No_Element, Position = No_Element,
others => others =>
...@@ -983,6 +984,7 @@ is ...@@ -983,6 +984,7 @@ is
Contract_Cases => Contract_Cases =>
(Length (Container) = 0 or else Key < First_Key (Container) => (Length (Container) = 0 or else Key < First_Key (Container) =>
Floor'Result = No_Element, Floor'Result = No_Element,
others => others =>
Has_Element (Container, Floor'Result) Has_Element (Container, Floor'Result)
and not (Key < K.Get (Keys (Container), and not (Key < K.Get (Keys (Container),
...@@ -999,9 +1001,9 @@ is ...@@ -999,9 +1001,9 @@ is
Ceiling'Result = No_Element, Ceiling'Result = No_Element,
others => others =>
Has_Element (Container, Ceiling'Result) Has_Element (Container, Ceiling'Result)
and and not (K.Get
not (K.Get (Keys (Container), (Keys (Container),
P.Get (Positions (Container), Ceiling'Result)) < Key) P.Get (Positions (Container), Ceiling'Result)) < Key)
and K_Is_Find and K_Is_Find
(Keys (Container), (Keys (Container),
Key, Key,
......
...@@ -608,6 +608,7 @@ is ...@@ -608,6 +608,7 @@ is
return False; return False;
end if; end if;
end loop; end loop;
return True; return True;
end E_Bigger_Than_Range; end E_Bigger_Than_Range;
...@@ -700,6 +701,7 @@ is ...@@ -700,6 +701,7 @@ is
end if; end if;
end loop; end loop;
end if; end if;
return True; return True;
end E_Is_Find; end E_Is_Find;
...@@ -719,6 +721,7 @@ is ...@@ -719,6 +721,7 @@ is
return False; return False;
end if; end if;
end loop; end loop;
return True; return True;
end E_Smaller_Than_Range; end E_Smaller_Than_Range;
...@@ -736,6 +739,7 @@ is ...@@ -736,6 +739,7 @@ is
return I; return I;
end if; end if;
end loop; end loop;
return 0; return 0;
end Find; end Find;
......
...@@ -152,8 +152,11 @@ package body Ada.Containers.Functional_Maps with SPARK_Mode => Off is ...@@ -152,8 +152,11 @@ package body Ada.Containers.Functional_Maps with SPARK_Mode => Off is
-- Has_Witness -- -- Has_Witness --
----------------- -----------------
function Has_Witness (Container : Map; Witness : Count_Type) return Boolean function Has_Witness
is (Witness in 1 .. Length (Container.Keys)); (Container : Map;
Witness : Count_Type) return Boolean
is
(Witness in 1 .. Length (Container.Keys));
-------------- --------------
-- Is_Empty -- -- Is_Empty --
...@@ -265,7 +268,9 @@ package body Ada.Containers.Functional_Maps with SPARK_Mode => Off is ...@@ -265,7 +268,9 @@ package body Ada.Containers.Functional_Maps with SPARK_Mode => Off is
-- W_Get -- -- W_Get --
----------- -----------
function W_Get (Container : Map; Witness : Count_Type) return Element_Type function W_Get
(Container : Map;
Witness : Count_Type) return Element_Type
is is
(Get (Container.Elements, Witness)); (Get (Container.Elements, Witness));
......
...@@ -35,9 +35,11 @@ private with Ada.Containers.Functional_Base; ...@@ -35,9 +35,11 @@ private with Ada.Containers.Functional_Base;
generic generic
type Key_Type (<>) is private; type Key_Type (<>) is private;
type Element_Type (<>) is private; type Element_Type (<>) is private;
with function Equivalent_Keys with function Equivalent_Keys
(Left : Key_Type; (Left : Key_Type;
Right : Key_Type) return Boolean is "="; Right : Key_Type) return Boolean is "=";
Enable_Handling_Of_Equivalence : Boolean := True; Enable_Handling_Of_Equivalence : Boolean := True;
-- This constant should only be set to False when no particular handling -- This constant should only be set to False when no particular handling
-- of equivalence over keys is needed, that is, Equivalent_Keys defines a -- of equivalence over keys is needed, that is, Equivalent_Keys defines a
...@@ -77,7 +79,7 @@ package Ada.Containers.Functional_Maps with SPARK_Mode is ...@@ -77,7 +79,7 @@ package Ada.Containers.Functional_Maps with SPARK_Mode is
-- Has_Key returns the same result on all equivalent keys -- Has_Key returns the same result on all equivalent keys
(if (for some K of Container => Equivalent_Keys (K, Key)) then (if (for some K of Container => Equivalent_Keys (K, Key)) then
Has_Key'Result)); Has_Key'Result));
function Get (Container : Map; Key : Key_Type) return Element_Type with function Get (Container : Map; Key : Key_Type) return Element_Type with
-- Return the element associated with Key in Container -- Return the element associated with Key in Container
...@@ -90,8 +92,8 @@ package Ada.Containers.Functional_Maps with SPARK_Mode is ...@@ -90,8 +92,8 @@ package Ada.Containers.Functional_Maps with SPARK_Mode is
-- Get returns the same result on all equivalent keys -- Get returns the same result on all equivalent keys
Get'Result = W_Get (Container, Witness (Container, Key)) Get'Result = W_Get (Container, Witness (Container, Key))
and (for all K of Container => and (for all K of Container =>
(Equivalent_Keys (K, Key) = (Equivalent_Keys (K, Key) =
(Witness (Container, Key) = Witness (Container, K))))); (Witness (Container, Key) = Witness (Container, K)))));
function Length (Container : Map) return Count_Type with function Length (Container : Map) return Count_Type with
......
...@@ -34,9 +34,11 @@ private with Ada.Containers.Functional_Base; ...@@ -34,9 +34,11 @@ private with Ada.Containers.Functional_Base;
generic generic
type Element_Type (<>) is private; type Element_Type (<>) is private;
with function Equivalent_Elements with function Equivalent_Elements
(Left : Element_Type; (Left : Element_Type;
Right : Element_Type) return Boolean is "="; Right : Element_Type) return Boolean is "=";
Enable_Handling_Of_Equivalence : Boolean := True; Enable_Handling_Of_Equivalence : Boolean := True;
-- This constant should only be set to False when no particular handling -- This constant should only be set to False when no particular handling
-- of equivalence over elements is needed, that is, Equivalent_Elements -- of equivalence over elements is needed, that is, Equivalent_Elements
...@@ -75,7 +77,7 @@ package Ada.Containers.Functional_Sets with SPARK_Mode is ...@@ -75,7 +77,7 @@ package Ada.Containers.Functional_Sets with SPARK_Mode is
-- Contains returns the same result on all equivalent elements -- Contains returns the same result on all equivalent elements
(if (for some E of Container => Equivalent_Elements (E, Item)) then (if (for some E of Container => Equivalent_Elements (E, Item)) then
Contains'Result)); Contains'Result));
function Length (Container : Set) return Count_Type with function Length (Container : Set) return Count_Type with
Global => null; Global => null;
...@@ -89,8 +91,7 @@ package Ada.Containers.Functional_Sets with SPARK_Mode is ...@@ -89,8 +91,7 @@ package Ada.Containers.Functional_Sets with SPARK_Mode is
-- Set inclusion -- Set inclusion
Global => null, Global => null,
Post => "<="'Result = (for all Item of Left => Contains (Right, Item)) Post => "<="'Result = (for all Item of Left => Contains (Right, Item));
and (if "<="'Result then Length (Left) <= Length (Right));
function "=" (Left : Set; Right : Set) return Boolean with function "=" (Left : Set; Right : Set) return Boolean with
-- Extensional equality over sets -- Extensional equality over sets
...@@ -187,7 +188,12 @@ package Ada.Containers.Functional_Sets with SPARK_Mode is ...@@ -187,7 +188,12 @@ package Ada.Containers.Functional_Sets with SPARK_Mode is
Global => null, Global => null,
Post => Post =>
Num_Overlaps'Result = Length (Intersection (Left, Right)); Num_Overlaps'Result = Length (Intersection (Left, Right))
and (if Left <= Right then Num_Overlaps'Result = Length (Left)
else Num_Overlaps'Result < Length (Left))
and (if Right <= Left then Num_Overlaps'Result = Length (Right)
else Num_Overlaps'Result < Length (Right))
and (Num_Overlaps'Result = 0) = No_Overlap (Left, Right);
---------------------------- ----------------------------
-- Construction Functions -- -- Construction Functions --
......
...@@ -4798,7 +4798,7 @@ package body Exp_Ch6 is ...@@ -4798,7 +4798,7 @@ package body Exp_Ch6 is
Init_Assignment := Init_Assignment :=
Make_Assignment_Statement (Loc, Make_Assignment_Statement (Loc,
Name => New_Occurrence_Of (Ret_Obj_Id, Loc), Name => New_Occurrence_Of (Ret_Obj_Id, Loc),
Expression => Relocate_Node (Ret_Obj_Expr)); Expression => New_Copy_Tree (Ret_Obj_Expr));
Set_Etype (Name (Init_Assignment), Etype (Ret_Obj_Id)); Set_Etype (Name (Init_Assignment), Etype (Ret_Obj_Id));
Set_Assignment_OK (Name (Init_Assignment)); Set_Assignment_OK (Name (Init_Assignment));
......
...@@ -17003,7 +17003,7 @@ package body Sem_Util is ...@@ -17003,7 +17003,7 @@ package body Sem_Util is
package NCT_Itype_Assoc is new Simple_HTable ( package NCT_Itype_Assoc is new Simple_HTable (
Header_Num => NCT_Header_Num, Header_Num => NCT_Header_Num,
Element => Entity_Id, Element => Node_Or_Entity_Id,
No_Element => Empty, No_Element => Empty,
Key => Entity_Id, Key => Entity_Id,
Hash => New_Copy_Hash, Hash => New_Copy_Hash,
...@@ -17114,37 +17114,45 @@ package body Sem_Util is ...@@ -17114,37 +17114,45 @@ package body Sem_Util is
--------------------------- ---------------------------
procedure Build_NCT_Hash_Tables is procedure Build_NCT_Hash_Tables is
Elmt : Elmt_Id; Assoc : Entity_Id;
Ent : Entity_Id; Elmt : Elmt_Id;
Key : Entity_Id;
Value : Entity_Id;
begin begin
if No (Map) then if No (Map) then
return; return;
end if; end if;
-- Clear both hash tables associated with entry replication since
-- multiple calls to New_Copy_Tree could cause multiple collisions
-- and produce long linked lists in individual buckets.
NCT_Assoc.Reset;
NCT_Itype_Assoc.Reset;
Elmt := First_Elmt (Map); Elmt := First_Elmt (Map);
while Present (Elmt) loop while Present (Elmt) loop
Ent := Node (Elmt);
-- Get new entity, and associate old and new -- Extract a (key, value) pair from the map
Key := Node (Elmt);
Next_Elmt (Elmt); Next_Elmt (Elmt);
NCT_Assoc.Set (Ent, Node (Elmt)); Value := Node (Elmt);
if Is_Type (Ent) then -- Add the pair in the association hash table
declare
Anode : constant Entity_Id :=
Associated_Node_For_Itype (Ent);
begin NCT_Assoc.Set (Key, Value);
-- Enter the link between the associated node of the old
-- Itype and the new Itype, for updating later when node
-- is copied.
if Present (Anode) then -- Add a link between the associated node of the old Itype and the
NCT_Itype_Assoc.Set (Anode, Node (Elmt)); -- new Itype, for updating later when node is copied.
end if;
end; if Is_Type (Key) then
Assoc := Associated_Node_For_Itype (Key);
if Present (Assoc) then
NCT_Itype_Assoc.Set (Assoc, Value);
end if;
end if; end if;
Next_Elmt (Elmt); Next_Elmt (Elmt);
...@@ -17540,23 +17548,29 @@ package body Sem_Util is ...@@ -17540,23 +17548,29 @@ package body Sem_Util is
pragma Assert (not Is_Itype (Old_Entity)); pragma Assert (not Is_Itype (Old_Entity));
pragma Assert (Nkind (Old_Entity) in N_Entity); pragma Assert (Nkind (Old_Entity) in N_Entity);
-- Restrict entity creation to declarations of constants, variables -- Do not duplicate an entity when it is declared within an inner
-- and subtypes. There is no need to duplicate entities declared in -- scope enclosed by an expression with actions.
-- inner scopes.
if (not Ekind_In (Old_Entity, E_Constant, E_Variable) if EWA_Inner_Scope_Level > 0 then
and then Nkind (Parent (Old_Entity)) /= N_Subtype_Declaration) return;
or else EWA_Inner_Scope_Level > 0
then -- Entity duplication is currently performed only for objects and
-- types. Relaxing this restriction leads to a performance penalty.
elsif Ekind_In (Old_Entity, E_Constant, E_Variable) then
null;
elsif Is_Type (Old_Entity) then
null;
else
return; return;
end if; end if;
New_E := New_Copy (Old_Entity); New_E := New_Copy (Old_Entity);
-- The new entity has all the attributes of the old one, and we -- The new entity has all the attributes of the old one, however it
-- just copy the contents of the entity. However, the back-end -- requires a new name for debugging purposes.
-- needs different names for debugging purposes, so we create a
-- new internal name for it in all cases.
Set_Chars (New_E, New_Internal_Name ('T')); Set_Chars (New_E, New_Internal_Name ('T'));
...@@ -17830,8 +17844,8 @@ package body Sem_Util is ...@@ -17830,8 +17844,8 @@ package body Sem_Util is
while Present (New_E) loop while Present (New_E) loop
-- Skip entities that were not created in the first phase -- Skip entities that were not created in the first phase
-- (that is, old entities specified by the caller in the -- (that is, old entities specified by the caller in the set of
-- set of mappings to be applied to the tree). -- mappings to be applied to the tree).
if Is_Itype (New_E) if Is_Itype (New_E)
or else No (Map) or else No (Map)
......
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