fixing pr42337
[official-gcc.git] / gcc / ada / exp_ch6.ads
blob242995f490d2c92b9a50948dcf28233ccdda50d1
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- E X P _ C H 6 --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2008, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
26 -- Expand routines for chapter 6 constructs
28 with Types; use Types;
30 package Exp_Ch6 is
32 procedure Expand_N_Function_Call (N : Node_Id);
33 procedure Expand_N_Subprogram_Body (N : Node_Id);
34 procedure Expand_N_Subprogram_Body_Stub (N : Node_Id);
35 procedure Expand_N_Subprogram_Declaration (N : Node_Id);
36 procedure Expand_N_Procedure_Call_Statement (N : Node_Id);
38 procedure Expand_Call (N : Node_Id);
39 -- This procedure contains common processing for Expand_N_Function_Call,
40 -- Expand_N_Procedure_Statement, and Expand_N_Entry_Call.
42 procedure Freeze_Subprogram (N : Node_Id);
43 -- generate the appropriate expansions related to Subprogram freeze
44 -- nodes (e.g. the filling of the corresponding Dispatch Table for
45 -- Primitive Operations)
47 -- The following type defines the various forms of allocation used for the
48 -- results of build-in-place function calls.
50 type BIP_Allocation_Form is
51 (Unspecified,
52 Caller_Allocation,
53 Secondary_Stack,
54 Global_Heap,
55 User_Storage_Pool);
57 type BIP_Formal_Kind is
58 -- Ada 2005 (AI-318-02): This type defines the kinds of implicit extra
59 -- formals created for build-in-place functions. The order of the above
60 -- enumeration literals matches the order in which the formals are
61 -- declared. See Sem_Ch6.Create_Extra_Formals.
62 (BIP_Alloc_Form,
63 -- Present if result subtype is unconstrained, or if the result type
64 -- is tagged. Indicates whether the return object is allocated by the
65 -- caller or callee, and if the callee, whether to use the secondary
66 -- stack or the heap. See Create_Extra_Formals.
67 BIP_Final_List,
68 -- Present if result type needs finalization. Pointer to caller's
69 -- finalization list.
70 BIP_Master,
71 -- Present if result type contains tasks. Master associated with
72 -- calling context.
73 BIP_Activation_Chain,
74 -- Present if result type contains tasks. Caller's activation chain
75 BIP_Object_Access);
76 -- Present for all build-in-place functions. Address at which to place
77 -- the return object, or null if BIP_Alloc_Form indicates
78 -- allocated by callee.
79 -- ??? We also need to be able to pass in some way to access a
80 -- user-defined storage pool at some point. And perhaps a constrained
81 -- flag.
83 function BIP_Formal_Suffix (Kind : BIP_Formal_Kind) return String;
84 -- Ada 2005 (AI-318-02): Returns a string to be used as the suffix of names
85 -- for build-in-place formal parameters of the given kind.
87 function Build_In_Place_Formal
88 (Func : Entity_Id;
89 Kind : BIP_Formal_Kind) return Entity_Id;
90 -- Ada 2005 (AI-318-02): Locates and returns the entity for the implicit
91 -- build-in-place formal parameter of the given kind associated with the
92 -- function Func, and returns its Entity_Id. It is a bug if not found; the
93 -- caller should ensure this is called only when the extra formal exists.
95 function Is_Build_In_Place_Function (E : Entity_Id) return Boolean;
96 -- Ada 2005 (AI-318-02): Returns True if E denotes a function, generic
97 -- function, or access-to-function type whose result must be built in
98 -- place; otherwise returns False. For Ada 2005, this is currently
99 -- restricted to the set of functions whose result subtype is an inherently
100 -- limited type. In Ada 95, this must be False for inherently limited
101 -- result types (but currently returns False for all Ada 95 functions).
102 -- Eventually we plan to support build-in-place for nonlimited types.
103 -- Build-in-place is usually more efficient for large things, and less
104 -- efficient for small things. However, we never use build-in-place if the
105 -- convention is other than Ada, because that would disturb mixed-language
106 -- programs. Note that for the non-inherently-limited cases, we must make
107 -- the same decision for Ada 95 and 2005, so that mixed-dialect programs
108 -- will work.
110 function Is_Build_In_Place_Function_Call (N : Node_Id) return Boolean;
111 -- Ada 2005 (AI-318-02): Returns True if N denotes a call to a function
112 -- that requires handling as a build-in-place call or is a qualified
113 -- expression applied to such a call; otherwise returns False.
115 procedure Make_Build_In_Place_Call_In_Allocator
116 (Allocator : Node_Id;
117 Function_Call : Node_Id);
118 -- Ada 2005 (AI-318-02): Handle a call to a build-in-place function that
119 -- occurs as the expression initializing an allocator, by passing access
120 -- to the allocated object as an additional parameter of the function call.
121 -- A new access object is declared that is initialized to the result of the
122 -- allocator, passed to the function, and the allocator is rewritten to
123 -- refer to that access object. Function_Call must denote either an
124 -- N_Function_Call node for which Is_Build_In_Place_Call is True, or else
125 -- an N_Qualified_Expression node applied to such a function call.
127 procedure Make_Build_In_Place_Call_In_Anonymous_Context
128 (Function_Call : Node_Id);
129 -- Ada 2005 (AI-318-02): Handle a call to a build-in-place function that
130 -- occurs in a context that does not provide a separate object. A temporary
131 -- object is created to act as the return object and an access to the
132 -- temporary is passed as an additional parameter of the call. This occurs
133 -- in contexts such as subprogram call actuals and object renamings.
134 -- Function_Call must denote either an N_Function_Call node for which
135 -- Is_Build_In_Place_Call is True, or else an N_Qualified_Expression node
136 -- applied to such a function call.
138 procedure Make_Build_In_Place_Call_In_Assignment
139 (Assign : Node_Id;
140 Function_Call : Node_Id);
141 -- Ada 2005 (AI-318-02): Handle a call to a build-in-place function that
142 -- occurs as the right-hand side of an assignment statement by passing
143 -- access to the left-hand side as an additional parameter of the function
144 -- call. Assign must denote a N_Assignment_Statement. Function_Call must
145 -- denote either an N_Function_Call node for which Is_Build_In_Place_Call
146 -- is True, or an N_Qualified_Expression node applied to such a function
147 -- call.
149 procedure Make_Build_In_Place_Call_In_Object_Declaration
150 (Object_Decl : Node_Id;
151 Function_Call : Node_Id);
152 -- Ada 2005 (AI-318-02): Handle a call to a build-in-place function that
153 -- occurs as the expression initializing an object declaration by
154 -- passing access to the declared object as an additional parameter of the
155 -- function call. Function_Call must denote either an N_Function_Call node
156 -- for which Is_Build_In_Place_Call is True, or an N_Qualified_Expression
157 -- node applied to such a function call.
159 function Needs_BIP_Final_List (E : Entity_Id) return Boolean;
160 -- ???pragma Precondition (Is_Build_In_Place_Function (E));
161 -- Ada 2005 (AI-318-02): Returns True if the function needs the
162 -- BIP_Final_List implicit parameter.
164 end Exp_Ch6;