OSDN Git Service

* Makefile.in (reload1.o-warn): Remove.
[pf3gnuchains/gcc-fork.git] / gcc / ada / tbuild.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                               T B U I L D                                --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 1992-2007, 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 2,  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 COPYING.  If not, write --
19 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, USA.                                              --
21 --                                                                          --
22 -- GNAT was originally developed  by the GNAT team at  New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
24 --                                                                          --
25 ------------------------------------------------------------------------------
26
27 --  This package contains various utility procedures to assist in
28 --  building specific types of tree nodes.
29
30 with Namet; use Namet;
31 with Types; use Types;
32
33 package Tbuild is
34
35    function Checks_Off (N : Node_Id) return Node_Id;
36    pragma Inline (Checks_Off);
37    --  Returns an N_Unchecked_Expression node whose expression is the given
38    --  argument. The results is a subexpression identical to the argument,
39    --  except that it will be analyzed and resolved with checks off.
40
41    function Convert_To (Typ : Entity_Id; Expr : Node_Id) return Node_Id;
42    --  Returns an expression that represents the result of a checked convert
43    --  of expression Exp to type T. If the base type of Exp is T, then no
44    --  conversion is required, and Exp is returned unchanged. Otherwise an
45    --  N_Type_Conversion node is constructed to convert the expression.
46    --  If an N_Type_Conversion node is required, Relocate_Node is used on
47    --  Exp. This means that it is safe to replace a node by a Convert_To
48    --  of itself to some other type.
49
50    procedure Discard_Node (N : Node_Or_Entity_Id);
51    pragma Inline (Discard_Node);
52    --  This is a dummy procedure that simply returns and does nothing.
53    --  It is used when a function returning a Node_Id value is called
54    --  for its side effect (e.g. a call to Make to construct a node)
55    --  but the Node_Id value is not required.
56
57    procedure Discard_List (L : List_Id);
58    pragma Inline (Discard_List);
59    --  This is a dummy procedure that simply returns and does nothing.
60    --  It is used when a function returning a Node_Id value is called
61    --  for its side effect (e.g. a call to the pareser to parse a list
62    --  of compilation units), but the List_Id value is not required.
63
64    function Make_Byte_Aligned_Attribute_Reference
65      (Sloc           : Source_Ptr;
66       Prefix         : Node_Id;
67       Attribute_Name : Name_Id) return Node_Id;
68    pragma Inline (Make_Byte_Aligned_Attribute_Reference);
69    --  Like the standard Make_Attribute_Reference but the special flag
70    --  Must_Be_Byte_Aligned is set in the attribute reference node. The
71    --  Attribute_Name must be Name_Address or Name_Unrestricted_Access.
72
73    function Make_DT_Access
74      (Loc : Source_Ptr; Rec : Node_Id; Typ : Entity_Id) return Node_Id;
75    --  Create an access to the Dispatch Table by using the Tag field
76    --  of a tagged record : Acc_Dt (Rec.tag).all
77
78    function Make_Implicit_Exception_Handler
79      (Sloc              : Source_Ptr;
80       Choice_Parameter  : Node_Id := Empty;
81       Exception_Choices : List_Id;
82       Statements        : List_Id) return Node_Id;
83    pragma Inline (Make_Implicit_Exception_Handler);
84    --  This is just like Make_Exception_Handler, except that it also sets the
85    --  Local_Raise_Statements field to No_Elist, ensuring that it is properly
86    --  initialized. This should always be used when creating exception handlers
87    --  as part of the expansion.
88
89    function Make_Implicit_If_Statement
90      (Node            : Node_Id;
91       Condition       : Node_Id;
92       Then_Statements : List_Id;
93       Elsif_Parts     : List_Id := No_List;
94       Else_Statements : List_Id := No_List) return Node_Id;
95    pragma Inline (Make_Implicit_If_Statement);
96    --  This function makes an N_If_Statement node whose fields are filled
97    --  in with the indicated values (see Sinfo), and whose Sloc field is
98    --  is set to Sloc (Node). The effect is identical to calling function
99    --  Nmake.Make_If_Statement except that there is a check for restriction
100    --  No_Implicit_Conditionals, and if this restriction is being violated,
101    --  an error message is posted on Node.
102
103    function Make_Implicit_Label_Declaration
104      (Loc                 : Source_Ptr;
105       Defining_Identifier : Node_Id;
106       Label_Construct     : Node_Id) return Node_Id;
107    --  Used to contruct an implicit label declaration node, including setting
108    --  the proper Label_Construct field (since Label_Construct is a semantic
109    --  field, the normal call to Make_Implicit_Label_Declaration does not
110    --  set this field).
111
112    function Make_Implicit_Loop_Statement
113      (Node                   : Node_Id;
114       Statements             : List_Id;
115       Identifier             : Node_Id := Empty;
116       Iteration_Scheme       : Node_Id := Empty;
117       Has_Created_Identifier : Boolean := False;
118       End_Label              : Node_Id := Empty) return Node_Id;
119    --  This function makes an N_Loop_Statement node whose fields are filled
120    --  in with the indicated values (see Sinfo), and whose Sloc field is
121    --  is set to Sloc (Node). The effect is identical to calling function
122    --  Nmake.Make_Loop_Statement except that there is a check for restrictions
123    --  No_Implicit_Loops and No_Implicit_Conditionals (the first applying in
124    --  all cases, and the second only for while loops), and if one of these
125    --  restrictions is being violated, an error message is posted on Node.
126
127    function Make_Integer_Literal
128      (Loc    : Source_Ptr;
129       Intval : Int) return Node_Id;
130    pragma Inline (Make_Integer_Literal);
131    --  A convenient form of Make_Integer_Literal taking Int instead of Uint
132
133    function Make_Linker_Section_Pragma
134      (Ent : Entity_Id;
135       Loc : Source_Ptr;
136       Sec : String) return Node_Id;
137    --  Construct a Linker_Section pragma for entity Ent, using string Sec as
138    --  the section name. Loc is the Sloc value to use in building the pragma.
139
140    function Make_Raise_Constraint_Error
141      (Sloc      : Source_Ptr;
142       Condition : Node_Id := Empty;
143       Reason    : RT_Exception_Code) return Node_Id;
144    pragma Inline (Make_Raise_Constraint_Error);
145    --  A convenient form of Make_Raise_Constraint_Error where the Reason
146    --  is given simply as an enumeration value, rather than a Uint code.
147
148    function Make_Raise_Program_Error
149      (Sloc      : Source_Ptr;
150       Condition : Node_Id := Empty;
151       Reason    : RT_Exception_Code) return Node_Id;
152    pragma Inline (Make_Raise_Program_Error);
153    --  A convenient form of Make_Raise_Program_Error where the Reason
154    --  is given simply as an enumeration value, rather than a Uint code.
155
156    function Make_Raise_Storage_Error
157      (Sloc      : Source_Ptr;
158       Condition : Node_Id := Empty;
159       Reason    : RT_Exception_Code) return Node_Id;
160    pragma Inline (Make_Raise_Storage_Error);
161    --  A convenient form of Make_Raise_Storage_Error where the Reason
162    --  is given simply as an enumeration value, rather than a Uint code.
163
164    function Make_String_Literal
165      (Sloc   : Source_Ptr;
166       Strval : String) return Node_Id;
167    --  A convenient form of Make_String_Literal, where the string value
168    --  is given as a normal string instead of a String_Id value.
169
170    function Make_Unsuppress_Block
171      (Loc   : Source_Ptr;
172       Check : Name_Id;
173       Stmts : List_Id) return Node_Id;
174    --  Build a block with a pragma Suppress on 'Check'. Stmts is the
175    --  statements list that needs protection against the check
176
177    function New_Constraint_Error (Loc : Source_Ptr) return Node_Id;
178    --  This function builds a tree corresponding to the Ada statement
179    --  "raise Constraint_Error" and returns the root of this tree,
180    --  the N_Raise_Statement node.
181
182    function New_External_Name
183      (Related_Id   : Name_Id;
184       Suffix       : Character := ' ';
185       Suffix_Index : Int       := 0;
186       Prefix       : Character := ' ') return Name_Id;
187    function New_External_Name
188      (Related_Id   : Name_Id;
189       Suffix       : String;
190       Suffix_Index : Int       := 0;
191       Prefix       : Character := ' ') return Name_Id;
192    --  Builds a new entry in the names table of the form:
193    --
194    --    [Prefix  &] Related_Id [& Suffix] [& Suffix_Index]
195    --
196    --  Prefix is prepended only if Prefix is non-blank (in which case it
197    --  must be an upper case letter other than O,Q,U,W (which are used for
198    --  identifier encoding, see Namet), and T is reserved for use by implicit
199    --  types. and X is reserved for use by debug type encoding (see package
200    --  Exp_Dbug). Note: the reason that Prefix is last is that it is almost
201    --  always omitted. The notable case of Prefix being non-null is when
202    --  it is 'T' for an implicit type.
203
204    --  Suffix_Index'Image is appended only if the value of Suffix_Index is
205    --  positive, or if Suffix_Index is negative 1, then a unique serialized
206    --  suffix is added. If Suffix_Index is zero, then no index is appended.
207
208    --  Suffix is also a single upper case letter other than O,Q,U,W,X and is a
209    --  required parameter (T is permitted). The constructed name is stored
210    --  using Find_Name so that it can be located using a subsequent Find_Name
211    --  operation (i.e. it is properly hashed into the names table). The upper
212    --  case letter given as the Suffix argument ensures that the name does
213    --  not clash with any Ada identifier name. These generated names are
214    --  permitted, but not required, to be made public by setting the flag
215    --  Is_Public in the associated entity.
216
217    function New_External_Name
218      (Suffix       : Character;
219       Suffix_Index : Nat) return Name_Id;
220    --  Builds a new entry in the names table of the form
221    --    Suffix & Suffix_Index'Image
222    --  where Suffix is a single upper case letter other than O,Q,U,W,X and is
223    --  a required parameter (T is permitted). The constructed name is stored
224    --  using Find_Name so that it can be located using a subsequent Find_Name
225    --  operation (i.e. it is properly hashed into the names table). The upper
226    --  case letter given as the Suffix argument ensures that the name does
227    --  not clash with any Ada identifier name. These generated names are
228    --  permitted, but not required, to be made public by setting the flag
229    --  Is_Public in the associated entity.
230
231    function New_Internal_Name (Id_Char : Character) return Name_Id;
232    --  Id_Char is an upper case letter other than O,Q,U,W (which are reserved
233    --  for identifier encoding (see Namet package for details) and X which is
234    --  used for debug encoding (see Exp_Dbug). The letter T is permitted, but
235    --  is reserved by convention for the case of internally generated types.
236    --  The result of the call is a new generated unique name of the form XyyyU
237    --  where X is Id_Char, yyy is a unique serial number, and U is either a
238    --  lower case s or b indicating if the current unit is a spec or a body.
239    --
240    --  The name is entered into the names table using Name_Enter rather than
241    --  Name_Find, because there can never be a need to locate the entry using
242    --  the Name_Find procedure later on. Names created by New_Internal_Name
243    --  are guaranteed to be consistent from one compilation to another (i.e.
244    --  if the identical unit is compiled with a semantically consistent set
245    --  of sources, the numbers will be consistent. This means that it is fine
246    --  to use these as public symbols.
247
248    function New_Occurrence_Of
249      (Def_Id : Entity_Id;
250       Loc    : Source_Ptr) return Node_Id;
251    --  New_Occurrence_Of creates an N_Identifier node which is an
252    --  occurrence of the defining identifier which is passed as its
253    --  argument. The Entity and Etype of the result are set from
254    --  the given defining identifier as follows: Entity is simply
255    --  a copy of Def_Id. Etype is a copy of Def_Id for types, and
256    --  a copy of the Etype of Def_Id for other entities.
257
258    function New_Reference_To
259      (Def_Id : Entity_Id;
260       Loc    : Source_Ptr) return Node_Id;
261    --  This is like New_Occurrence_Of, but it does not set the Etype field.
262    --  It is used from the expander, where Etype fields are generally not set,
263    --  since they are set when the expanded tree is reanalyzed.
264
265    function New_Suffixed_Name
266      (Related_Id : Name_Id;
267       Suffix     : String) return Name_Id;
268    --  This function is used to create special suffixed names used by the
269    --  debugger. Suffix is a string of upper case letters, used to construct
270    --  the required name. For instance, the special type used to record the
271    --  fixed-point small is called typ_SMALL where typ is the name of the
272    --  fixed-point type (as passed in Related_Id), and Suffix is "SMALL".
273
274    function OK_Convert_To (Typ : Entity_Id; Expr : Node_Id) return Node_Id;
275    --  Like Convert_To, except that a conversion node is always generated,
276    --  and the Conversion_OK flag is set on this conversion node.
277
278    function Unchecked_Convert_To
279      (Typ  : Entity_Id;
280       Expr : Node_Id) return Node_Id;
281    --  Like Convert_To, but if a conversion is actually needed, constructs
282    --  an N_Unchecked_Type_Conversion node to do the required conversion.
283
284 end Tbuild;