OSDN Git Service

2011-11-04 Yannick Moy <moy@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / atree.ads
index 3093104..6bb9ddd 100644 (file)
@@ -6,25 +6,23 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2005, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
 --                                                                          --
 -- 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- --
--- ware  Foundation;  either version 2,  or (at your option) any later ver- --
+-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
--- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
--- for  more details.  You should have  received  a copy of the GNU General --
--- Public License  distributed with GNAT;  see file COPYING.  If not, write --
--- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
--- MA 02111-1307, USA.                                                      --
+-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
 --                                                                          --
--- As a special exception,  if other files  instantiate  generics from this --
--- unit, or you link  this unit with other files  to produce an executable, --
--- this  unit  does not  by itself cause  the resulting  executable  to  be --
--- covered  by the  GNU  General  Public  License.  This exception does not --
--- however invalidate  any other reasons why  the executable file  might be --
--- covered by the  GNU Public License.                                      --
+-- As a special exception under Section 7 of GPL version 3, you are granted --
+-- additional permissions described in the GCC Runtime Library Exception,   --
+-- version 3.1, as published by the Free Software Foundation.               --
+--                                                                          --
+-- You should have received a copy of the GNU General Public License and    --
+-- a copy of the GCC Runtime Library Exception along with this program;     --
+-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
+-- <http://www.gnu.org/licenses/>.                                          --
 --                                                                          --
 -- GNAT was originally developed  by the GNAT team at  New York University. --
 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
@@ -34,6 +32,7 @@
 with Alloc;
 with Sinfo;  use Sinfo;
 with Einfo;  use Einfo;
+with Namet;  use Namet;
 with Types;  use Types;
 with Snames; use Snames;
 with System; use System;
@@ -49,7 +48,7 @@ package Atree is
 --  this tree. There is no separate symbol table structure.
 
 --  WARNING: There is a C version of this package. Any changes to this
---  source file must be properly reflected in the C header file tree.h
+--  source file must be properly reflected in the C header file atree.h
 
 --  Package Atree defines the basic structure of the tree and its nodes and
 --  provides the basic abstract interface for manipulating the tree. Two
@@ -59,7 +58,7 @@ package Atree is
 --  by the parser. The package Entity_Info defines the semantic information
 --  which is added to the tree nodes that represent declared entities (i.e.
 --  the information which might typically be described in a separate symbol
---  table structure.
+--  table structure).
 
 --  The front end of the compiler first parses the program and generates a
 --  tree that is simply a syntactic representation of the program in abstract
@@ -84,21 +83,16 @@ package Atree is
    --                 show which token is referenced by this pointer.
 
    --   In_List       A flag used to indicate if the node is a member
-   --                    of a node list.
-
-   --   Rewrite_Sub   A flag set if the node has been rewritten using
-   --                 the Rewrite procedure. The original value of the
-   --                 node is retrievable with Original_Node.
+   --                 of a node list.
 
    --   Rewrite_Ins   A flag set if a node is marked as a rewrite inserted
    --                 node as a result of a call to Mark_Rewrite_Insertion.
 
-   --   Paren_Count   A 2-bit count used on expression nodes to indicate
-   --                 the level of parentheses. Up to 3 levels can be
-   --                 accomodated. Anything more than 3 levels is treated
-   --                 as 3 levels (conformance tests that complain about
-   --                 this are hereby deemed pathological!) Set to zero
-   --                 for non-subexpression nodes.
+   --   Paren_Count   A 2-bit count used in sub-expression nodes to indicate
+   --                 the level of parentheses. The settings are 0,1,2 and
+   --                 3 for many. If the value is 3, then an auxiliary table
+   --                 is used to indicate the real value. Set to zero for
+   --                 non-subexpression nodes.
 
    --   Comes_From_Source
    --                 This flag is present in all nodes. It is set if the
@@ -144,7 +138,7 @@ package Atree is
    --   it will take a bit of fiddling to change that ???
 
    --   Note: the actual usage of FieldN (i.e. whether it contains a Elist_Id,
-   --   List_Id, Name_Id, Node_Id, String_Id, Uint or Ureal), depends on the
+   --   List_Id, Name_Id, Node_Id, String_Id, Uint or Ureal) depends on the
    --   value in Nkind. Generally the access to this field is always via the
    --   functional interface, so the field names ElistN, ListN, NameN, NodeN,
    --   StrN, UintN and UrealN are used only in the bodies of the access
@@ -157,17 +151,17 @@ package Atree is
    --   it is useful to be able to do untyped traversals, and an internal
    --   package in Atree allows for direct untyped accesses in such cases.
 
