sizetype is used. */
extern tree create_range_type (tree type, tree min, tree max);
-/* Return a TYPE_DECL node suitable for the TYPE_STUB_DECL field of a type.
- TYPE_NAME gives the name of the type and TYPE is a ..._TYPE node giving
- its data type. */
-extern tree create_type_stub_decl (tree type_name, tree type);
-
-/* Return a TYPE_DECL node. TYPE_NAME gives the name of the type and TYPE
- is a ..._TYPE node giving its data type. ARTIFICIAL_P is true if the
- declaration was generated by the compiler. DEBUG_INFO_P is true if we
- need to write debug information about this type. GNAT_NODE is used for
- the position of the decl. */
-extern tree create_type_decl (tree type_name, tree type, bool artificial_p,
+/* Return a TYPE_DECL node suitable for the TYPE_STUB_DECL field of TYPE.
+ NAME gives the name of the type to be used in the declaration. */
+extern tree create_type_stub_decl (tree name, tree type);
+
+/* Return a TYPE_DECL node for TYPE. NAME gives the name of the type to be
+ used in the declaration. ARTIFICIAL_P is true if the declaration was
+ generated by the compiler. DEBUG_INFO_P is true if we need to write
+ debug information about this type. GNAT_NODE is used for the position
+ of the decl. */
+extern tree create_type_decl (tree name, tree type, bool artificial_p,
bool debug_info_p, Node_Id gnat_node);
/* Return a VAR_DECL or CONST_DECL node.
- VAR_NAME gives the name of the variable. ASM_NAME is its assembler name
- (if provided). TYPE is its data type (a GCC ..._TYPE node). VAR_INIT is
+ NAME gives the name of the variable. ASM_NAME is its assembler name
+ (if provided). TYPE is its data type (a GCC ..._TYPE node). INIT is
the GCC tree for an optional initial expression; NULL_TREE if none.
CONST_FLAG is true if this variable is constant, in which case we might
DEBUG_INFO_P is true if we need to write debug information for it.
GNAT_NODE is used for the position of the decl. */
-extern tree
-create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init,
- bool const_flag, bool public_flag, bool extern_flag,
- bool static_flag, bool artificial_p, bool debug_info_p,
- bool const_decl_allowed_p, struct attrib *attr_list,
- Node_Id gnat_node);
-
-/* Wrapper around create_var_decl_1 for cases where we don't care whether
- a VAR or a CONST decl node is created. */
-#define create_var_decl(var_name, asm_name, type, var_init, \
- const_flag, public_flag, extern_flag, \
- static_flag, artificial_p, debug_info_p,\
- attr_list, gnat_node) \
- create_var_decl_1 (var_name, asm_name, type, var_init, \
- const_flag, public_flag, extern_flag, \
- static_flag, artificial_p, debug_info_p, \
- true, attr_list, gnat_node)
-
-/* Return a FIELD_DECL node. FIELD_NAME is the field's name, FIELD_TYPE is
- its type and RECORD_TYPE is the type of the enclosing record. If SIZE is
- nonzero, it is the specified size of the field. If POS is nonzero, it is
- the bit position. PACKED is 1 if the enclosing record is packed, -1 if it
- has Component_Alignment of Storage_Unit. If ADDRESSABLE is nonzero, it
+extern tree create_var_decl (tree name, tree asm_name, tree type, tree init,
+ bool const_flag, bool public_flag,
+ bool extern_flag, bool static_flag,
+ bool artificial_p, bool debug_info_p,
+ struct attrib *attr_list, Node_Id gnat_node,
+ bool const_decl_allowed_p = true);
+
+/* Return a FIELD_DECL node. NAME is the field's name, TYPE is its type and
+ RECORD_TYPE is the type of the enclosing record. If SIZE is nonzero, it
+ is the specified size of the field. If POS is nonzero, it is the bit
+ position. PACKED is 1 if the enclosing record is packed, -1 if it has
+ Component_Alignment of Storage_Unit. If ADDRESSABLE is nonzero, it
means we are allowed to take the address of the field; if it is negative,
we should not make a bitfield, which is used by make_aligning_type. */
-extern tree create_field_decl (tree field_name, tree field_type,
- tree record_type, tree size, tree pos,
- int packed, int addressable);
+extern tree create_field_decl (tree name, tree type, tree record_type,
+ tree size, tree pos, int packed,
+ int addressable);
-/* Return a PARM_DECL node. PARAM_NAME is the name of the parameter and
- PARAM_TYPE is its type. READONLY is true if the parameter is readonly
- (either an In parameter or an address of a pass-by-ref parameter). */
-extern tree create_param_decl (tree param_name, tree param_type,
- bool readonly);
+/* Return a PARM_DECL node. NAME is the name of the parameter and TYPE is
+ its type. READONLY is true if the parameter is readonly (either an In
+ parameter or an address of a pass-by-ref parameter). */
+extern tree create_param_decl (tree name, tree type, bool readonly);
-/* Return a LABEL_DECL with LABEL_NAME. GNAT_NODE is used for the position
- of the decl. */
-extern tree create_label_decl (tree label_name, Node_Id gnat_node);
+/* Return a LABEL_DECL with NAME. GNAT_NODE is used for the position of
+ the decl. */
+extern tree create_label_decl (tree name, Node_Id gnat_node);
-/* Return a FUNCTION_DECL node. SUBPROG_NAME is the name of the subprogram,
- ASM_NAME is its assembler name, SUBPROG_TYPE is its type (a FUNCTION_TYPE
- node), PARAM_DECL_LIST is the list of the subprogram arguments (a list of
- PARM_DECL nodes chained through the DECL_CHAIN field).
+/* Return a FUNCTION_DECL node. NAME is the name of the subprogram, ASM_NAME
+ its assembler name, TYPE its type (a FUNCTION_TYPE node), PARAM_DECL_LIST
+ the list of its parameters (a list of PARM_DECL nodes chained through the
+ DECL_CHAIN field).
INLINE_STATUS, PUBLIC_FLAG, EXTERN_FLAG and ATTR_LIST are used to set the
appropriate fields in the FUNCTION_DECL.
DEBUG_INFO_P is true if we need to write debug information for it.
GNAT_NODE is used for the position of the decl. */
-extern tree create_subprog_decl (tree subprog_name, tree asm_name,
- tree subprog_type, tree param_decl_list,
+extern tree create_subprog_decl (tree name, tree asm_name, tree type,
+ tree param_decl_list,
enum inline_status_t inline_status,
bool public_flag, bool extern_flag,
bool artificial_p, bool debug_info_p,
return range_type;
}
\f
-/* Return a TYPE_DECL node suitable for the TYPE_STUB_DECL field of a type.
- TYPE_NAME gives the name of the type and TYPE is a ..._TYPE node giving
- its data type. */
+/* Return a TYPE_DECL node suitable for the TYPE_STUB_DECL field of TYPE.
+ NAME gives the name of the type to be used in the declaration. */
tree
-create_type_stub_decl (tree type_name, tree type)
+create_type_stub_decl (tree name, tree type)
{
- tree type_decl = build_decl (input_location, TYPE_DECL, type_name, type);
+ tree type_decl = build_decl (input_location, TYPE_DECL, name, type);
DECL_ARTIFICIAL (type_decl) = 1;
TYPE_ARTIFICIAL (type) = 1;
return type_decl;
}
-/* Return a TYPE_DECL node. TYPE_NAME gives the name of the type and TYPE
- is a ..._TYPE node giving its data type. ARTIFICIAL_P is true if the
- declaration was generated by the compiler. DEBUG_INFO_P is true if we
- need to write debug information about this type. GNAT_NODE is used for
- the position of the decl. */
+/* Return a TYPE_DECL node for TYPE. NAME gives the name of the type to be
+ used in the declaration. ARTIFICIAL_P is true if the declaration was
+ generated by the compiler. DEBUG_INFO_P is true if we need to write
+ debug information about this type. GNAT_NODE is used for the position
+ of the decl. */
tree
-create_type_decl (tree type_name, tree type, bool artificial_p,
- bool debug_info_p, Node_Id gnat_node)
+create_type_decl (tree name, tree type, bool artificial_p, bool debug_info_p,
+ Node_Id gnat_node)
{
enum tree_code code = TREE_CODE (type);
- bool named = TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL;
+ bool is_named
+ = TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL;
tree type_decl;
/* Only the builtin TYPE_STUB_DECL should be used for dummy types. */
/* If the type hasn't been named yet, we're naming it; preserve an existing
TYPE_STUB_DECL that has been attached to it for some purpose. */
- if (!named && TYPE_STUB_DECL (type))
+ if (!is_named && TYPE_STUB_DECL (type))
{
type_decl = TYPE_STUB_DECL (type);
- DECL_NAME (type_decl) = type_name;
+ DECL_NAME (type_decl) = name;
}
else
- type_decl = build_decl (input_location, TYPE_DECL, type_name, type);
+ type_decl = build_decl (input_location, TYPE_DECL, name, type);
DECL_ARTIFICIAL (type_decl) = artificial_p;
TYPE_ARTIFICIAL (type) = artificial_p;
from multiple contexts, and "type_decl" references a copy of it: in such a
case, do not mess TYPE_STUB_DECL: we do not want to re-use the TYPE_DECL
with the mechanism above. */
- if (!named && type != DECL_ORIGINAL_TYPE (type_decl))
+ if (!is_named && type != DECL_ORIGINAL_TYPE (type_decl))
TYPE_STUB_DECL (type) = type_decl;
/* Do not generate debug info for UNCONSTRAINED_ARRAY_TYPE that the
\f
/* Return a VAR_DECL or CONST_DECL node.
- VAR_NAME gives the name of the variable. ASM_NAME is its assembler name
- (if provided). TYPE is its data type (a GCC ..._TYPE node). VAR_INIT is
+ NAME gives the name of the variable. ASM_NAME is its assembler name
+ (if provided). TYPE is its data type (a GCC ..._TYPE node). INIT is
the GCC tree for an optional initial expression; NULL_TREE if none.
CONST_FLAG is true if this variable is constant, in which case we might
GNAT_NODE is used for the position of the decl. */
tree
-create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init,
- bool const_flag, bool public_flag, bool extern_flag,
- bool static_flag, bool artificial_p, bool debug_info_p,
- bool const_decl_allowed_p, struct attrib *attr_list,
- Node_Id gnat_node)
+create_var_decl (tree name, tree asm_name, tree type, tree init,
+ bool const_flag, bool public_flag, bool extern_flag,
+ bool static_flag, bool artificial_p, bool debug_info_p,
+ struct attrib *attr_list, Node_Id gnat_node,
+ bool const_decl_allowed_p)
{
/* Whether the object has static storage duration, either explicitly or by
virtue of being declared at the global level. */
constant expression for initializing a static variable; otherwise, we
only check that it is constant. */
const bool init_const
- = (var_init
- && gnat_types_compatible_p (type, TREE_TYPE (var_init))
+ = (init
+ && gnat_types_compatible_p (type, TREE_TYPE (init))
&& (extern_flag || static_storage
- ? initializer_constant_valid_p (var_init, TREE_TYPE (var_init))
+ ? initializer_constant_valid_p (init, TREE_TYPE (init))
!= NULL_TREE
- : TREE_CONSTANT (var_init)));
+ : TREE_CONSTANT (init)));
/* Whether we will make TREE_CONSTANT the DECL we produce here, in which
case the initializer may be used in lieu of the DECL node (as done in
= build_decl (input_location,
(constant_p && const_decl_allowed_p
&& !AGGREGATE_TYPE_P (type)) ? CONST_DECL : VAR_DECL,
- var_name, type);
+ name, type);
/* If this is external, throw away any initializations (they will be done
elsewhere) unless this is a constant for which we would like to remain
elaboration routine. If we are just annotating types, throw away the
initialization if it isn't a constant. */
if ((extern_flag && !constant_p)
- || (type_annotate_only && var_init && !TREE_CONSTANT (var_init)))
- var_init = NULL_TREE;
+ || (type_annotate_only && init && !TREE_CONSTANT (init)))
+ init = NULL_TREE;
/* At the global level, a non-constant initializer generates elaboration
statements. Check that such statements are allowed, that is to say,
not violating a No_Elaboration_Code restriction. */
- if (var_init && !init_const && global_bindings_p ())
+ if (init && !init_const && global_bindings_p ())
Check_Elaboration_Code_Allowed (gnat_node);
/* Attach the initializer, if any. */
- DECL_INITIAL (var_decl) = var_init;
+ DECL_INITIAL (var_decl) = init;
/* Directly set some flags. */
DECL_ARTIFICIAL (var_decl) = artificial_p;
|| (TREE_CODE (var_decl) == CONST_DECL && !optimize)
|| (extern_flag
&& constant_p
- && var_init
- && initializer_constant_valid_p (var_init, TREE_TYPE (var_init))
+ && init
+ && initializer_constant_valid_p (init, TREE_TYPE (init))
!= null_pointer_node))
DECL_IGNORED_P (var_decl) = 1;
}
}
-/* Return a FIELD_DECL node. FIELD_NAME is the field's name, FIELD_TYPE is
- its type and RECORD_TYPE is the type of the enclosing record. If SIZE is
- nonzero, it is the specified size of the field. If POS is nonzero, it is
- the bit position. PACKED is 1 if the enclosing record is packed, -1 if it
- has Component_Alignment of Storage_Unit. If ADDRESSABLE is nonzero, it
+/* Return a FIELD_DECL node. NAME is the field's name, TYPE is its type and
+ RECORD_TYPE is the type of the enclosing record. If SIZE is nonzero, it
+ is the specified size of the field. If POS is nonzero, it is the bit
+ position. PACKED is 1 if the enclosing record is packed, -1 if it has
+ Component_Alignment of Storage_Unit. If ADDRESSABLE is nonzero, it
means we are allowed to take the address of the field; if it is negative,
we should not make a bitfield, which is used by make_aligning_type. */
tree
-create_field_decl (tree field_name, tree field_type, tree record_type,
- tree size, tree pos, int packed, int addressable)
+create_field_decl (tree name, tree type, tree record_type, tree size, tree pos,
+ int packed, int addressable)
{
- tree field_decl = build_decl (input_location,
- FIELD_DECL, field_name, field_type);
+ tree field_decl = build_decl (input_location, FIELD_DECL, name, type);
DECL_CONTEXT (field_decl) = record_type;
- TREE_READONLY (field_decl) = TYPE_READONLY (field_type);
+ TREE_READONLY (field_decl) = TYPE_READONLY (type);
/* If FIELD_TYPE is BLKmode, we must ensure this is aligned to at least a
byte boundary since GCC cannot handle less-aligned BLKmode bitfields.
array, because in this case slices of variable length of this array
must be handled by GCC and variable-sized objects need to be aligned
to at least a byte boundary. */
- if (packed && (TYPE_MODE (field_type) == BLKmode
+ if (packed && (TYPE_MODE (type) == BLKmode
|| (!pos
- && AGGREGATE_TYPE_P (field_type)
- && aggregate_type_contains_array_p (field_type))))
+ && AGGREGATE_TYPE_P (type)
+ && aggregate_type_contains_array_p (type))))
DECL_ALIGN (field_decl) = BITS_PER_UNIT;
/* If a size is specified, use it. Otherwise, if the record type is packed
size = convert (bitsizetype, size);
else if (packed == 1)
{
- size = rm_size (field_type);
- if (TYPE_MODE (field_type) == BLKmode)
+ size = rm_size (type);
+ if (TYPE_MODE (type) == BLKmode)
size = round_up (size, BITS_PER_UNIT);
}
if (addressable >= 0
&& size
&& TREE_CODE (size) == INTEGER_CST
- && TREE_CODE (TYPE_SIZE (field_type)) == INTEGER_CST
- && (!tree_int_cst_equal (size, TYPE_SIZE (field_type))
- || (pos && !value_factor_p (pos, TYPE_ALIGN (field_type)))
+ && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
+ && (!tree_int_cst_equal (size, TYPE_SIZE (type))
+ || (pos && !value_factor_p (pos, TYPE_ALIGN (type)))
|| packed
|| (TYPE_ALIGN (record_type) != 0
- && TYPE_ALIGN (record_type) < TYPE_ALIGN (field_type))))
+ && TYPE_ALIGN (record_type) < TYPE_ALIGN (type))))
{
DECL_BIT_FIELD (field_decl) = 1;
DECL_SIZE (field_decl) = size;
if (!packed && !pos)
{
if (TYPE_ALIGN (record_type) != 0
- && TYPE_ALIGN (record_type) < TYPE_ALIGN (field_type))
+ && TYPE_ALIGN (record_type) < TYPE_ALIGN (type))
DECL_ALIGN (field_decl) = TYPE_ALIGN (record_type);
else
- DECL_ALIGN (field_decl) = TYPE_ALIGN (field_type);
+ DECL_ALIGN (field_decl) = TYPE_ALIGN (type);
}
}
{
unsigned int bit_align
= (DECL_BIT_FIELD (field_decl) ? 1
- : packed && TYPE_MODE (field_type) != BLKmode ? BITS_PER_UNIT : 0);
+ : packed && TYPE_MODE (type) != BLKmode ? BITS_PER_UNIT : 0);
if (bit_align > DECL_ALIGN (field_decl))
DECL_ALIGN (field_decl) = bit_align;
- else if (!bit_align && TYPE_ALIGN (field_type) > DECL_ALIGN (field_decl))
+ else if (!bit_align && TYPE_ALIGN (type) > DECL_ALIGN (field_decl))
{
- DECL_ALIGN (field_decl) = TYPE_ALIGN (field_type);
- DECL_USER_ALIGN (field_decl) = TYPE_USER_ALIGN (field_type);
+ DECL_ALIGN (field_decl) = TYPE_ALIGN (type);
+ DECL_USER_ALIGN (field_decl) = TYPE_USER_ALIGN (type);
}
}
of a copy. This is the case for true bitfields, but the DECL_BIT_FIELD
value we have at this point is not accurate enough, so we don't account
for this here and let finish_record_type decide. */
- if (!addressable && !type_for_nonaliased_component_p (field_type))
+ if (!addressable && !type_for_nonaliased_component_p (type))
addressable = 1;
DECL_NONADDRESSABLE_P (field_decl) = !addressable;
return field_decl;
}
\f
-/* Return a PARM_DECL node. PARAM_NAME is the name of the parameter and
- PARAM_TYPE is its type. READONLY is true if the parameter is readonly
- (either an In parameter or an address of a pass-by-ref parameter). */
+/* Return a PARM_DECL node. NAME is the name of the parameter and TYPE is
+ its type. READONLY is true if the parameter is readonly (either an In
+ parameter or an address of a pass-by-ref parameter). */
tree
-create_param_decl (tree param_name, tree param_type, bool readonly)
+create_param_decl (tree name, tree type, bool readonly)
{
- tree param_decl = build_decl (input_location,
- PARM_DECL, param_name, param_type);
+ tree param_decl = build_decl (input_location, PARM_DECL, name, type);
/* Honor TARGET_PROMOTE_PROTOTYPES like the C compiler, as not doing so
can lead to various ABI violations. */
if (targetm.calls.promote_prototypes (NULL_TREE)
- && INTEGRAL_TYPE_P (param_type)
- && TYPE_PRECISION (param_type) < TYPE_PRECISION (integer_type_node))
+ && INTEGRAL_TYPE_P (type)
+ && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
{
/* We have to be careful about biased types here. Make a subtype
of integer_type_node with the proper biasing. */
- if (TREE_CODE (param_type) == INTEGER_TYPE
- && TYPE_BIASED_REPRESENTATION_P (param_type))
+ if (TREE_CODE (type) == INTEGER_TYPE
+ && TYPE_BIASED_REPRESENTATION_P (type))
{
tree subtype
= make_unsigned_type (TYPE_PRECISION (integer_type_node));
TREE_TYPE (subtype) = integer_type_node;
TYPE_BIASED_REPRESENTATION_P (subtype) = 1;
- SET_TYPE_RM_MIN_VALUE (subtype, TYPE_MIN_VALUE (param_type));
- SET_TYPE_RM_MAX_VALUE (subtype, TYPE_MAX_VALUE (param_type));
- param_type = subtype;
+ SET_TYPE_RM_MIN_VALUE (subtype, TYPE_MIN_VALUE (type));
+ SET_TYPE_RM_MAX_VALUE (subtype, TYPE_MAX_VALUE (type));
+ type = subtype;
}
else
- param_type = integer_type_node;
+ type = integer_type_node;
}
- DECL_ARG_TYPE (param_decl) = param_type;
+ DECL_ARG_TYPE (param_decl) = type;
TREE_READONLY (param_decl) = readonly;
return param_decl;
}
return true;
}
-/* Return a LABEL_DECL with LABEL_NAME. GNAT_NODE is used for the position
- of the decl. */
+/* Return a LABEL_DECL with NAME. GNAT_NODE is used for the position of
+ the decl. */
tree
-create_label_decl (tree label_name, Node_Id gnat_node)
+create_label_decl (tree name, Node_Id gnat_node)
{
tree label_decl
- = build_decl (input_location, LABEL_DECL, label_name, void_type_node);
+ = build_decl (input_location, LABEL_DECL, name, void_type_node);
DECL_MODE (label_decl) = VOIDmode;
return label_decl;
}
\f
-/* Return a FUNCTION_DECL node. SUBPROG_NAME is the name of the subprogram,
- ASM_NAME is its assembler name, SUBPROG_TYPE is its type (a FUNCTION_TYPE
- node), PARAM_DECL_LIST is the list of the subprogram arguments (a list of
- PARM_DECL nodes chained through the DECL_CHAIN field).
+/* Return a FUNCTION_DECL node. NAME is the name of the subprogram, ASM_NAME
+ its assembler name, TYPE its type (a FUNCTION_TYPE node), PARAM_DECL_LIST
+ the list of its parameters (a list of PARM_DECL nodes chained through the
+ DECL_CHAIN field).
INLINE_STATUS, PUBLIC_FLAG, EXTERN_FLAG and ATTR_LIST are used to set the
appropriate fields in the FUNCTION_DECL.
GNAT_NODE is used for the position of the decl. */
tree
-create_subprog_decl (tree subprog_name, tree asm_name, tree subprog_type,
- tree param_decl_list, enum inline_status_t inline_status,
- bool public_flag, bool extern_flag, bool artificial_p,
- bool debug_info_p, struct attrib *attr_list,
- Node_Id gnat_node)
+create_subprog_decl (tree name, tree asm_name, tree type, tree param_decl_list,
+ enum inline_status_t inline_status, bool public_flag,
+ bool extern_flag, bool artificial_p, bool debug_info_p,
+ struct attrib *attr_list, Node_Id gnat_node)
{
- tree subprog_decl = build_decl (input_location, FUNCTION_DECL, subprog_name,
- subprog_type);
- tree result_decl = build_decl (input_location, RESULT_DECL, NULL_TREE,
- TREE_TYPE (subprog_type));
+ tree subprog_decl = build_decl (input_location, FUNCTION_DECL, name, type);
+ tree result_decl
+ = build_decl (input_location, RESULT_DECL, NULL_TREE, TREE_TYPE (type));
DECL_ARGUMENTS (subprog_decl) = param_decl_list;
DECL_ARTIFICIAL (subprog_decl) = artificial_p;
DECL_IGNORED_P (subprog_decl) = 1;
TREE_PUBLIC (subprog_decl) = public_flag;
- TREE_READONLY (subprog_decl) = TYPE_READONLY (subprog_type);
- TREE_THIS_VOLATILE (subprog_decl) = TYPE_VOLATILE (subprog_type);
- TREE_SIDE_EFFECTS (subprog_decl) = TYPE_VOLATILE (subprog_type);
+ TREE_READONLY (subprog_decl) = TYPE_READONLY (type);
+ TREE_THIS_VOLATILE (subprog_decl) = TYPE_VOLATILE (type);
+ TREE_SIDE_EFFECTS (subprog_decl) = TYPE_VOLATILE (type);
DECL_ARTIFICIAL (result_decl) = 1;
DECL_IGNORED_P (result_decl) = 1;
- DECL_BY_REFERENCE (result_decl) = TREE_ADDRESSABLE (subprog_type);
+ DECL_BY_REFERENCE (result_decl) = TREE_ADDRESSABLE (type);
DECL_RESULT (subprog_decl) = result_decl;
process_attributes (&subprog_decl, &attr_list, true, gnat_node);