Commit f3b01cd9 by Arnaud Charlet

[multiple changes]

2009-04-17  Ed Schonberg  <schonberg@adacore.com>

	* atree.ads, atree.adb: Move New_Copy_Tree.to sem_util.

	* nlists.ads, nlists.adb: Move New_Copy_List to sem_util.
	
	* lib-load.adb: Use Copy_Separate_Tree rather than New_Copy_Tree

	* sem_util.ads, sem_util.adb: New_Copy_Tree and New_Copy_List belong in
	semantic units, because the handling of itypes in the copied tree
	requires semantic information that does not belong in atree.

2009-04-17  Robert Dewar  <dewar@adacore.com>

	* par-ch6.adb: Minor reformatting

	* prj.adb: Minor reformatting

From-SVN: r146230
parent cec29135
2009-04-17 Ed Schonberg <schonberg@adacore.com>
* sem_ch3.adb (Access_Subprogram_Definition): Additional checks on
illegal uses of incomplete types in formal parts and return types.
* sem_ch6.adb (Process_Formals): Taft-amendment types are legal in
access to subprograms.
* sem_ch7.adb (Uninstall_Declarations): diagnose attempts to use
Taft-amendment types as the return type of an access_to_function type.
* freeze.adb (Freeze_Entity): Remove tests on formals of an incomplete
type for access_to_subprograms. The check is performed on package exit.
2009-04-17 Ed Schonberg <schonberg@adacore.com>
* atree.ads, atree.adb: Move New_Copy_Tree.to sem_util.
* nlists.ads, nlists.adb: Move New_Copy_List to sem_util.
* lib-load.adb: Use Copy_Separate_Tree rather than New_Copy_Tree
* sem_util.ads, sem_util.adb: New_Copy_Tree and New_Copy_List belong in
semantic units, because the handling of itypes in the copied tree
requires semantic information that does not belong in atree.
2009-04-17 Robert Dewar <dewar@adacore.com>
* par-ch6.adb: Minor reformatting
* prj.adb: Minor reformatting
2009-04-17 Gary Dismukes <dismukes@adacore.com> 2009-04-17 Gary Dismukes <dismukes@adacore.com>
* par-ch6.adb (P_Subprogram): Overriding indicators should be allowed * par-ch6.adb (P_Subprogram): Overriding indicators should be allowed
...@@ -105,8 +105,6 @@ package body Atree is ...@@ -105,8 +105,6 @@ package body Atree is
use Atree_Private_Part; use Atree_Private_Part;
-- We are also allowed to see our private data structures! -- We are also allowed to see our private data structures!
function E_To_N is new Unchecked_Conversion (Entity_Kind, Node_Kind);
function N_To_E is new Unchecked_Conversion (Node_Kind, Entity_Kind);
-- Functions used to store Entity_Kind value in Nkind field -- Functions used to store Entity_Kind value in Nkind field
-- The following declarations are used to store flags 65-72 in the -- The following declarations are used to store flags 65-72 in the
...@@ -395,91 +393,6 @@ package body Atree is ...@@ -395,91 +393,6 @@ package body Atree is
function To_Flag_Word5_Ptr is new function To_Flag_Word5_Ptr is new
Unchecked_Conversion (Union_Id_Ptr, Flag_Word5_Ptr); Unchecked_Conversion (Union_Id_Ptr, Flag_Word5_Ptr);
-- Default value used to initialize default nodes. Note that some of the
-- fields get overwritten, and in particular, Nkind always gets reset.
Default_Node : Node_Record := (
Is_Extension => False,
Pflag1 => False,
Pflag2 => False,
In_List => False,
Unused_1 => False,
Rewrite_Ins => False,
Analyzed => False,
Comes_From_Source => False, -- modified by Set_Comes_From_Source_Default
Error_Posted => False,
Flag4 => False,
Flag5 => False,
Flag6 => False,
Flag7 => False,
Flag8 => False,
Flag9 => False,
Flag10 => False,
Flag11 => False,
Flag12 => False,
Flag13 => False,
Flag14 => False,
Flag15 => False,
Flag16 => False,
Flag17 => False,
Flag18 => False,
Nkind => N_Unused_At_Start,
Sloc => No_Location,
Link => Empty_List_Or_Node,
Field1 => Empty_List_Or_Node,
Field2 => Empty_List_Or_Node,
Field3 => Empty_List_Or_Node,
Field4 => Empty_List_Or_Node,
Field5 => Empty_List_Or_Node);
-- Default value used to initialize node extensions (i.e. the second
-- and third and fourth components of an extended node). Note we are
-- cheating a bit here when it comes to Node12, which really holds
-- flags an (for the third component), the convention. But it works
-- because Empty, False, Convention_Ada, all happen to be all zero bits.
Default_Node_Extension : constant Node_Record := (
Is_Extension => True,
Pflag1 => False,
Pflag2 => False,
In_List => False,
Unused_1 => False,
Rewrite_Ins => False,
Analyzed => False,
Comes_From_Source => False,
Error_Posted => False,
Flag4 => False,
Flag5 => False,
Flag6 => False,
Flag7 => False,
Flag8 => False,
Flag9 => False,
Flag10 => False,
Flag11 => False,
Flag12 => False,
Flag13 => False,
Flag14 => False,
Flag15 => False,
Flag16 => False,
Flag17 => False,
Flag18 => False,
Nkind => E_To_N (E_Void),
Field6 => Empty_List_Or_Node,
Field7 => Empty_List_Or_Node,
Field8 => Empty_List_Or_Node,
Field9 => Empty_List_Or_Node,
Field10 => Empty_List_Or_Node,
Field11 => Empty_List_Or_Node,
Field12 => Empty_List_Or_Node);
-------------------------------------------------- --------------------------------------------------
-- Implementation of Tree Substitution Routines -- -- Implementation of Tree Substitution Routines --
-------------------------------------------------- --------------------------------------------------
...@@ -1218,7 +1131,7 @@ package body Atree is ...@@ -1218,7 +1131,7 @@ package body Atree is
-- Start of processing for New_Copy_Tree function -- Start of processing for New_Copy_Tree function
function New_Copy_Tree function New_Copy_Tree1
(Source : Node_Id; (Source : Node_Id;
Map : Elist_Id := No_Elist; Map : Elist_Id := No_Elist;
New_Sloc : Source_Ptr := No_Location; New_Sloc : Source_Ptr := No_Location;
...@@ -1835,12 +1748,9 @@ package body Atree is ...@@ -1835,12 +1748,9 @@ package body Atree is
-- The new Itype has all the attributes of the old one, and -- The new Itype has all the attributes of the old one, and
-- we just copy the contents of the entity. However, the back-end -- we just copy the contents of the entity. However, the back-end
-- needs different names for debugging purposes, so we create a -- needs different names for debugging purposes, so we create a
-- new internal name by appending the letter 'c' (copy) to the -- new internal name for it in all cases.
-- name of the original.
Get_Name_String (Chars (Old_Itype)); -- Set_Chars (New_Itype, New_Internal_Name ('T'));
Add_Char_To_Name_Buffer ('c');
Set_Chars (New_Itype, Name_Enter);
-- If our associated node is an entity that has already been copied, -- If our associated node is an entity that has already been copied,
-- then set the associated node of the copy to point to the right -- then set the associated node of the copy to point to the right
...@@ -1952,6 +1862,10 @@ package body Atree is ...@@ -1952,6 +1862,10 @@ package body Atree is
Old_Itype); Old_Itype);
end if; end if;
end if; end if;
Get_Name_String (Chars (Old_Itype));
Add_Char_To_Name_Buffer ('c');
Add_Nat_To_Name_Buffer (Int (Associated_Node_For_Itype (New_Itype)));
Set_Chars (New_Itype, Name_Enter);
end Visit_Itype; end Visit_Itype;
---------------- ----------------
...@@ -2085,7 +1999,7 @@ package body Atree is ...@@ -2085,7 +1999,7 @@ package body Atree is
-- Now we can copy the actual tree -- Now we can copy the actual tree
return Copy_Node_With_Replacement (Source); return Copy_Node_With_Replacement (Source);
end New_Copy_Tree; end New_Copy_Tree1;
---------------- ----------------
-- New_Entity -- -- New_Entity --
......
...@@ -430,7 +430,7 @@ package Atree is ...@@ -430,7 +430,7 @@ package Atree is
-- Source to be Empty, in which case Relocate_Node simply returns -- Source to be Empty, in which case Relocate_Node simply returns
-- Empty as the result. -- Empty as the result.
function New_Copy_Tree function New_Copy_Tree1
(Source : Node_Id; (Source : Node_Id;
Map : Elist_Id := No_Elist; Map : Elist_Id := No_Elist;
New_Sloc : Source_Ptr := No_Location; New_Sloc : Source_Ptr := No_Location;
...@@ -3114,6 +3114,95 @@ package Atree is ...@@ -3114,6 +3114,95 @@ package Atree is
for Node_Record'Size use 8*32; for Node_Record'Size use 8*32;
for Node_Record'Alignment use 4; for Node_Record'Alignment use 4;
function E_To_N is new Unchecked_Conversion (Entity_Kind, Node_Kind);
function N_To_E is new Unchecked_Conversion (Node_Kind, Entity_Kind);
-- Default value used to initialize default nodes. Note that some of the
-- fields get overwritten, and in particular, Nkind always gets reset.
Default_Node : Node_Record := (
Is_Extension => False,
Pflag1 => False,
Pflag2 => False,
In_List => False,
Unused_1 => False,
Rewrite_Ins => False,
Analyzed => False,
Comes_From_Source => False,
-- modified by Set_Comes_From_Source_Default
Error_Posted => False,
Flag4 => False,
Flag5 => False,
Flag6 => False,
Flag7 => False,
Flag8 => False,
Flag9 => False,
Flag10 => False,
Flag11 => False,
Flag12 => False,
Flag13 => False,
Flag14 => False,
Flag15 => False,
Flag16 => False,
Flag17 => False,
Flag18 => False,
Nkind => N_Unused_At_Start,
Sloc => No_Location,
Link => Empty_List_Or_Node,
Field1 => Empty_List_Or_Node,
Field2 => Empty_List_Or_Node,
Field3 => Empty_List_Or_Node,
Field4 => Empty_List_Or_Node,
Field5 => Empty_List_Or_Node);
-- Default value used to initialize node extensions (i.e. the second
-- and third and fourth components of an extended node). Note we are
-- cheating a bit here when it comes to Node12, which really holds
-- flags an (for the third component), the convention. But it works
-- because Empty, False, Convention_Ada, all happen to be all zero bits.
Default_Node_Extension : constant Node_Record := (
Is_Extension => True,
Pflag1 => False,
Pflag2 => False,
In_List => False,
Unused_1 => False,
Rewrite_Ins => False,
Analyzed => False,
Comes_From_Source => False,
Error_Posted => False,
Flag4 => False,
Flag5 => False,
Flag6 => False,
Flag7 => False,
Flag8 => False,
Flag9 => False,
Flag10 => False,
Flag11 => False,
Flag12 => False,
Flag13 => False,
Flag14 => False,
Flag15 => False,
Flag16 => False,
Flag17 => False,
Flag18 => False,
Nkind => E_To_N (E_Void),
Field6 => Empty_List_Or_Node,
Field7 => Empty_List_Or_Node,
Field8 => Empty_List_Or_Node,
Field9 => Empty_List_Or_Node,
Field10 => Empty_List_Or_Node,
Field11 => Empty_List_Or_Node,
Field12 => Empty_List_Or_Node);
-- The following defines the extendable array used for the nodes table -- The following defines the extendable array used for the nodes table
-- Nodes with extensions use five consecutive entries in the array -- Nodes with extensions use five consecutive entries in the array
......
...@@ -169,14 +169,14 @@ package body Lib.Load is ...@@ -169,14 +169,14 @@ package body Lib.Load is
Chars => Chars (Selector_Name (Name (With_Node)))); Chars => Chars (Selector_Name (Name (With_Node))));
Du_Name := Du_Name :=
Make_Defining_Program_Unit_Name (No_Location, Make_Defining_Program_Unit_Name (No_Location,
Name => New_Copy_Tree (Prefix (Name (With_Node))), Name => Copy_Separate_Tree (Prefix (Name (With_Node))),
Defining_Identifier => Cunit_Entity); Defining_Identifier => Cunit_Entity);
Set_Is_Child_Unit (Cunit_Entity); Set_Is_Child_Unit (Cunit_Entity);
End_Lab := End_Lab :=
Make_Designator (No_Location, Make_Designator (No_Location,
Name => New_Copy_Tree (Prefix (Name (With_Node))), Name => Copy_Separate_Tree (Prefix (Name (With_Node))),
Identifier => New_Occurrence_Of (Cunit_Entity, No_Location)); Identifier => New_Occurrence_Of (Cunit_Entity, No_Location));
end if; end if;
......
...@@ -745,31 +745,6 @@ package body Nlists is ...@@ -745,31 +745,6 @@ package body Nlists is
end if; end if;
end New_Copy_List_Original; end New_Copy_List_Original;
------------------------
-- New_Copy_List_Tree --
------------------------
function New_Copy_List_Tree (List : List_Id) return List_Id is
NL : List_Id;
E : Node_Id;
begin
if List = No_List then
return No_List;
else
NL := New_List;
E := First (List);
while Present (E) loop
Append (New_Copy_Tree (E), NL);
E := Next (E);
end loop;
return NL;
end if;
end New_Copy_List_Tree;
-------------- --------------
-- New_List -- -- New_List --
-------------- --------------
......
...@@ -108,13 +108,6 @@ package Nlists is ...@@ -108,13 +108,6 @@ package Nlists is
function New_Copy_List_Original (List : List_Id) return List_Id; function New_Copy_List_Original (List : List_Id) return List_Id;
-- Same as New_Copy_List but copies only nodes coming from source -- Same as New_Copy_List but copies only nodes coming from source
function New_Copy_List_Tree (List : List_Id) return List_Id;
-- Similar to New_Copy_List, except that the copies are done using the
-- Atree.New_Copy_Tree function, which means that a full recursive copy
-- of the subtrees in the list is performed, setting proper parents. As
-- for New_Copy_Tree, it is illegal to attempt to copy extended nodes
-- (entities) either directly or indirectly using this function.
function First (List : List_Id) return Node_Id; function First (List : List_Id) return Node_Id;
pragma Inline (First); pragma Inline (First);
-- Obtains the first element of the given node list or, if the node list -- Obtains the first element of the given node list or, if the node list
......
...@@ -221,13 +221,12 @@ package body Ch6 is ...@@ -221,13 +221,12 @@ package body Ch6 is
-- and bodies can occur. -- and bodies can occur.
if Pf_Flags /= Pf_Decl_Gins_Pbod_Rnam_Stub if Pf_Flags /= Pf_Decl_Gins_Pbod_Rnam_Stub
and then Pf_Flags /= Pf_Decl_Pbod and then
Pf_Flags /= Pf_Decl_Pbod
then then
Error_Msg_SC ("overriding indicator not allowed here!"); Error_Msg_SC ("overriding indicator not allowed here!");
elsif Token /= Tok_Function elsif Token /= Tok_Function and then Token /= Tok_Procedure then
and then Token /= Tok_Procedure
then
Error_Msg_SC ("FUNCTION or PROCEDURE expected!"); Error_Msg_SC ("FUNCTION or PROCEDURE expected!");
end if; end if;
end if; end if;
......
...@@ -715,8 +715,8 @@ package body Prj is ...@@ -715,8 +715,8 @@ package body Prj is
is is
begin begin
if Object_File_Suffix = No_Name then if Object_File_Suffix = No_Name then
return Extend_Name (Source_File_Name, Object_Suffix); return Extend_Name
(Source_File_Name, Object_Suffix);
else else
return Extend_Name return Extend_Name
(Source_File_Name, Get_Name_String (Object_File_Suffix)); (Source_File_Name, Get_Name_String (Object_File_Suffix));
...@@ -880,6 +880,7 @@ package body Prj is ...@@ -880,6 +880,7 @@ package body Prj is
loop loop
Free (Tree.Projects.Table (P)); Free (Tree.Projects.Table (P));
end loop; end loop;
Project_Table.Free (Tree.Projects); Project_Table.Free (Tree.Projects);
-- Private part -- Private part
...@@ -929,6 +930,7 @@ package body Prj is ...@@ -929,6 +930,7 @@ package body Prj is
Free (Tree.Projects.Table (P)); Free (Tree.Projects.Table (P));
end loop; end loop;
end if; end if;
Project_Table.Init (Tree.Projects); Project_Table.Init (Tree.Projects);
-- Private part table -- Private part table
......
...@@ -876,6 +876,57 @@ package Sem_Util is ...@@ -876,6 +876,57 @@ package Sem_Util is
-- formal. Used in Ada 2005 mode to solve the syntactic ambiguity that -- formal. Used in Ada 2005 mode to solve the syntactic ambiguity that
-- results from an indexing of a function call written in prefix form. -- results from an indexing of a function call written in prefix form.
function New_Copy_List_Tree (List : List_Id) return List_Id;
-- Copy recursively an analyzed list of nodes. Uses New_Copy_Tree defined
-- below. As for New_Copy_Tree, it is illegal to attempt to copy extended
-- nodes (entities) either directly or indirectly using this function.
function New_Copy_Tree
(Source : Node_Id;
Map : Elist_Id := No_Elist;
New_Sloc : Source_Ptr := No_Location;
New_Scope : Entity_Id := Empty) return Node_Id;
-- Given a node that is the root of a subtree, Copy_Tree copies the entire
-- syntactic subtree, including recursively any descendents whose parent
-- field references a copied node (descendents not linked to a copied node
-- by the parent field are not copied, instead the copied tree references
-- the same descendent as the original in this case, which is appropriate
-- for non-syntactic fields such as Etype). The parent pointers in the
-- copy are properly set. Copy_Tree (Empty/Error) returns Empty/Error.
-- The one exception to the rule of not copying semantic fields is that
-- any implicit types attached to the subtree are duplicated, so that
-- the copy contains a distinct set of implicit type entities. Thus this
-- function is used when it is necessary to duplicate an analyzed tree,
-- declared in the same or some other compilation unit. This function is
-- declared here rather than in atree because it uses semantic information
-- in particular concerning the structure of itypes and the generation of
-- public symbols.
-- The Map argument, if set to a non-empty Elist, specifies a set of
-- mappings to be applied to entities in the tree. The map has the form:
--
-- old entity 1
-- new entity to replace references to entity 1
-- old entity 2
-- new entity to replace references to entity 2
-- ...
--
-- The call destroys the contents of Map in this case
--
-- The parameter New_Sloc, if set to a value other than No_Location, is
-- used as the Sloc value for all nodes in the new copy. If New_Sloc is
-- set to its default value No_Location, then the Sloc values of the
-- nodes in the copy are simply copied from the corresponding original.
--
-- The Comes_From_Source indication is unchanged if New_Sloc is set to
-- the default No_Location value, but is reset if New_Sloc is given, since
-- in this case the result clearly is neither a source node or an exact
-- copy of a source node.
--
-- The parameter New_Scope, if set to a value other than Empty, is the
-- value to use as the Scope for any Itypes that are copied. The most
-- typical value for this parameter, if given, is Current_Scope.
function New_External_Entity function New_External_Entity
(Kind : Entity_Kind; (Kind : Entity_Kind;
Scope_Id : Entity_Id; Scope_Id : Entity_Id;
......
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