-   --   Flag4         Fifteen Boolean flags (use depends on Nkind and
+   --   Flag4         Sixteen Boolean flags (use depends on Nkind and
    --   Flag5         Ekind, as described for FieldN). Again the access
    --   Flag6         is usually via subprograms in Sinfo and Einfo which
    --   Flag7         provide high-level synonyms for these flags, and
    --   Flag8         contain debugging code that checks that the values
    --   Flag9         in Nkind and Ekind are appropriate for the access.
    --   Flag10
-   --   Flag11        Note that Flag1-3 are missing from this list. The
-   --   Flag12        first three flag positions are reserved for the
-   --   Flag13        standard flags (Comes_From_Source, Error_Posted,
-   --   Flag14        and Analyzed)
+   --   Flag11        Note that Flag1-2 are missing from this list. For
+   --   Flag12        historical reasons, these flag names are unused.
+   --   Flag13
+   --   Flag14
    --   Flag15
    --   Flag16
    --   Flag17
@@ -186,9 +180,9 @@ package Atree is
    --                 entity, it is of type Entity_Kind which is defined
    --                 in package Einfo.
 
-   --   Flag19        197 additional flags
+   --   Flag19        235 additional flags
    --   ...
-   --   Flag215
+   --   Flag254
 
    --   Convention    Entity convention (Convention_Id value)
 
@@ -198,13 +192,9 @@ package Atree is
    --   Elist6        Synonym for Field6 typed as Elist_Id (Empty = No_Elist)
    --   Uint6         Synonym for Field6 typed as Uint (Empty = Uint_0)
 
-   --   Similar definitions for Field7 to Field27 (and Node7-Node27,
-   --   Elist7-Elist27, Uint7-Uint27, Ureal7-Ureal27). Note that not all
-   --   these functions are defined, only the ones that are actually used.
-
-   type Paren_Count_Type is mod 4;
-   for Paren_Count_Type'Size use 2;
-   --  Type used for Paren_Count field
+   --   Similar definitions for Field7 to Field28 (and Node7-Node28,
+   --   Elist7-Elist28, Uint7-Uint28, Ureal7-Ureal28). Note that not all these
+   --   functions are defined, only the ones that are actually used.
 
    function Last_Node_Id return Node_Id;
    pragma Inline (Last_Node_Id);
@@ -287,7 +277,7 @@ package Atree is
 
    --  Field1-5 fields are set to Empty
 
-   --  Field6-22 fields in extended nodes are set to Empty
+   --  Field6-29 fields in extended nodes are set to Empty
 
    --  Parent is set to Empty
 
@@ -302,7 +292,7 @@ package Atree is
    -------------------------------------
 
    --  A subpackage Atree.Unchecked_Access provides routines for reading and
-   --  writing the fields defined above (Field1-27, Node1-27, Flag1-215 etc).
+   --  writing the fields defined above (Field1-27, Node1-27, Flag4-254 etc).
    --  These unchecked access routines can be used for untyped traversals.
    --  In addition they are used in the implementations of the Sinfo and
    --  Einfo packages. These packages both provide logical synonyms for
@@ -321,7 +311,7 @@ package Atree is
    --  which the parser could not parse correctly, and adding additional
    --  semantic information (e.g. making constraint checks explicit). The
    --  following subprograms are used for constructing the tree in the first
-   --  place, and then for subsequent modifications as required
+   --  place, and then for subsequent modifications as required.
 
    procedure Initialize;
    --  Called at the start of compilation to initialize the allocation of
@@ -330,7 +320,11 @@ package Atree is
    --  Tree_Read is used.
 
    procedure Lock;
-   --  Called before the backend is invoked to lock the nodes table
+   --  Called before the back end is invoked to lock the nodes table
+   --  Also called after Unlock to relock???
+
+   procedure Unlock;
+   --  Unlocks nodes table, in cases where the back end needs to modify it
 
    procedure Tree_Read;
    --  Initializes internal tables from current tree file using the relevant
@@ -404,19 +398,22 @@ package Atree is
    --  The parent pointer of the destination and its list link, if any, are
    --  not affected by the copy. Note that parent pointers of descendents
    --  are not adjusted, so the descendents of the destination node after
-   --  the Copy_Node is completed have dubious parent pointers.
+   --  the Copy_Node is completed have dubious parent pointers. Note that
+   --  this routine does NOT copy aspect specifications, the Has_Aspects
+   --  flag in the returned node will always be False. The caller must deal
+   --  with copying aspect specifications where this is required.
 
    function New_Copy (Source : Node_Id) return Node_Id;
-   --  This function allocates a completely new node, and then initializes
-   --  it by copying the contents of the source node into it. The contents
-   --  of the source node is not affected. The target node is always marked
-   --  as not being in a list (even if the source is a list member). The
-   --  new node will have an extension if the source has an extension.
-   --  New_Copy (Empty) returns Empty and New_Copy (Error) returns Error.
-   --  Note that, unlike New_Copy_Tree, New_Copy does not recursively copy any
-   --  descendents, so in general parent pointers are not set correctly for
-   --  the descendents of the copied node. Both normal and extended nodes
-   --  (entities) may be copied using New_Copy.
+   --  This function allocates a completely new node, and then initializes it
+   --  by copying the contents of the source node into it. The contents of the
+   --  source node is not affected. The target node is always marked as not
+   --  being in a list (even if the source is a list member). The new node will
+   --  have an extension if the source has an extension. New_Copy (Empty)
+   --  returns Empty and New_Copy (Error) returns Error. Note that, unlike
+   --  Copy_Separate_Tree, New_Copy does not recursively copy any descendents,
+   --  so in general parent pointers are not set correctly for the descendents
+   --  of the copied node. Both normal and extended nodes (entities) may be
+   --  copied using New_Copy.
 
    function Relocate_Node (Source : Node_Id) return Node_Id;
    --  Source is a non-entity node that is to be relocated. A new node is
@@ -432,56 +429,21 @@ package Atree is
    --  Source to be Empty, in which case Relocate_Node simply returns
    --  Empty as the result.
 
-   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. 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 Copy_Separate_Tree (Source : Node_Id) return Node_Id;
    --  Given a node that is the root of a subtree, Copy_Separate_Tree copies
    --  the entire syntactic subtree, including recursively any descendants
    --  whose parent field references a copied node (descendants not linked to
    --  a copied node by the parent field are also copied.) The parent pointers
    --  in the copy are properly set. Copy_Separate_Tree (Empty/Error) returns
-   --  Empty/Error. The semantic fields are not copied and the new subtree
-   --  does not share any entity with source subtree.
-   --  But the code *does* copy semantic fields, and the description above
-   --  is in any case unclear on this point ??? (RBKD)
+   --  Empty/Error. The new subtree does not share entities with the source,
+   --  but has new entities with the same name. Most of the time this routine
+   --  is called on an unanalyzed tree, and no semantic information is copied.
+   --  However, to ensure that no entities are shared between the two when the
+   --  source is already analyzed, entity fields in the copy are zeroed out.
+
+   function Copy_Separate_List (Source : List_Id) return List_Id;
+   --  Applies Copy_Separate_Tree to each element of the Source list, returning
+   --  a new list of the results of these copy operations.
 
    procedure Exchange_Entities (E1 : Entity_Id; E2 : Entity_Id);
    --  Exchange the contents of two entities. The parent pointers are switched
@@ -491,42 +453,39 @@ package Atree is
    --  entity ID values of the two entities are interchanged. Neither of the
    --  two entities may be list members.
 
-   procedure Delete_Node (Node : Node_Id);
-   --  The node, which must not be a list member, is deleted from the tree and
-   --  its type is set to N_Unused_At_End. It is an error (not necessarily
-   --  detected) to reference this node after it has been deleted. The
-   --  implementation of the body of Atree is free to reuse the node to
-   --  satisfy future node allocation requests, but is not required to do so.
-
-   procedure Delete_Tree (Node : Node_Id);
-   --  The entire syntactic subtree referenced by Node (i.e. the given node
-   --  and all its syntactic descendents) are deleted as described above for
-   --  Delete_Node.
-
    function Extend_Node (Node : Node_Id) return Entity_Id;
-   --  This function returns a copy of its input node with an extension
-   --  added. The fields of the extension are set to Empty. Due to the way
-   --  extensions are handled (as four consecutive array elements), it may
-   --  be necessary to reallocate the node, so that the returned value is
-   --  not the same as the input value, but where possible the returned
-   --  value will be the same as the input value (i.e. the extension will
-   --  occur in place). It is the caller's responsibility to ensure that
-   --  any pointers to the original node are appropriately updated. This
-   --  function is used only by Sinfo.CN to change nodes into their
-   --  corresponding entities.
-
-   type Traverse_Result is (OK, OK_Orig, Skip, Abandon);
+   --  This function returns a copy of its input node with an extension added.
+   --  The fields of the extension are set to Empty. Due to the way extensions
+   --  are handled (as four consecutive array elements), it may be necessary
+   --  to reallocate the node, so that the returned value is not the same as
+   --  the input value, but where possible the returned value will be the same
+   --  as the input value (i.e. the extension will occur in place). It is the
+   --  caller's responsibility to ensure that any pointers to the original node
+   --  are appropriately updated. This function is used only by Sinfo.CN to
+   --  change nodes into their corresponding entities.
+
+   type Report_Proc is access procedure (Target : Node_Id; Source : Node_Id);
+
+   procedure Set_Reporting_Proc (P : Report_Proc);
+   --  Register a procedure that is invoked when a node is allocated, replaced
+   --  or rewritten.
+
+   type Traverse_Result is (Abandon, OK, OK_Orig, Skip);
    --  This is the type of the result returned by the Process function passed
-   --  to Traverse_Func and Traverse_Proc and also the type of the result of
-   --  Traverse_Func itself. See descriptions below for details.
+   --  to Traverse_Func and Traverse_Proc. See below for details.
+
+   subtype Traverse_Final_Result is Traverse_Result range Abandon .. OK;
+   --  This is the type of the final result returned Traverse_Func, based on
+   --  the results of Process calls. See below for details.
 
    generic
-     with function Process (N : Node_Id) return Traverse_Result is <>;
-   function Traverse_Func (Node : Node_Id) return Traverse_Result;
+      with function Process (N : Node_Id) return Traverse_Result is <>;
+   function Traverse_Func (Node : Node_Id) return Traverse_Final_Result;
    --  This is a generic function that, given the parent node for a subtree,
    --  traverses all syntactic nodes of this tree, calling the given function
-   --  Process on each one. The traversal is controlled as follows by the
-   --  result returned by Process:
+   --  Process on each one, in pre order (i.e. top-down). The order of
+   --  traversing subtrees is arbitrary. The traversal is controlled as follows
+   --  by the result returned by Process:
 
    --    OK       The traversal continues normally with the syntactic
    --             children of the node just processed.
@@ -543,13 +502,13 @@ package Atree is
 
    --  The result returned by Traverse is Abandon if processing was terminated
    --  by a call to Process returning Abandon, otherwise it is OK (meaning that
-   --  all calls to process returned either OK or Skip).
+   --  all calls to process returned either OK, OK_Orig, or Skip).
 
    generic
