OSDN Git Service

* gcc-interface/ada-tree.def: Fix formatting nits.
[pf3gnuchains/gcc-fork.git] / gcc / ada / gcc-interface / ada-tree.h
1 /****************************************************************************
2  *                                                                          *
3  *                         GNAT COMPILER COMPONENTS                         *
4  *                                                                          *
5  *                             A D A - T R E E                              *
6  *                                                                          *
7  *                              C Header File                               *
8  *                                                                          *
9  *          Copyright (C) 1992-2009, 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 along with GCC; see the file COPYING3.  If not see        *
19  * <http://www.gnu.org/licenses/>.                                          *
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  ****************************************************************************/
25
26 /* Ada uses the lang_decl and lang_type fields to hold a tree.  */
27 union lang_tree_node
28   GTY((desc ("0"),
29        chain_next ("(union lang_tree_node *)TREE_CHAIN (&%h.t)")))
30 {
31   union tree_node GTY((tag ("0"))) t;
32 };
33 struct lang_decl GTY(()) { tree t; };
34 struct lang_type GTY(()) { tree t; };
35
36 /* Define macros to get and set the tree in TYPE_ and DECL_LANG_SPECIFIC.  */
37 #define GET_TYPE_LANG_SPECIFIC(NODE) \
38   (TYPE_LANG_SPECIFIC (NODE) ? TYPE_LANG_SPECIFIC (NODE)->t : NULL_TREE)
39 #define SET_TYPE_LANG_SPECIFIC(NODE, X) \
40  (TYPE_LANG_SPECIFIC (NODE)                     \
41   = (TYPE_LANG_SPECIFIC (NODE)                  \
42      ? TYPE_LANG_SPECIFIC (NODE) : GGC_NEW (struct lang_type))) \
43  ->t = X;
44
45 #define GET_DECL_LANG_SPECIFIC(NODE) \
46   (DECL_LANG_SPECIFIC (NODE) ? DECL_LANG_SPECIFIC (NODE)->t : NULL_TREE)
47 #define SET_DECL_LANG_SPECIFIC(NODE, VALUE)     \
48  (DECL_LANG_SPECIFIC (NODE)                     \
49   = (DECL_LANG_SPECIFIC (NODE)                  \
50      ? DECL_LANG_SPECIFIC (NODE) : GGC_NEW (struct lang_decl))) \
51  ->t = VALUE;
52
53 /* Flags added to GCC type nodes.  */
54
55 /* For RECORD_TYPE, UNION_TYPE, and QUAL_UNION_TYPE, nonzero if this is a
56    record being used as a fat pointer (only true for RECORD_TYPE).  */
57 #define TYPE_IS_FAT_POINTER_P(NODE) \
58   TYPE_LANG_FLAG_0 (RECORD_OR_UNION_CHECK (NODE))
59
60 #define TYPE_FAT_POINTER_P(NODE) \
61   (TREE_CODE (NODE) == RECORD_TYPE && TYPE_IS_FAT_POINTER_P (NODE))
62
63 /* For integral types and array types, nonzero if this is a packed array type
64    used for bit-packed types.  Such types should not be extended to a larger
65    size or validated against a specified size.  */
66 #define TYPE_PACKED_ARRAY_TYPE_P(NODE) TYPE_LANG_FLAG_0 (NODE)
67
68 #define TYPE_IS_PACKED_ARRAY_TYPE_P(NODE) \
69   ((TREE_CODE (NODE) == INTEGER_TYPE || TREE_CODE (NODE) == ARRAY_TYPE) \
70    && TYPE_PACKED_ARRAY_TYPE_P (NODE))
71
72 /* For INTEGER_TYPE, nonzero if this is a modular type with a modulus that
73    is not equal to two to the power of its mode's size.  */
74 #define TYPE_MODULAR_P(NODE) TYPE_LANG_FLAG_1 (INTEGER_TYPE_CHECK (NODE))
75
76 /* For ARRAY_TYPE, nonzero if this type corresponds to a dimension of
77    an Ada array other than the first.  */
78 #define TYPE_MULTI_ARRAY_P(NODE) TYPE_LANG_FLAG_1 (ARRAY_TYPE_CHECK (NODE))
79
80 /* For FUNCTION_TYPE, nonzero if this denotes a function returning an
81    unconstrained array or record.  */
82 #define TYPE_RETURNS_UNCONSTRAINED_P(NODE) \
83   TYPE_LANG_FLAG_1 (FUNCTION_TYPE_CHECK (NODE))
84
85 /* For RECORD_TYPE, UNION_TYPE, and QUAL_UNION_TYPE, nonzero if this denotes
86    a justified modular type (will only be true for RECORD_TYPE).  */
87 #define TYPE_JUSTIFIED_MODULAR_P(NODE) \
88   TYPE_LANG_FLAG_1 (RECORD_OR_UNION_CHECK (NODE))
89
90 /* Nonzero in an arithmetic subtype if this is a subtype not known to the
91    front-end.  */
92 #define TYPE_EXTRA_SUBTYPE_P(NODE) TYPE_LANG_FLAG_2 (NODE)
93
94 /* Nonzero for composite types if this is a by-reference type.  */
95 #define TYPE_BY_REFERENCE_P(NODE) TYPE_LANG_FLAG_2 (NODE)
96
97 /* For RECORD_TYPE, UNION_TYPE, and QUAL_UNION_TYPE, nonzero if this is the
98    type for an object whose type includes its template in addition to
99    its value (only true for RECORD_TYPE).  */
100 #define TYPE_CONTAINS_TEMPLATE_P(NODE) \
101   TYPE_LANG_FLAG_3 (RECORD_OR_UNION_CHECK (NODE))
102
103 /* For INTEGER_TYPE, nonzero if this really represents a VAX
104    floating-point type.  */
105 #define TYPE_VAX_FLOATING_POINT_P(NODE) \
106   TYPE_LANG_FLAG_3 (INTEGER_TYPE_CHECK (NODE))
107
108 /* True if NODE is a thin pointer.  */
109 #define TYPE_THIN_POINTER_P(NODE)                       \
110   (POINTER_TYPE_P (NODE)                                \
111    && TREE_CODE (TREE_TYPE (NODE)) == RECORD_TYPE       \
112    && TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (NODE)))
113
114 /* True if TYPE is either a fat or thin pointer to an unconstrained
115    array.  */
116 #define TYPE_FAT_OR_THIN_POINTER_P(NODE) \
117   (TYPE_FAT_POINTER_P (NODE) || TYPE_THIN_POINTER_P (NODE))
118
119 /* For INTEGER_TYPEs, nonzero if the type has a biased representation.  */
120 #define TYPE_BIASED_REPRESENTATION_P(NODE) \
121   TYPE_LANG_FLAG_4 (INTEGER_TYPE_CHECK (NODE))
122
123 /* For ARRAY_TYPEs, nonzero if the array type has Convention_Fortran.  */
124 #define TYPE_CONVENTION_FORTRAN_P(NODE) \
125   TYPE_LANG_FLAG_4 (ARRAY_TYPE_CHECK (NODE))
126
127 /* For FUNCTION_TYPEs, nonzero if the function returns by reference.  */
128 #define TYPE_RETURNS_BY_REF_P(NODE) \
129   TYPE_LANG_FLAG_4 (FUNCTION_TYPE_CHECK (NODE))
130
131 /* For VOID_TYPE, ENUMERAL_TYPE, UNION_TYPE, and RECORD_TYPE, nonzero if this
132    is a dummy type, made to correspond to a private or incomplete type.  */
133 #define TYPE_DUMMY_P(NODE) TYPE_LANG_FLAG_4 (NODE)
134
135 /* True if TYPE is such a dummy type.  */
136 #define TYPE_IS_DUMMY_P(NODE) \
137   ((TREE_CODE (NODE) == VOID_TYPE || TREE_CODE (NODE) == RECORD_TYPE    \
138     || TREE_CODE (NODE) == UNION_TYPE || TREE_CODE (NODE) == ENUMERAL_TYPE) \
139    && TYPE_DUMMY_P (NODE))
140
141 /* For FUNCTION_TYPEs, nonzero if function returns by being passed a pointer
142    to a place to store its result.  */
143 #define TYPE_RETURNS_BY_TARGET_PTR_P(NODE) \
144   TYPE_LANG_FLAG_5 (FUNCTION_TYPE_CHECK (NODE))
145
146 /* For an INTEGER_TYPE, nonzero if TYPE_ACTUAL_BOUNDS is present.  */
147 #define TYPE_HAS_ACTUAL_BOUNDS_P(NODE) \
148   TYPE_LANG_FLAG_5 (INTEGER_TYPE_CHECK (NODE))
149
150 /* For a RECORD_TYPE, nonzero if this was made just to supply needed
151    padding or alignment.  */
152 #define TYPE_IS_PADDING_P(NODE) TYPE_LANG_FLAG_5 (RECORD_TYPE_CHECK (NODE))
153
154 /* True if TYPE can alias any other types.  */
155 #define TYPE_UNIVERSAL_ALIASING_P(NODE) TYPE_LANG_FLAG_6 (NODE)
156
157 /* This field is only defined for FUNCTION_TYPE nodes. If the Ada subprogram
158    contains no parameters passed by copy in/copy out then this field is zero.
159    Otherwise it points to a list of nodes used to specify the return values
160    of the out (or in out) parameters that qualify to be passed by copy in/
161    copy out. For a full description of the copy in/copy out parameter passing
162    mechanism refer to the routine gnat_to_gnu_entity. */
163 #define TYPE_CI_CO_LIST(NODE) TYPE_LANG_SLOT_1 (FUNCTION_TYPE_CHECK (NODE))
164
165 /* For integral types, this is the RM Size of the type.  */
166 #define TYPE_RM_SIZE(NODE) \
167   TYPE_LANG_SLOT_1 (TREE_CHECK3 (NODE, ENUMERAL_TYPE, BOOLEAN_TYPE, INTEGER_TYPE))
168
169 /* For an INTEGER_TYPE with TYPE_MODULAR_P, this is the value of the
170    modulus. */
171 #define TYPE_MODULUS(NODE) GET_TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE))
172 #define SET_TYPE_MODULUS(NODE, X) \
173   SET_TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE), X)
174
175 /* For an INTEGER_TYPE that is the TYPE_DOMAIN of some ARRAY_TYPE, points to
176    the type corresponding to the Ada index type.  */
177 #define TYPE_INDEX_TYPE(NODE) \
178   GET_TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE))
179 #define SET_TYPE_INDEX_TYPE(NODE, X) \
180   SET_TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE), X)
181
182 /* For an INTEGER_TYPE with TYPE_VAX_FLOATING_POINT_P, stores the
183    Digits_Value.  */
184 #define TYPE_DIGITS_VALUE(NODE) \
185   GET_TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE))
186 #define SET_TYPE_DIGITS_VALUE(NODE, X) \
187   SET_TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE), X)
188
189 /* For a RECORD_TYPE that is a fat pointer, point to the type for the
190    unconstrained object.  Likewise for a RECORD_TYPE that is pointed
191    to by a thin pointer.  */
192 #define TYPE_UNCONSTRAINED_ARRAY(NODE) \
193   GET_TYPE_LANG_SPECIFIC (RECORD_TYPE_CHECK (NODE))
194 #define SET_TYPE_UNCONSTRAINED_ARRAY(NODE, X) \
195   SET_TYPE_LANG_SPECIFIC (RECORD_TYPE_CHECK (NODE), X)
196
197 /* For other RECORD_TYPEs and all UNION_TYPEs and QUAL_UNION_TYPEs, the Ada
198    size of the object.  This differs from the GCC size in that it does not
199    include any rounding up to the alignment of the type.  */
200 #define TYPE_ADA_SIZE(NODE) \
201   GET_TYPE_LANG_SPECIFIC (RECORD_OR_UNION_CHECK (NODE))
202 #define SET_TYPE_ADA_SIZE(NODE, X) \
203   SET_TYPE_LANG_SPECIFIC (RECORD_OR_UNION_CHECK (NODE), X)
204
205 /* For an INTEGER_TYPE with TYPE_HAS_ACTUAL_BOUNDS_P or an ARRAY_TYPE, this is
206    the index type that should be used when the actual bounds are required for
207    a template.  This is used in the case of packed arrays.  */
208 #define TYPE_ACTUAL_BOUNDS(NODE) \
209   GET_TYPE_LANG_SPECIFIC (TREE_CHECK2 (NODE, INTEGER_TYPE, ARRAY_TYPE))
210 #define SET_TYPE_ACTUAL_BOUNDS(NODE, X) \
211   SET_TYPE_LANG_SPECIFIC (TREE_CHECK2 (NODE, INTEGER_TYPE, ARRAY_TYPE), X)
212
213 /* In an UNCONSTRAINED_ARRAY_TYPE, points to the record containing both
214    the template and object.
215
216    ??? We also put this on an ENUMERAL_TYPE that's dummy.  Technically,
217    this is a conflict on the minval field, but there doesn't seem to be
218    simple fix, so we'll live with this kludge for now.  */
219 #define TYPE_OBJECT_RECORD_TYPE(NODE) \
220   (TREE_CHECK2 ((NODE), UNCONSTRAINED_ARRAY_TYPE, ENUMERAL_TYPE)->type.minval)
221
222 /* Nonzero in a FUNCTION_DECL that represents a stubbed function
223    discriminant.  */
224 #define DECL_STUBBED_P(NODE) DECL_LANG_FLAG_0 (FUNCTION_DECL_CHECK (NODE))
225
226 /* Nonzero in a VAR_DECL if it is guaranteed to be constant after having
227    been elaborated and TREE_READONLY is not set on it.  */
228 #define DECL_READONLY_ONCE_ELAB(NODE) DECL_LANG_FLAG_0 (VAR_DECL_CHECK (NODE))
229
230 /* Nonzero if this decl is always used by reference; i.e., an INDIRECT_REF
231    is needed to access the object.  */
232 #define DECL_BY_REF_P(NODE) DECL_LANG_FLAG_1 (NODE)
233
234 /* Nonzero in a FIELD_DECL that is a dummy built for some internal reason.  */
235 #define DECL_INTERNAL_P(NODE) DECL_LANG_FLAG_3 (FIELD_DECL_CHECK (NODE))
236
237 /* Nonzero if this decl is a PARM_DECL for an Ada array being passed to a
238    foreign convention subprogram.  */
239 #define DECL_BY_COMPONENT_PTR_P(NODE) DECL_LANG_FLAG_3 (PARM_DECL_CHECK (NODE))
240
241 /* Nonzero in a FUNCTION_DECL that corresponds to an elaboration procedure.  */
242 #define DECL_ELABORATION_PROC_P(NODE) \
243   DECL_LANG_FLAG_3 (FUNCTION_DECL_CHECK (NODE))
244
245 /* Nonzero if this is a decl for a pointer that points to something which
246    is readonly.  Used mostly for fat pointers.  */
247 #define DECL_POINTS_TO_READONLY_P(NODE) DECL_LANG_FLAG_4 (NODE)
248
249 /* Nonzero in a PARM_DECL if we are to pass by descriptor.  */
250 #define DECL_BY_DESCRIPTOR_P(NODE) DECL_LANG_FLAG_5 (PARM_DECL_CHECK (NODE))
251
252 /* Nonzero in a VAR_DECL if it is a pointer renaming a global object.  */
253 #define DECL_RENAMING_GLOBAL_P(NODE) DECL_LANG_FLAG_5 (VAR_DECL_CHECK (NODE))
254
255 /* In a CONST_DECL, points to a VAR_DECL that is allocatable to
256    memory.  Used when a scalar constant is aliased or has its
257    address taken.  */
258 #define DECL_CONST_CORRESPONDING_VAR(NODE) \
259   GET_DECL_LANG_SPECIFIC (CONST_DECL_CHECK (NODE))
260 #define SET_DECL_CONST_CORRESPONDING_VAR(NODE, X) \
261   SET_DECL_LANG_SPECIFIC (CONST_DECL_CHECK (NODE), X)
262
263 /* In a FIELD_DECL, points to the FIELD_DECL that was the ultimate
264    source of the decl.  */
265 #define DECL_ORIGINAL_FIELD(NODE) \
266   GET_DECL_LANG_SPECIFIC (FIELD_DECL_CHECK (NODE))
267 #define SET_DECL_ORIGINAL_FIELD(NODE, X) \
268   SET_DECL_LANG_SPECIFIC (FIELD_DECL_CHECK (NODE), X)
269
270 /* In a VAR_DECL, points to the object being renamed if the VAR_DECL is a
271    renaming pointer, otherwise 0.  Note that this object is guaranteed to
272    be protected against multiple evaluations.  */
273 #define DECL_RENAMED_OBJECT(NODE) \
274   GET_DECL_LANG_SPECIFIC (VAR_DECL_CHECK (NODE))
275 #define SET_DECL_RENAMED_OBJECT(NODE, X) \
276   SET_DECL_LANG_SPECIFIC (VAR_DECL_CHECK (NODE), X)
277
278 /* In a TYPE_DECL, points to the parallel type if any, otherwise 0.  */
279 #define DECL_PARALLEL_TYPE(NODE) \
280   GET_DECL_LANG_SPECIFIC (TYPE_DECL_CHECK (NODE))
281 #define SET_DECL_PARALLEL_TYPE(NODE, X) \
282   SET_DECL_LANG_SPECIFIC (TYPE_DECL_CHECK (NODE), X)
283
284 /* In a FUNCTION_DECL, points to the stub associated with the function
285    if any, otherwise 0.  */
286 #define DECL_FUNCTION_STUB(NODE) \
287   GET_DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (NODE))
288 #define SET_DECL_FUNCTION_STUB(NODE, X) \
289   SET_DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (NODE), X)
290
291 /* In a PARM_DECL, points to the alternate TREE_TYPE.  */
292 #define DECL_PARM_ALT_TYPE(NODE) \
293   GET_DECL_LANG_SPECIFIC (PARM_DECL_CHECK (NODE))
294 #define SET_DECL_PARM_ALT_TYPE(NODE, X) \
295   SET_DECL_LANG_SPECIFIC (PARM_DECL_CHECK (NODE), X)
296
297 /* In a FIELD_DECL corresponding to a discriminant, contains the
298    discriminant number.  */
299 #define DECL_DISCRIMINANT_NUMBER(NODE) DECL_INITIAL (FIELD_DECL_CHECK (NODE))
300
301 /* Define fields and macros for statements.  */
302 #define IS_ADA_STMT(NODE) \
303   (STATEMENT_CLASS_P (NODE) && TREE_CODE (NODE) >= STMT_STMT)
304
305 #define STMT_STMT_STMT(NODE)     TREE_OPERAND_CHECK_CODE (NODE, STMT_STMT, 0)
306 #define LOOP_STMT_TOP_COND(NODE) TREE_OPERAND_CHECK_CODE (NODE, LOOP_STMT, 0)
307 #define LOOP_STMT_BOT_COND(NODE) TREE_OPERAND_CHECK_CODE (NODE, LOOP_STMT, 1)
308 #define LOOP_STMT_UPDATE(NODE)   TREE_OPERAND_CHECK_CODE (NODE, LOOP_STMT, 2)
309 #define LOOP_STMT_BODY(NODE)     TREE_OPERAND_CHECK_CODE (NODE, LOOP_STMT, 3)
310 #define LOOP_STMT_LABEL(NODE)    TREE_OPERAND_CHECK_CODE (NODE, LOOP_STMT, 4)
311 #define EXIT_STMT_COND(NODE)     TREE_OPERAND_CHECK_CODE (NODE, EXIT_STMT, 0)
312 #define EXIT_STMT_LABEL(NODE)    TREE_OPERAND_CHECK_CODE (NODE, EXIT_STMT, 1)