OSDN Git Service

* ada-tree.h (TYPE_RM_SIZE_NUM): Delete.
[pf3gnuchains/gcc-fork.git] / gcc / ada / sem_ch12.ads
index f9634bd..c3b3417 100644 (file)
@@ -6,18 +6,17 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2005, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2008, 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,  51  Franklin  Street,  Fifth  Floor, --
--- Boston, MA 02110-1301, USA.                                              --
+-- Public License  distributed with GNAT; see file COPYING3.  If not, go to --
+-- http://www.gnu.org/licenses for a complete copy of the license.          --
 --                                                                          --
 -- GNAT was originally developed  by the GNAT team at  New York University. --
 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
@@ -58,8 +57,7 @@ package Sem_Ch12 is
    function Copy_Generic_Node
      (N             : Node_Id;
       Parent_Id     : Node_Id;
-      Instantiating : Boolean)
-      return          Node_Id;
+      Instantiating : Boolean) return Node_Id;
    --  Copy the tree for a generic unit or its body. The unit is copied
    --  repeatedly: once to produce a copy on which semantic analysis of
    --  the generic is performed, and once for each instantiation. The tree
@@ -76,16 +74,47 @@ package Sem_Ch12 is
    --  of the ancestors of a child generic that is being instantiated.
 
    procedure Instantiate_Package_Body
-     (Body_Info    : Pending_Body_Info;
-      Inlined_Body : Boolean := False);
+     (Body_Info     : Pending_Body_Info;
+      Inlined_Body  : Boolean := False;
+      Body_Optional : Boolean := False);
    --  Called after semantic analysis, to complete the instantiation of
    --  package instances. The flag Inlined_Body is set if the body is
    --  being instantiated on the fly for inlined purposes.
+   --
+   --  The flag Body_Optional indicates that the call is for an instance
+   --  that precedes the current instance in the same declarative part.
+   --  This call is needed when instantiating a nested generic whose body
+   --  is to be found in the body of an instance. Normally we instantiate
+   --  package bodies only when they appear in the main unit, or when their
+   --  contents are needed for a nested generic G. If unit U contains several
+   --  instances I1, I2, etc. and I2 contains a nested generic, then when U
+   --  appears in the context of some other unit P that contains an instance
+   --  of G, we compile the body of I2, but not that of I1. However, when we
+   --  compile U as the main unit, we compile both bodies. This will lead to
+   --  lead to link-time errors if the compilation of I1 generates public
+   --  symbols, because those in I2 will receive different names in both
+   --  cases. This forces us to analyze the body of I1 even when U is not the
+   --  main unit. We don't want this additional mechanism to generate an error
+   --  when the body of the generic for I1 is not present, and this is the
+   --  reason for the presence of the flag Body_Optional, which is exchanged
+   --  between the current procedure and Load_Parent_Of_Generic.
 
    procedure Instantiate_Subprogram_Body
-     (Body_Info : Pending_Body_Info);
+     (Body_Info     : Pending_Body_Info;
+      Body_Optional : Boolean := False);
    --  Called after semantic analysis, to complete the instantiation of
-   --  function and procedure instances.
+   --  function and procedure instances. The flag Body_Optional has the
+   --  same purpose as described for Instantiate_Package_Body.
+
+   function Need_Subprogram_Instance_Body
+     (N    : Node_Id;
+      Subp : Entity_Id) return Boolean;
+
+   --  If a subprogram instance is inlined, indicate that the body of it
+   --  must be created, to be used in inlined calls by the back-end. The
+   --  subprogram may be inlined because the generic itself carries the
+   --  pragma, or because a pragma appears for the instance in the scope.
+   --  of the instance.
 
    procedure Save_Global_References (N : Node_Id);
    --  Traverse the original generic unit, and capture all references to
@@ -111,7 +140,7 @@ package Sem_Ch12 is
    --  an inlined body (so that errout can distinguish cases for generating
    --  error messages, otherwise the treatment is identical). In this call
    --  N is the subprogram body and E is the defining identifier of the
-   --  subprogram in quiestion. The resulting Sloc adjustment factor is
+   --  subprogram in question. The resulting Sloc adjustment factor is
    --  saved as part of the internal state of the Sem_Ch12 package for use
    --  in subsequent calls to copy nodes.
 
@@ -126,4 +155,18 @@ package Sem_Ch12 is
    procedure Initialize;
    --  Initializes internal data structures
 
+   procedure Check_Private_View (N : Node_Id);
+   --  Check whether the type of a generic entity has a different view between
+   --  the point of generic analysis and the point of instantiation. If the
+   --  view has changed, then at the point of instantiation we restore the
+   --  correct view to perform semantic analysis of the instance, and reset
+   --  the current view after instantiation. The processing is driven by the
+   --  current private status of the type of the node, and Has_Private_View,
+   --  a flag that is set at the point of generic compilation. If view and
+   --  flag are inconsistent then the type is updated appropriately.
+   --
+   --  This subprogram is used in Check_Generic_Actuals and Copy_Generic_Node,
+   --  and is exported here for the purpose of front-end inlining (see Exp_Ch6.
+   --  Expand_Inlined_Call.Process_Formals).
+
 end Sem_Ch12;