-     with function Process (N : Node_Id) return Traverse_Result is <>;
+      with function Process (N : Node_Id) return Traverse_Result is <>;
    procedure Traverse_Proc (Node : Node_Id);
    pragma Inline (Traverse_Proc);
-   --  This is similar to Traverse_Func except that no result is returned,
+   --  This is the same as Traverse_Func except that no result is returned,
    --  i.e. Traverse_Func is called and the result is simply discarded.
 
    ---------------------------
@@ -565,6 +524,9 @@ package Atree is
    function Analyzed          (N : Node_Id) return Boolean;
    pragma Inline (Analyzed);
 
+   function Has_Aspects       (N : Node_Id) return Boolean;
+   pragma Inline (Has_Aspects);
+
    function Comes_From_Source (N : Node_Id) return Boolean;
    pragma Inline (Comes_From_Source);
 
@@ -574,14 +536,13 @@ package Atree is
    function Sloc              (N : Node_Id) return Source_Ptr;
    pragma Inline (Sloc);
 
-   function Paren_Count       (N : Node_Id) return Paren_Count_Type;
+   function Paren_Count       (N : Node_Id) return Nat;
    pragma Inline (Paren_Count);
 
    function Parent            (N : Node_Id) return Node_Id;
    pragma Inline (Parent);
-   --  Returns the parent of a node if the node is not a list member, or
-   --  else the parent of the list containing the node if the node is a
-   --  list member.
+   --  Returns the parent of a node if the node is not a list member, or else
+   --  the parent of the list containing the node if the node is a list member.
 
    function No                (N : Node_Id) return Boolean;
    pragma Inline (No);
@@ -593,6 +554,166 @@ package Atree is
    --  Tests given Id for inequality with the Empty node. This allows notations
    --  like "if Present (Statement)" as opposed to "if Statement /= Empty".
 
