* config/arm/elf.h (ASM_OUTPUT_ALIGNED_COMMON): Remove definition.
[official-gcc.git] / gcc / ada / tbuild.ads
blobef321a149400a4c391dac6d650f4a5066cfc76cb
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-2002, 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, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, 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 ------------------------------------------------------------------------------
27 -- This package contains various utility procedures to assist in
28 -- building specific types of tree nodes.
30 with Types; use Types;
32 package Tbuild is
34 function Checks_Off (N : Node_Id) return Node_Id;
35 pragma Inline (Checks_Off);
36 -- Returns an N_Unchecked_Expression node whose expression is the given
37 -- argument. The results is a subexpression identical to the argument,
38 -- except that it will be analyzed and resolved with checks off.
40 function Convert_To (Typ : Entity_Id; Expr : Node_Id) return Node_Id;
41 -- Returns an expression that represents the result of a checked convert
42 -- of expression Exp to type T. If the base type of Exp is T, then no
43 -- conversion is required, and Exp is returned unchanged. Otherwise an
44 -- N_Type_Conversion node is constructed to convert the expression.
45 -- If an N_Type_Conversion node is required, Relocate_Node is used on
46 -- Exp. This means that it is safe to replace a node by a Convert_To
47 -- of itself to some other type.
49 function Make_Byte_Aligned_Attribute_Reference
50 (Sloc : Source_Ptr;
51 Prefix : Node_Id;
52 Attribute_Name : Name_Id)
53 return Node_Id;
54 pragma Inline (Make_Byte_Aligned_Attribute_Reference);
55 -- Like the standard Make_Attribute_Reference but the special flag
56 -- Must_Be_Byte_Aligned is set in the attribute reference node. The
57 -- Attribute_Name must be Name_Address or Name_Unrestricted_Access.
59 function Make_DT_Component
60 (Loc : Source_Ptr;
61 Typ : Entity_Id;
62 I : Positive)
63 return Node_Id;
64 -- Gives a reference to the Ith component of the Dispatch Table of
65 -- a given Tagged Type.
67 -- I = 1 --> Inheritance_Depth
68 -- I = 2 --> Tags (array of ancestors)
69 -- I = 3, 4 --> predefined primitive
70 -- function _Size (X : Typ) return Long_Long_Integer;
71 -- function _Equality (X : Typ; Y : Typ'Class) return Boolean;
72 -- I >= 5 --> User-Defined Primitive Operations
74 function Make_DT_Access
75 (Loc : Source_Ptr; Rec : Node_Id; Typ : Entity_Id) return Node_Id;
76 -- Create an access to the Dispatch Table by using the Tag field
77 -- of a tagged record : Acc_Dt (Rec.tag).all
79 function Make_Implicit_If_Statement
80 (Node : Node_Id;
81 Condition : Node_Id;
82 Then_Statements : List_Id;
83 Elsif_Parts : List_Id := No_List;
84 Else_Statements : List_Id := No_List)
85 return Node_Id;
86 pragma Inline (Make_Implicit_If_Statement);
87 -- This function makes an N_If_Statement node whose fields are filled
88 -- in with the indicated values (see Sinfo), and whose Sloc field is
89 -- is set to Sloc (Node). The effect is identical to calling function
90 -- Nmake.Make_If_Statement except that there is a check for restriction
91 -- No_Implicit_Conditionals, and if this restriction is being violated,
92 -- an error message is posted on Node.
94 function Make_Implicit_Label_Declaration
95 (Loc : Source_Ptr;
96 Defining_Identifier : Node_Id;
97 Label_Construct : Node_Id)
98 return Node_Id;
99 -- Used to construct an implicit label declaration node, including setting
100 -- the proper Label_Construct field (since Label_Construct is a semantic
101 -- field, the normal call to Make_Implicit_Label_Declaration does not
102 -- set this field).
104 function Make_Implicit_Loop_Statement
105 (Node : Node_Id;
106 Statements : List_Id;
107 Identifier : Node_Id := Empty;
108 Iteration_Scheme : Node_Id := Empty;
109 Has_Created_Identifier : Boolean := False;
110 End_Label : Node_Id := Empty)
111 return Node_Id;
112 -- This function makes an N_Loop_Statement node whose fields are filled
113 -- in with the indicated values (see Sinfo), and whose Sloc field is
114 -- is set to Sloc (Node). The effect is identical to calling function
115 -- Nmake.Make_Loop_Statement except that there is a check for restrictions
116 -- No_Implicit_Loops and No_Implicit_Conditionals (the first applying in
117 -- all cases, and the second only for while loops), and if one of these
118 -- restrictions is being violated, an error message is posted on Node.
120 function Make_Integer_Literal
121 (Loc : Source_Ptr;
122 Intval : Int)
123 return Node_Id;
124 pragma Inline (Make_Integer_Literal);
125 -- A convenient form of Make_Integer_Literal taking Int instead of Uint
127 function Make_Raise_Constraint_Error
128 (Sloc : Source_Ptr;
129 Condition : Node_Id := Empty;
130 Reason : RT_Exception_Code)
131 return Node_Id;
132 pragma Inline (Make_Raise_Constraint_Error);
133 -- A convenient form of Make_Raise_Constraint_Error where the Reason
134 -- is given simply as an enumeration value, rather than a Uint code.
136 function Make_Raise_Program_Error
137 (Sloc : Source_Ptr;
138 Condition : Node_Id := Empty;
139 Reason : RT_Exception_Code)
140 return Node_Id;
141 pragma Inline (Make_Raise_Program_Error);
142 -- A convenient form of Make_Raise_Program_Error where the Reason
143 -- is given simply as an enumeration value, rather than a Uint code.
145 function Make_Raise_Storage_Error
146 (Sloc : Source_Ptr;
147 Condition : Node_Id := Empty;
148 Reason : RT_Exception_Code)
149 return Node_Id;
150 pragma Inline (Make_Raise_Storage_Error);
151 -- A convenient form of Make_Raise_Storage_Error where the Reason
152 -- is given simply as an enumeration value, rather than a Uint code.
154 function Make_Unsuppress_Block
155 (Loc : Source_Ptr;
156 Check : Name_Id;
157 Stmts : List_Id)
158 return Node_Id;
159 -- Build a block with a pragma Suppress on 'Check'. Stmts is the
160 -- statements list that needs protection against the check
162 function New_Constraint_Error (Loc : Source_Ptr) return Node_Id;
163 -- This function builds a tree corresponding to the Ada statement
164 -- "raise Constraint_Error" and returns the root of this tree,
165 -- the N_Raise_Statement node.
167 function New_External_Name
168 (Related_Id : Name_Id;
169 Suffix : Character := ' ';
170 Suffix_Index : Int := 0;
171 Prefix : Character := ' ')
172 return Name_Id;
173 function New_External_Name
174 (Related_Id : Name_Id;
175 Suffix : String;
176 Suffix_Index : Int := 0;
177 Prefix : Character := ' ')
178 return Name_Id;
179 -- Builds a new entry in the names table of the form:
181 -- [Prefix &] Related_Id [& Suffix] [& Suffix_Index]
183 -- Prefix is prepended only if Prefix is non-blank (in which case it
184 -- must be an upper case letter other than O,Q,U,W (which are used for
185 -- identifier encoding, see Namet), and T is reserved for use by implicit
186 -- types. and X is reserved for use by debug type encoding (see package
187 -- Exp_Dbug). Note: the reason that Prefix is last is that it is almost
188 -- always omitted. The notable case of Prefix being non-null is when
189 -- it is 'T' for an implicit type.
191 -- Suffix_Index'Image is appended only if the value of Suffix_Index is
192 -- positive, or if Suffix_Index is negative 1, then a unique serialized
193 -- suffix is added. If Suffix_Index is zero, then no index is appended.
195 -- Suffix is also a single upper case letter other than O,Q,U,W,X and is a
196 -- required parameter (T is permitted). The constructed name is stored
197 -- using Find_Name so that it can be located using a subsequent Find_Name
198 -- operation (i.e. it is properly hashed into the names table). The upper
199 -- case letter given as the Suffix argument ensures that the name does
200 -- not clash with any Ada identifier name. These generated names are
201 -- permitted, but not required, to be made public by setting the flag
202 -- Is_Public in the associated entity.
204 function New_External_Name
205 (Suffix : Character;
206 Suffix_Index : Nat)
207 return Name_Id;
208 -- Builds a new entry in the names table of the form
209 -- Suffix & Suffix_Index'Image
210 -- where Suffix is a single upper case letter other than O,Q,U,W,X and is
211 -- a required parameter (T is permitted). The constructed name is stored
212 -- using Find_Name so that it can be located using a subsequent Find_Name
213 -- operation (i.e. it is properly hashed into the names table). The upper
214 -- case letter given as the Suffix argument ensures that the name does
215 -- not clash with any Ada identifier name. These generated names are
216 -- permitted, but not required, to be made public by setting the flag
217 -- Is_Public in the associated entity.
219 function New_Internal_Name (Id_Char : Character) return Name_Id;
220 -- Id_Char is an upper case letter other than O,Q,U,W (which are reserved
221 -- for identifier encoding (see Namet package for details) and X which is
222 -- used for debug encoding (see Exp_Dbug). The letter T is permitted, but
223 -- is reserved by convention for the case of internally generated types.
224 -- The result of the call is a new generated unique name of the form XyyyU
225 -- where X is Id_Char, yyy is a unique serial number, and U is either a
226 -- lower case s or b indicating if the current unit is a spec or a body.
228 -- The name is entered into the names table using Name_Enter rather than
229 -- Name_Find, because there can never be a need to locate the entry using
230 -- the Name_Find procedure later on. Names created by New_Internal_Name
231 -- are guaranteed to be consistent from one compilation to another (i.e.
232 -- if the identical unit is compiled with a semantically consistent set
233 -- of sources, the numbers will be consistent. This means that it is fine
234 -- to use these as public symbols.
236 function New_Occurrence_Of
237 (Def_Id : Entity_Id;
238 Loc : Source_Ptr)
239 return Node_Id;
240 -- New_Occurrence_Of creates an N_Identifier node which is an
241 -- occurrence of the defining identifier which is passed as its
242 -- argument. The Entity and Etype of the result are set from
243 -- the given defining identifier as follows: Entity is simply
244 -- a copy of Def_Id. Etype is a copy of Def_Id for types, and
245 -- a copy of the Etype of Def_Id for other entities.
247 function New_Reference_To
248 (Def_Id : Entity_Id;
249 Loc : Source_Ptr)
250 return Node_Id;
251 -- This is like New_Occurrence_Of, but it does not set the Etype field.
252 -- It is used from the expander, where Etype fields are generally not set,
253 -- since they are set when the expanded tree is reanalyzed.
255 function New_Suffixed_Name
256 (Related_Id : Name_Id;
257 Suffix : String)
258 return Name_Id;
259 -- This function is used to create special suffixed names used by the
260 -- debugger. Suffix is a string of upper case letters, used to construct
261 -- the required name. For instance, the special type used to record the
262 -- fixed-point small is called typ_SMALL where typ is the name of the
263 -- fixed-point type (as passed in Related_Id), and Suffix is "SMALL".
265 function OK_Convert_To (Typ : Entity_Id; Expr : Node_Id) return Node_Id;
266 -- Like Convert_To, except that a conversion node is always generated,
267 -- and the Conversion_OK flag is set on this conversion node.
269 function Unchecked_Convert_To
270 (Typ : Entity_Id;
271 Expr : Node_Id)
272 return Node_Id;
273 -- Like Convert_To, but if a conversion is actually needed, constructs
274 -- an N_Unchecked_Type_Conversion node to do the required conversion.
276 end Tbuild;