+   ---------------------
+   -- Node_Kind Tests --
+   ---------------------
+
+   --  These are like the functions in Sinfo, but the first argument is a
+   --  Node_Id, and the tested field is Nkind (N).
+
+   function Nkind_In
+     (N  : Node_Id;
+      V1 : Node_Kind;
+      V2 : Node_Kind) return Boolean;
+
+   function Nkind_In
+     (N  : Node_Id;
+      V1 : Node_Kind;
+      V2 : Node_Kind;
+      V3 : Node_Kind) return Boolean;
+
+   function Nkind_In
+     (N  : Node_Id;
+      V1 : Node_Kind;
+      V2 : Node_Kind;
+      V3 : Node_Kind;
+      V4 : Node_Kind) return Boolean;
+
+   function Nkind_In
+     (N  : Node_Id;
+      V1 : Node_Kind;
+      V2 : Node_Kind;
+      V3 : Node_Kind;
+      V4 : Node_Kind;
+      V5 : Node_Kind) return Boolean;
+
+   function Nkind_In
+     (N  : Node_Id;
+      V1 : Node_Kind;
+      V2 : Node_Kind;
+      V3 : Node_Kind;
+      V4 : Node_Kind;
+      V5 : Node_Kind;
+      V6 : Node_Kind) return Boolean;
+
+   function Nkind_In
+     (N  : Node_Id;
+      V1 : Node_Kind;
+      V2 : Node_Kind;
+      V3 : Node_Kind;
+      V4 : Node_Kind;
+      V5 : Node_Kind;
+      V6 : Node_Kind;
+      V7 : Node_Kind) return Boolean;
+
+   function Nkind_In
+     (N  : Node_Id;
+      V1 : Node_Kind;
+      V2 : Node_Kind;
+      V3 : Node_Kind;
+      V4 : Node_Kind;
+      V5 : Node_Kind;
+      V6 : Node_Kind;
+      V7 : Node_Kind;
+      V8 : Node_Kind) return Boolean;
+
+   function Nkind_In
+     (N  : Node_Id;
+      V1 : Node_Kind;
+      V2 : Node_Kind;
+      V3 : Node_Kind;
+      V4 : Node_Kind;
+      V5 : Node_Kind;
+      V6 : Node_Kind;
+      V7 : Node_Kind;
+      V8 : Node_Kind;
+      V9 : Node_Kind) return Boolean;
+
+   pragma Inline (Nkind_In);
+   --  Inline all above functions
+
+   -----------------------
+   -- Entity_Kind_Tests --
+   -----------------------
+
+   --  Utility functions to test whether an Entity_Kind value, either given
+   --  directly as the first argument, or the Ekind field of an Entity give
+   --  as the first argument, matches any of the given list of Entity_Kind
+   --  values. Return True if any match, False if no match.
+
+   function Ekind_In
+     (E  : Entity_Id;
+      V1 : Entity_Kind;
+      V2 : Entity_Kind) return Boolean;
+
+   function Ekind_In
+     (E  : Entity_Id;
+      V1 : Entity_Kind;
+      V2 : Entity_Kind;
+      V3 : Entity_Kind) return Boolean;
+
+   function Ekind_In
+     (E  : Entity_Id;
+      V1 : Entity_Kind;
+      V2 : Entity_Kind;
+      V3 : Entity_Kind;
+      V4 : Entity_Kind) return Boolean;
+
+   function Ekind_In
+     (E  : Entity_Id;
+      V1 : Entity_Kind;
+      V2 : Entity_Kind;
+      V3 : Entity_Kind;
+      V4 : Entity_Kind;
+      V5 : Entity_Kind) return Boolean;
+
+   function Ekind_In
+     (E  : Entity_Id;
+      V1 : Entity_Kind;
+      V2 : Entity_Kind;
+      V3 : Entity_Kind;
+      V4 : Entity_Kind;
+      V5 : Entity_Kind;
+      V6 : Entity_Kind) return Boolean;
+
+   function Ekind_In
+     (T  : Entity_Kind;
+      V1 : Entity_Kind;
+      V2 : Entity_Kind) return Boolean;
+
+   function Ekind_In
+     (T  : Entity_Kind;
+      V1 : Entity_Kind;
+      V2 : Entity_Kind;
+      V3 : Entity_Kind) return Boolean;
+
+   function Ekind_In
+     (T  : Entity_Kind;
+      V1 : Entity_Kind;
+      V2 : Entity_Kind;
+      V3 : Entity_Kind;
+      V4 : Entity_Kind) return Boolean;
+
+   function Ekind_In
+     (T  : Entity_Kind;
+      V1 : Entity_Kind;
+      V2 : Entity_Kind;
+      V3 : Entity_Kind;
+      V4 : Entity_Kind;
+      V5 : Entity_Kind) return Boolean;
+
+   function Ekind_In
+     (T  : Entity_Kind;
+      V1 : Entity_Kind;
+      V2 : Entity_Kind;
+      V3 : Entity_Kind;
+      V4 : Entity_Kind;
+      V5 : Entity_Kind;
+      V6 : Entity_Kind) return Boolean;
+
+   pragma Inline (Ekind_In);
+   --  Inline all above functions
+
    -----------------------------
    -- Entity Access Functions --
    -----------------------------
@@ -618,7 +739,7 @@ package Atree is
    procedure Set_Sloc         (N : Node_Id; Val : Source_Ptr);
    pragma Inline (Set_Sloc);
 
-   procedure Set_Paren_Count  (N : Node_Id; Val : Paren_Count_Type);
+   procedure Set_Paren_Count  (N : Node_Id; Val : Nat);
    pragma Inline (Set_Paren_Count);
 
    procedure Set_Parent       (N : Node_Id; Val : Node_Id);
@@ -637,6 +758,17 @@ package Atree is
    --  unusual cases, the value needs to be reset (e.g. when a source
    --  node is copied, and the copy must not have Comes_From_Source set.
 
+   procedure Set_Has_Aspects (N : Node_Id; Val : Boolean := True);
+   pragma Inline (Set_Has_Aspects);
+
+   procedure Set_Original_Node (N : Node_Id; Val : Node_Id);
+   pragma Inline (Set_Original_Node);
+   --  Note that this routine is used only in very peculiar cases. In normal
+   --  cases, the Original_Node link is set by calls to Rewrite. We currently
+   --  use it in ASIS mode to manually set the link from pragma expressions
+   --  to their aspect original source expressions, so that the original source
+   --  expressions accessed by ASIS are also semantically analyzed.
+
    ------------------------------
    -- Entity Update Procedures --
    ------------------------------
@@ -644,12 +776,15 @@ package Atree is
    --  The following procedures apply only to Entity_Id values, i.e.
    --  to extended nodes.
 
+   procedure Basic_Set_Convention (E : Entity_Id; Val : Convention_Id);
+   pragma Inline (Basic_Set_Convention);
+   --  Clients should use Sem_Util.Set_Convention rather than calling this
+   --  routine directly, as Set_Convention also deals with the special
+   --  processing required for access types.
+
    procedure Set_Ekind (E : Entity_Id; Val : Entity_Kind);
    pragma Inline (Set_Ekind);
 
-   procedure Set_Convention (E : Entity_Id; Val : Convention_Id);
-   pragma Inline (Set_Convention);
-
    ---------------------------
    -- Tree Rewrite Routines --
    ---------------------------
@@ -696,9 +831,9 @@ package Atree is
 
    function Is_Rewrite_Insertion (Node : Node_Id) return Boolean;
    pragma Inline (Is_Rewrite_Insertion);
-   --  Tests whether the given node was marked using Set_Rewrite_Insert. This
-   --  is used in reconstructing the original tree (where such nodes are to
-   --  be eliminated from the reconstructed tree).
+   --  Tests whether the given node was marked using Mark_Rewrite_Insertion.
+   --  This is used in reconstructing the original tree (where such nodes are
+   --  to be eliminated).
 
    procedure Rewrite (Old_Node, New_Node : Node_Id);
    --  This is used when a complete subtree is to be replaced. Old_Node is the
@@ -721,7 +856,7 @@ package Atree is
    --  This is similar to Rewrite, except that the old value of Old_Node is
    --  not saved, and the New_Node is deleted after the replace, since it
    --  is assumed that it can no longer be legitimately needed. The flag
-   --  Is_Rewrite_Susbtitute will be False for the resulting node, unless
+   --  Is_Rewrite_Substitution will be False for the resulting node, unless
    --  it was already true on entry, and Original_Node will not return the
    --  original contents of the Old_Node, but rather the New_Node value (unless
    --  Old_Node had already been rewritten using Rewrite). Replace also
@@ -759,16 +894,19 @@ package Atree is
    -- Generic Field Access Routines --
    -----------------------------------
 
-   --  This subpackage provides the functions for accessing and procedures
-   --  for setting fields that are normally referenced by their logical
-   --  synonyms defined in packages Sinfo and Einfo. As previously
-   --  described the implementations of these packages use the package
-   --  Atree.Unchecked_Access.
+   --  This subpackage provides the functions for accessing and procedures for
+   --  setting fields that are normally referenced by wrapper subprograms (e.g.
+   --  logical synonyms defined in packages Sinfo and Einfo, or specialized
+   --  routines such as Rewrite (for Original_Node), or the node creation
+   --  routines (for Set_Nkind). The implementations of these wrapper
+   --  subprograms use the package Atree.Unchecked_Access as do various
+   --  special case accesses where no wrapper applies. Documentation is always
+   --  required for such a special case access explaining why it is needed.
 
    package Unchecked_Access is
 
-      --  Functions to allow interpretation of Union_Id values as Uint
-      --  and Ureal values
+      --  Functions to allow interpretation of Union_Id values as Uint and
+      --  Ureal values.
 
       function To_Union is new Unchecked_Conversion (Uint,  Union_Id);
       function To_Union is new Unchecked_Conversion (Ureal, Union_Id);
@@ -776,8 +914,8 @@ package Atree is
       function From_Union is new Unchecked_Conversion (Union_Id, Uint);
       function From_Union is new Unchecked_Conversion (Union_Id, Ureal);
 
-      --  Functions to fetch contents of indicated field. It is an error
-      --  to attempt to read the value of a field which is not present.
+      --  Functions to fetch contents of indicated field. It is an error to
+      --  attempt to read the value of a field which is not present.
 
       function Field1 (N : Node_Id) return Union_Id;
       pragma Inline (Field1);
@@ -860,6 +998,12 @@ package Atree is
       function Field27 (N : Node_Id) return Union_Id;
       pragma Inline (Field27);
 
+      function Field28 (N : Node_Id) return Union_Id;
+      pragma Inline (Field28);
+
+      function Field29 (N : Node_Id) return Union_Id;
+      pragma Inline (Field29);
+
       function Node1 (N : Node_Id) return Node_Id;
       pragma Inline (Node1);
 
@@ -941,6 +1085,12 @@ package Atree is
       function Node27 (N : Node_Id) return Node_Id;
       pragma Inline (Node27);
 
+      function Node28 (N : Node_Id) return Node_Id;
+      pragma Inline (Node28);
+
+      function Node29 (N : Node_Id) return Node_Id;
+      pragma Inline (Node29);
+
       function List1 (N : Node_Id) return List_Id;
       pragma Inline (List1);
 
@@ -962,6 +1112,12 @@ package Atree is
       function List14 (N : Node_Id) return List_Id;
       pragma Inline (List14);
 
+      function List25 (N : Node_Id) return List_Id;
+      pragma Inline (List25);
+
+      function Elist1 (N : Node_Id) return Elist_Id;
+      pragma Inline (Elist1);
+
       function Elist2 (N : Node_Id) return Elist_Id;
       pragma Inline (Elist2);
 
@@ -971,9 +1127,15 @@ package Atree is
       function Elist4 (N : Node_Id) return Elist_Id;
       pragma Inline (Elist4);
 
+      function Elist5 (N : Node_Id) return Elist_Id;
+      pragma Inline (Elist5);
+
       function Elist8 (N : Node_Id) return Elist_Id;
       pragma Inline (Elist8);
 
+      function Elist10 (N : Node_Id) return Elist_Id;
+      pragma Inline (Elist10);
+
       function Elist13 (N : Node_Id) return Elist_Id;
       pragma Inline (Elist13);
 
@@ -995,6 +1157,12 @@ package Atree is
       function Elist24 (N : Node_Id) return Elist_Id;
       pragma Inline (Elist24);
 
+      function Elist25 (N : Node_Id) return Elist_Id;
+      pragma Inline (Elist25);
+
+      function Elist26 (N : Node_Id) return Elist_Id;
+      pragma Inline (Elist26);
+
       function Name1 (N : Node_Id) return Name_Id;
       pragma Inline (Name1);
 
@@ -1004,10 +1172,10 @@ package Atree is
       function Str3 (N : Node_Id) return String_Id;
       pragma Inline (Str3);
 
-      --  Note: the following Uintnn functions have a special test for
-      --  the Field value being Empty. If an Empty value is found then
-      --  Uint_0 is returned. This avoids the rather tricky requirement
-      --  of initializing all Uint fields in nodes and entities.
+      --  Note: the following Uintnn functions have a special test for the
+      --  Field value being Empty. If an Empty value is found then Uint_0 is
+      --  returned. This avoids the rather tricky requirement of initializing
+      --  all Uint fields in nodes and entities.
 
       function Uint2 (N : Node_Id) return Uint;
       pragma Inline (Uint2);
@@ -1699,6 +1867,123 @@ package Atree is
       function Flag215 (N : Node_Id) return Boolean;
       pragma Inline (Flag215);
 
+      function Flag216 (N : Node_Id) return Boolean;
+      pragma Inline (Flag216);
+
+      function Flag217 (N : Node_Id) return Boolean;
+      pragma Inline (Flag217);
+
+      function Flag218 (N : Node_Id) return Boolean;
+      pragma Inline (Flag218);
+
+      function Flag219 (N : Node_Id) return Boolean;
+      pragma Inline (Flag219);
+
+      function Flag220 (N : Node_Id) return Boolean;
+      pragma Inline (Flag220);
+
+      function Flag221 (N : Node_Id) return Boolean;
+      pragma Inline (Flag221);
+
+      function Flag222 (N : Node_Id) return Boolean;
+      pragma Inline (Flag222);
+
+      function Flag223 (N : Node_Id) return Boolean;
+      pragma Inline (Flag223);
+
+      function Flag224 (N : Node_Id) return Boolean;
+      pragma Inline (Flag224);
+
+      function Flag225 (N : Node_Id) return Boolean;
+      pragma Inline (Flag225);
+
+      function Flag226 (N : Node_Id) return Boolean;
+      pragma Inline (Flag226);
+
+      function Flag227 (N : Node_Id) return Boolean;
+      pragma Inline (Flag227);
+
+      function Flag228 (N : Node_Id) return Boolean;
+      pragma Inline (Flag228);
+
+      function Flag229 (N : Node_Id) return Boolean;
+      pragma Inline (Flag229);
+
+      function Flag230 (N : Node_Id) return Boolean;
+      pragma Inline (Flag230);
+
+      function Flag231 (N : Node_Id) return Boolean;
+      pragma Inline (Flag231);
+
+      function Flag232 (N : Node_Id) return Boolean;
+      pragma Inline (Flag232);
+
+      function Flag233 (N : Node_Id) return Boolean;
+      pragma Inline (Flag233);
+
+      function Flag234 (N : Node_Id) return Boolean;
+      pragma Inline (Flag234);
+
+      function Flag235 (N : Node_Id) return Boolean;
+      pragma Inline (Flag235);
+
+      function Flag236 (N : Node_Id) return Boolean;
+      pragma Inline (Flag236);
+
+      function Flag237 (N : Node_Id) return Boolean;
+      pragma Inline (Flag237);
+
+      function Flag238 (N : Node_Id) return Boolean;
+      pragma Inline (Flag238);
+
+      function Flag239 (N : Node_Id) return Boolean;
+      pragma Inline (Flag239);
+
+      function Flag240 (N : Node_Id) return Boolean;
+      pragma Inline (Flag240);
+
+      function Flag241 (N : Node_Id) return Boolean;
+      pragma Inline (Flag241);
+
+      function Flag242 (N : Node_Id) return Boolean;
+      pragma Inline (Flag242);
+
+      function Flag243 (N : Node_Id) return Boolean;
+      pragma Inline (Flag243);
+
+      function Flag244 (N : Node_Id) return Boolean;
+      pragma Inline (Flag244);
+
+      function Flag245 (N : Node_Id) return Boolean;
+      pragma Inline (Flag245);
+
+      function Flag246 (N : Node_Id) return Boolean;
+      pragma Inline (Flag246);
+
+      function Flag247 (N : Node_Id) return Boolean;
+      pragma Inline (Flag247);
+
+      function Flag248 (N : Node_Id) return Boolean;
+      pragma Inline (Flag248);
+
+      function Flag249 (N : Node_Id) return Boolean;
+      pragma Inline (Flag249);
+
+      function Flag250 (N : Node_Id) return Boolean;
+      pragma Inline (Flag250);
+
+      function Flag251 (N : Node_Id) return Boolean;
+      pragma Inline (Flag251);
+
+      function Flag252 (N : Node_Id) return Boolean;
+      pragma Inline (Flag252);
+
+      function Flag253 (N : Node_Id) return Boolean;
+      pragma Inline (Flag253);
+
+      function Flag254 (N : Node_Id) return Boolean;
+      pragma Inline (Flag254);
+
       --  Procedures to set value of indicated field
 
       procedure Set_Nkind (N : Node_Id; Val : Node_Kind);
@@ -1785,6 +2070,12 @@ package Atree is
       procedure Set_Field27 (N : Node_Id; Val : Union_Id);
       pragma Inline (Set_Field27);
 
+      procedure Set_Field28 (N : Node_Id; Val : Union_Id);
+      pragma Inline (Set_Field28);
+
+      procedure Set_Field29 (N : Node_Id; Val : Union_Id);
+      pragma Inline (Set_Field29);
+
       procedure Set_Node1 (N : Node_Id; Val : Node_Id);
       pragma Inline (Set_Node1);
 
@@ -1866,6 +2157,12 @@ package Atree is
       procedure Set_Node27 (N : Node_Id; Val : Node_Id);
       pragma Inline (Set_Node27);
 
+      procedure Set_Node28 (N : Node_Id; Val : Node_Id);
+      pragma Inline (Set_Node28);
+
+      procedure Set_Node29 (N : Node_Id; Val : Node_Id);
+      pragma Inline (Set_Node29);
+
       procedure Set_List1 (N : Node_Id; Val : List_Id);
       pragma Inline (Set_List1);
 
@@ -1887,6 +2184,12 @@ package Atree is
       procedure Set_List14 (N : Node_Id; Val : List_Id);
       pragma Inline (Set_List14);
 
+      procedure Set_List25 (N : Node_Id; Val : List_Id);
+      pragma Inline (Set_List25);
+
+      procedure Set_Elist1 (N : Node_Id; Val : Elist_Id);
+      pragma Inline (Set_Elist1);
+
       procedure Set_Elist2 (N : Node_Id; Val : Elist_Id);
       pragma Inline (Set_Elist2);
 
@@ -1896,9 +2199,15 @@ package Atree is
       procedure Set_Elist4 (N : Node_Id; Val : Elist_Id);
       pragma Inline (Set_Elist4);
 
+      procedure Set_Elist5 (N : Node_Id; Val : Elist_Id);
+      pragma Inline (Set_Elist5);
+
       procedure Set_Elist8 (N : Node_Id; Val : Elist_Id);
       pragma Inline (Set_Elist8);
 
+      procedure Set_Elist10 (N : Node_Id; Val : Elist_Id);
+      pragma Inline (Set_Elist10);
+
       procedure Set_Elist13 (N : Node_Id; Val : Elist_Id);
       pragma Inline (Set_Elist13);
 
@@ -1920,6 +2229,12 @@ package Atree is
       procedure Set_Elist24 (N : Node_Id; Val : Elist_Id);
       pragma Inline (Set_Elist24);
 
+      procedure Set_Elist25 (N : Node_Id; Val : Elist_Id);
+      pragma Inline (Set_Elist25);
+
+      procedure Set_Elist26 (N : Node_Id; Val : Elist_Id);
+      pragma Inline (Set_Elist26);
+
       procedure Set_Name1 (N : Node_Id; Val : Name_Id);
       pragma Inline (Set_Name1);
 
@@ -2619,8 +2934,125 @@ package Atree is
       procedure Set_Flag215 (N : Node_Id; Val : Boolean);
       pragma Inline (Set_Flag215);
 
-      --  The following versions of Set_Noden also set the parent
-      --  pointer of the referenced node if it is non_Empty
+      procedure Set_Flag216 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag216);
+
+      procedure Set_Flag217 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag217);
+
+      procedure Set_Flag218 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag218);
+
+      procedure Set_Flag219 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag219);
+
+      procedure Set_Flag220 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag220);
+
+      procedure Set_Flag221 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag221);
+
+      procedure Set_Flag222 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag222);
+
+      procedure Set_Flag223 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag223);
+
+      procedure Set_Flag224 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag224);
+
+      procedure Set_Flag225 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag225);
+
+      procedure Set_Flag226 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag226);
+
+      procedure Set_Flag227 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag227);
+
+      procedure Set_Flag228 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag228);
+
+      procedure Set_Flag229 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag229);
+
+      procedure Set_Flag230 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag230);
+
+      procedure Set_Flag231 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag231);
+
+      procedure Set_Flag232 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag232);
+
+      procedure Set_Flag233 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag233);
+
+      procedure Set_Flag234 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag234);
+
+      procedure Set_Flag235 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag235);
+
+      procedure Set_Flag236 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag236);
+
+      procedure Set_Flag237 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag237);
+
+      procedure Set_Flag238 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag238);
+
+      procedure Set_Flag239 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag239);
+
+      procedure Set_Flag240 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag240);
+
+      procedure Set_Flag241 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag241);
+
+      procedure Set_Flag242 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag242);
+
+      procedure Set_Flag243 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag243);
+
+      procedure Set_Flag244 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag244);
+
+      procedure Set_Flag245 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag245);
+
+      procedure Set_Flag246 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag246);
+
+      procedure Set_Flag247 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag247);
+
+      procedure Set_Flag248 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag248);
+
+      procedure Set_Flag249 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag249);
+
+      procedure Set_Flag250 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag250);
+
+      procedure Set_Flag251 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag251);
+
+      procedure Set_Flag252 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag252);
+
+      procedure Set_Flag253 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag253);
+
+      procedure Set_Flag254 (N : Node_Id; Val : Boolean);
+      pragma Inline (Set_Flag254);
+
+      --  The following versions of Set_Noden also set the parent pointer of
+      --  the referenced node if it is not Empty.
 
       procedure Set_Node1_With_Parent (N : Node_Id; Val : Node_Id);
       pragma Inline (Set_Node1_With_Parent);
@@ -2638,8 +3070,7 @@ package Atree is
       pragma Inline (Set_Node5_With_Parent);
 
       --  The following versions of Set_Listn also set the parent pointer of
-      --  the referenced node if it is non_Empty. The procedures for List6
-      --  to List12 can only be applied to nodes which have an extension.
+      --  the referenced node if it is not Empty.
 
       procedure Set_List1_With_Parent (N : Node_Id; Val : List_Id);
       pragma Inline (Set_List1_With_Parent);
@@ -2675,12 +3106,12 @@ package Atree is
       -------------------------
 
       --  The nodes of the tree are stored in a table (i.e. an array). In the
-      --  case of extended nodes four consecutive components in the array are
+      --  case of extended nodes five consecutive components in the array are
       --  used. There are thus two formats for array components. One is used
       --  for non-extended nodes, and for the first component of extended
-      --  nodes. The other is used for the extension parts (second, third and
-      --  fourth components) of an extended node. A variant record structure
-      --  is used to distinguish the two formats.
+      --  nodes. The other is used for the extension parts (second, third,
+      --  fourth and fifth components) of an extended node. A variant record
+      --  structure is used to distinguish the two formats.
 
       type Node_Record (Is_Extension : Boolean := False) is record
 
@@ -2700,8 +3131,9 @@ package Atree is
          --  Flag used to indicate if node is a member of a list.
          --  This field is considered private to the Atree package.
 
-         Unused_1 : Boolean;
-         --  Currently unused flag
+         Has_Aspects : Boolean;
+         --  Flag used to indicate that a node has aspect specifications that
+         --  are associated with the node. See Aspects package for details.
 
          Rewrite_Ins : Boolean;
          --  Flag set by Mark_Rewrite_Insertion procedure.
@@ -2735,33 +3167,32 @@ package Atree is
          Flag18 : Boolean;
          --  The eighteen flags for a normal node
 
-         --  The above fields are used as follows in components 2-4 of
-         --  an extended node entry. These fields are not currently
-         --  used in component 5 (where we still have lots of room!)
-
-         --    In_List            used as  Flag19, Flag40, Flag129
-         --    Unused_1           used as  Flag20, Flag41, Flag130
-         --    Rewrite_Ins        used as  Flag21, Flag42, Flag131
-         --    Analyzed           used as  Flag22, Flag43, Flag132
-         --    Comes_From_Source  used as  Flag23, Flag44, Flag133
-         --    Error_Posted       used as  Flag24, Flag45, Flag134
-         --    Flag4              used as  Flag25, Flag46, Flag135
-         --    Flag5              used as  Flag26, Flag47, Flag136
-         --    Flag6              used as  Flag27, Flag48, Flag137
-         --    Flag7              used as  Flag28, Flag49, Flag138
-         --    Flag8              used as  Flag29, Flag50, Flag139
-         --    Flag9              used as  Flag30, Flag51, Flag140
-         --    Flag10             used as  Flag31, Flag52, Flag141
-         --    Flag11             used as  Flag32, Flag53, Flag142
-         --    Flag12             used as  Flag33, Flag54, Flag143
-         --    Flag13             used as  Flag34, Flag55, Flag144
-         --    Flag14             used as  Flag35, Flag56, Flag145
-         --    Flag15             used as  Flag36, Flag57, Flag146
-         --    Flag16             used as  Flag37, Flag58, Flag147
-         --    Flag17             used as  Flag38, Flag59, Flag148
-         --    Flag18             used as  Flag39, Flag60, Flag149
-         --    Pflag1             used as  Flag61, Flag62, Flag150
-         --    Pflag2             used as  Flag63, Flag64, Flag151
+         --  The above fields are used as follows in components 2-5 of
+         --  an extended node entry.
+
+         --    In_List              used as  Flag19, Flag40, Flag129, Flag216
+         --    Has_Aspects          used as  Flag20, Flag41, Flag130, Flag217
+         --    Rewrite_Ins          used as  Flag21, Flag42, Flag131, Flag218
+         --    Analyzed             used as  Flag22, Flag43, Flag132, Flag219
+         --    Comes_From_Source    used as  Flag23, Flag44, Flag133, Flag220
+         --    Error_Posted         used as  Flag24, Flag45, Flag134, Flag221
+         --    Flag4                used as  Flag25, Flag46, Flag135, Flag222
+         --    Flag5                used as  Flag26, Flag47, Flag136, Flag223
+         --    Flag6                used as  Flag27, Flag48, Flag137, Flag224
+         --    Flag7                used as  Flag28, Flag49, Flag138, Flag225
+         --    Flag8                used as  Flag29, Flag50, Flag139, Flag226
+         --    Flag9                used as  Flag30, Flag51, Flag140, Flag227
+         --    Flag10               used as  Flag31, Flag52, Flag141, Flag228
+         --    Flag11               used as  Flag32, Flag53, Flag142, Flag229
+         --    Flag12               used as  Flag33, Flag54, Flag143, Flag230
+         --    Flag13               used as  Flag34, Flag55, Flag144, Flag231
+         --    Flag14               used as  Flag35, Flag56, Flag145, Flag232
+         --    Flag15               used as  Flag36, Flag57, Flag146, Flag233
+         --    Flag16               used as  Flag37, Flag58, Flag147, Flag234
+         --    Flag17               used as  Flag38, Flag59, Flag148, Flag235
+         --    Flag18               used as  Flag39, Flag60, Flag149, Flag236
+         --    Pflag1               used as  Flag61, Flag62, Flag150, Flag237
+         --    Pflag2               used as  Flag63, Flag64, Flag151, Flag238
 
          Nkind : Node_Kind;
          --  For a non-extended node, or the initial section of an extended
@@ -2770,7 +3201,8 @@ package Atree is
          --
          --     Second entry: holds the Ekind field of the entity
          --     Third entry:  holds 8 additional flags (Flag65-Flag72)
-         --     Fourth entry: not currently used
+         --     Fourth entry: holds 8 additional flags (Flag239-246)
+         --     Fifth entry:  holds 8 additional flags (Flag247-254)
 
          --  Now finally (on an 32-bit boundary!) comes the variant part
 
@@ -2802,6 +3234,7 @@ package Atree is
             --  Extension (second component) of extended node
 
             when True =>
+
                Field6  : Union_Id;
                Field7  : Union_Id;
                Field8  : Union_Id;
@@ -2832,10 +3265,8 @@ package Atree is
             --  above is used to hold additional general fields and flags
             --  as follows:
 
-            --    Field6-9       Holds Field24-Field27
-            --    Field10        currently unused, reserved for expansion
-            --    Field11        Holds Flag184-Flag215
-            --    Field12        currently unused, reserved for expansion
+            --    Field6-11      Holds Field24-Field29
+            --    Field12        Holds Flag184-Flag215
 
          end case;
       end record;
@@ -2844,12 +3275,101 @@ package Atree is
       for Node_Record'Size use 8*32;
       for Node_Record'Alignment use 4;
 
-      --  The following defines the extendible array used for the nodes table
-      --  Nodes with extensions use two consecutive entries in the array
+      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,
+         Has_Aspects       => 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,
+         Has_Aspects       => 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
+      --  Nodes with extensions use five consecutive entries in the array
 
       package Nodes is new Table.Table (
         Table_Component_Type => Node_Record,
-        Table_Index_Type     => Node_Id,
+        Table_Index_Type     => Node_Id'Base,
         Table_Low_Bound      => First_Node_Id,
         Table_Initial        => Alloc.Nodes_Initial,
         Table_Increment      => Alloc.Nodes_Increment,