Commit 6249559b by Eric Botcazou Committed by Eric Botcazou

gigi.h (create_var_decl_1): Rename into...

	* gcc-interface/gigi.h (create_var_decl_1): Rename into...
	(create_var_decl): ...this.  Add default value for last parameter.
	(create_type_stub_decl): Adjust.
	(create_type_decl): Likewise.
	(create_field_decl): Likewise.
	(create_param_decl): Likewise.
	(create_label_decl): Likewise.
	(create_subprog_decl): Likewise.
	* gcc-interface/utils.c (create_var_decl_1): Rename into...
	(create_var_decl): ...this.  Rename var_name into name and var_init
	into init, move const_decl_allowed_p last and adjust accordingly.
	(create_type_stub_decl): Rename type_name into name and adjust.
	(create_type_decl): Likewise.
	(create_field_decl): Likewise for field_name and field_type.
	(create_param_decl): Likewise for param_name and param_type.
	(create_label_decl): Likewise for label_name.
	(create_subprog_decl): Likewise for subprog_name and subprog_type.
	* gcc-interface/decl.c (gnat_to_gnu_entity): Adjust couple of calls
	to create_var_decl_1.

From-SVN: r225002
parent 66cc6273
2015-06-26 Eric Botcazou <ebotcazou@adacore.com> 2015-06-26 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/gigi.h (create_var_decl_1): Rename into...
(create_var_decl): ...this. Add default value for last parameter.
(create_type_stub_decl): Adjust.
(create_type_decl): Likewise.
(create_field_decl): Likewise.
(create_param_decl): Likewise.
(create_label_decl): Likewise.
(create_subprog_decl): Likewise.
* gcc-interface/utils.c (create_var_decl_1): Rename into...
(create_var_decl): ...this. Rename var_name into name and var_init
into init, move const_decl_allowed_p last and adjust accordingly.
(create_type_stub_decl): Rename type_name into name and adjust.
(create_type_decl): Likewise.
(create_field_decl): Likewise for field_name and field_type.
(create_param_decl): Likewise for param_name and param_type.
(create_label_decl): Likewise for label_name.
(create_subprog_decl): Likewise for subprog_name and subprog_type.
* gcc-interface/decl.c (gnat_to_gnu_entity): Adjust couple of calls
to create_var_decl_1.
2015-06-26 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/trans.c (loop_info_d): Add low_bound, high_bound, * gcc-interface/trans.c (loop_info_d): Add low_bound, high_bound,
artificial, has_checks and warned_aggressive_loop_optimizations. artificial, has_checks and warned_aggressive_loop_optimizations.
(gigi): Set warn_aggressive_loop_optimizations to 0. (gigi): Set warn_aggressive_loop_optimizations to 0.
......
...@@ -1444,11 +1444,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -1444,11 +1444,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
/* Now create the variable or the constant and set various flags. */ /* Now create the variable or the constant and set various flags. */
gnu_decl gnu_decl
= create_var_decl_1 (gnu_entity_name, gnu_ext_name, gnu_type, = create_var_decl (gnu_entity_name, gnu_ext_name, gnu_type,
gnu_expr, const_flag, Is_Public (gnat_entity), gnu_expr, const_flag, Is_Public (gnat_entity),
imported_p || !definition, static_p, imported_p || !definition, static_p,
artificial_p, debug_info_p, !renamed_obj, artificial_p, debug_info_p, attr_list,
attr_list, gnat_entity); gnat_entity, !renamed_obj);
DECL_BY_REF_P (gnu_decl) = used_by_ref; DECL_BY_REF_P (gnu_decl) = used_by_ref;
DECL_POINTS_TO_READONLY_P (gnu_decl) = used_by_ref && inner_const_flag; DECL_POINTS_TO_READONLY_P (gnu_decl) = used_by_ref && inner_const_flag;
DECL_CAN_NEVER_BE_NULL_P (gnu_decl) = Can_Never_Be_Null (gnat_entity); DECL_CAN_NEVER_BE_NULL_P (gnu_decl) = Can_Never_Be_Null (gnat_entity);
...@@ -1497,11 +1497,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -1497,11 +1497,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
|| Is_Aliased (Etype (gnat_entity)))) || Is_Aliased (Etype (gnat_entity))))
{ {
tree gnu_corr_var tree gnu_corr_var
= create_var_decl_1 (gnu_entity_name, gnu_ext_name, gnu_type, = create_var_decl (gnu_entity_name, gnu_ext_name, gnu_type,
gnu_expr, true, Is_Public (gnat_entity), gnu_expr, true, Is_Public (gnat_entity),
!definition, static_p, artificial_p, !definition, static_p, artificial_p,
debug_info_p, false, attr_list, debug_info_p, attr_list, gnat_entity,
gnat_entity); false);
SET_DECL_CONST_CORRESPONDING_VAR (gnu_decl, gnu_corr_var); SET_DECL_CONST_CORRESPONDING_VAR (gnu_decl, gnu_corr_var);
} }
......
...@@ -654,23 +654,22 @@ extern tree create_index_type (tree min, tree max, tree index, ...@@ -654,23 +654,22 @@ extern tree create_index_type (tree min, tree max, tree index,
sizetype is used. */ sizetype is used. */
extern tree create_range_type (tree type, tree min, tree max); 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. /* Return a TYPE_DECL node suitable for the TYPE_STUB_DECL field of TYPE.
TYPE_NAME gives the name of the type and TYPE is a ..._TYPE node giving NAME gives the name of the type to be used in the declaration. */
its data type. */ extern tree create_type_stub_decl (tree name, tree type);
extern tree create_type_stub_decl (tree type_name, tree type);
/* Return a TYPE_DECL node for TYPE. NAME gives the name of the type to be
/* Return a TYPE_DECL node. TYPE_NAME gives the name of the type and TYPE used in the declaration. ARTIFICIAL_P is true if the declaration was
is a ..._TYPE node giving its data type. ARTIFICIAL_P is true if the generated by the compiler. DEBUG_INFO_P is true if we need to write
declaration was generated by the compiler. DEBUG_INFO_P is true if we debug information about this type. GNAT_NODE is used for the position
need to write debug information about this type. GNAT_NODE is used for of the decl. */
the position of the decl. */ extern tree create_type_decl (tree name, tree type, bool artificial_p,
extern tree create_type_decl (tree type_name, tree type, bool artificial_p,
bool debug_info_p, Node_Id gnat_node); bool debug_info_p, Node_Id gnat_node);
/* Return a VAR_DECL or CONST_DECL node. /* Return a VAR_DECL or CONST_DECL node.
VAR_NAME gives the name of the variable. ASM_NAME is its assembler name 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 (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. 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 CONST_FLAG is true if this variable is constant, in which case we might
...@@ -691,49 +690,37 @@ extern tree create_type_decl (tree type_name, tree type, bool artificial_p, ...@@ -691,49 +690,37 @@ extern tree create_type_decl (tree type_name, tree type, bool artificial_p,
DEBUG_INFO_P is true if we need to write debug information for it. DEBUG_INFO_P is true if we need to write debug information for it.
GNAT_NODE is used for the position of the decl. */ GNAT_NODE is used for the position of the decl. */
extern tree extern tree create_var_decl (tree name, tree asm_name, tree type, tree init,
create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init, bool const_flag, bool public_flag,
bool const_flag, bool public_flag, bool extern_flag, bool extern_flag, bool static_flag,
bool static_flag, bool artificial_p, bool debug_info_p, bool artificial_p, bool debug_info_p,
bool const_decl_allowed_p, struct attrib *attr_list, struct attrib *attr_list, Node_Id gnat_node,
Node_Id gnat_node); bool const_decl_allowed_p = true);
/* Wrapper around create_var_decl_1 for cases where we don't care whether /* Return a FIELD_DECL node. NAME is the field's name, TYPE is its type and
a VAR or a CONST decl node is created. */ RECORD_TYPE is the type of the enclosing record. If SIZE is nonzero, it
#define create_var_decl(var_name, asm_name, type, var_init, \ is the specified size of the field. If POS is nonzero, it is the bit
const_flag, public_flag, extern_flag, \ position. PACKED is 1 if the enclosing record is packed, -1 if it has
static_flag, artificial_p, debug_info_p,\ Component_Alignment of Storage_Unit. If ADDRESSABLE is nonzero, it
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
means we are allowed to take the address of the field; if it is negative, 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. */ we should not make a bitfield, which is used by make_aligning_type. */
extern tree create_field_decl (tree field_name, tree field_type, extern tree create_field_decl (tree name, tree type, tree record_type,
tree record_type, tree size, tree pos, tree size, tree pos, int packed,
int packed, int addressable); int addressable);
/* Return a PARM_DECL node. PARAM_NAME is the name of the parameter and /* Return a PARM_DECL node. NAME is the name of the parameter and TYPE is
PARAM_TYPE is its type. READONLY is true if the parameter is readonly its type. READONLY is true if the parameter is readonly (either an In
(either an In parameter or an address of a pass-by-ref parameter). */ parameter or an address of a pass-by-ref parameter). */
extern tree create_param_decl (tree param_name, tree param_type, extern tree create_param_decl (tree name, tree type, bool readonly);
bool readonly);
/* Return a LABEL_DECL with LABEL_NAME. GNAT_NODE is used for the position /* Return a LABEL_DECL with NAME. GNAT_NODE is used for the position of
of the decl. */ the decl. */
extern tree create_label_decl (tree label_name, Node_Id gnat_node); extern tree create_label_decl (tree name, Node_Id gnat_node);
/* Return a FUNCTION_DECL node. SUBPROG_NAME is the name of the subprogram, /* Return a FUNCTION_DECL node. NAME is the name of the subprogram, ASM_NAME
ASM_NAME is its assembler name, SUBPROG_TYPE is its type (a FUNCTION_TYPE its assembler name, TYPE its type (a FUNCTION_TYPE node), PARAM_DECL_LIST
node), PARAM_DECL_LIST is the list of the subprogram arguments (a list of the list of its parameters (a list of PARM_DECL nodes chained through the
PARM_DECL nodes chained through the DECL_CHAIN field). DECL_CHAIN field).
INLINE_STATUS, PUBLIC_FLAG, EXTERN_FLAG and ATTR_LIST are used to set the INLINE_STATUS, PUBLIC_FLAG, EXTERN_FLAG and ATTR_LIST are used to set the
appropriate fields in the FUNCTION_DECL. appropriate fields in the FUNCTION_DECL.
...@@ -743,8 +730,8 @@ extern tree create_label_decl (tree label_name, Node_Id gnat_node); ...@@ -743,8 +730,8 @@ extern tree create_label_decl (tree label_name, Node_Id gnat_node);
DEBUG_INFO_P is true if we need to write debug information for it. DEBUG_INFO_P is true if we need to write debug information for it.
GNAT_NODE is used for the position of the decl. */ GNAT_NODE is used for the position of the decl. */
extern tree create_subprog_decl (tree subprog_name, tree asm_name, extern tree create_subprog_decl (tree name, tree asm_name, tree type,
tree subprog_type, tree param_decl_list, tree param_decl_list,
enum inline_status_t inline_status, enum inline_status_t inline_status,
bool public_flag, bool extern_flag, bool public_flag, bool extern_flag,
bool artificial_p, bool debug_info_p, bool artificial_p, bool debug_info_p,
......
...@@ -2238,31 +2238,31 @@ create_range_type (tree type, tree min, tree max) ...@@ -2238,31 +2238,31 @@ create_range_type (tree type, tree min, tree max)
return range_type; return range_type;
} }
/* Return a TYPE_DECL node suitable for the TYPE_STUB_DECL field of a type. /* Return a TYPE_DECL node suitable for the TYPE_STUB_DECL field of TYPE.
TYPE_NAME gives the name of the type and TYPE is a ..._TYPE node giving NAME gives the name of the type to be used in the declaration. */
its data type. */
tree 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; DECL_ARTIFICIAL (type_decl) = 1;
TYPE_ARTIFICIAL (type) = 1; TYPE_ARTIFICIAL (type) = 1;
return type_decl; return type_decl;
} }
/* Return a TYPE_DECL node. TYPE_NAME gives the name of the type and TYPE /* Return a TYPE_DECL node for TYPE. NAME gives the name of the type to be
is a ..._TYPE node giving its data type. ARTIFICIAL_P is true if the used in the declaration. ARTIFICIAL_P is true if the declaration was
declaration was generated by the compiler. DEBUG_INFO_P is true if we generated by the compiler. DEBUG_INFO_P is true if we need to write
need to write debug information about this type. GNAT_NODE is used for debug information about this type. GNAT_NODE is used for the position
the position of the decl. */ of the decl. */
tree tree
create_type_decl (tree type_name, tree type, bool artificial_p, create_type_decl (tree name, tree type, bool artificial_p, bool debug_info_p,
bool debug_info_p, Node_Id gnat_node) Node_Id gnat_node)
{ {
enum tree_code code = TREE_CODE (type); 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; tree type_decl;
/* Only the builtin TYPE_STUB_DECL should be used for dummy types. */ /* Only the builtin TYPE_STUB_DECL should be used for dummy types. */
...@@ -2270,13 +2270,13 @@ create_type_decl (tree type_name, tree type, bool artificial_p, ...@@ -2270,13 +2270,13 @@ create_type_decl (tree type_name, tree type, bool artificial_p,
/* If the type hasn't been named yet, we're naming it; preserve an existing /* 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. */ 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); type_decl = TYPE_STUB_DECL (type);
DECL_NAME (type_decl) = type_name; DECL_NAME (type_decl) = name;
} }
else 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; DECL_ARTIFICIAL (type_decl) = artificial_p;
TYPE_ARTIFICIAL (type) = artificial_p; TYPE_ARTIFICIAL (type) = artificial_p;
...@@ -2293,7 +2293,7 @@ create_type_decl (tree type_name, tree type, bool artificial_p, ...@@ -2293,7 +2293,7 @@ create_type_decl (tree type_name, tree type, bool artificial_p,
from multiple contexts, and "type_decl" references a copy of it: in such a 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 case, do not mess TYPE_STUB_DECL: we do not want to re-use the TYPE_DECL
with the mechanism above. */ 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; TYPE_STUB_DECL (type) = type_decl;
/* Do not generate debug info for UNCONSTRAINED_ARRAY_TYPE that the /* Do not generate debug info for UNCONSTRAINED_ARRAY_TYPE that the
...@@ -2306,8 +2306,8 @@ create_type_decl (tree type_name, tree type, bool artificial_p, ...@@ -2306,8 +2306,8 @@ create_type_decl (tree type_name, tree type, bool artificial_p,
/* Return a VAR_DECL or CONST_DECL node. /* Return a VAR_DECL or CONST_DECL node.
VAR_NAME gives the name of the variable. ASM_NAME is its assembler name 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 (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. 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 CONST_FLAG is true if this variable is constant, in which case we might
...@@ -2330,11 +2330,11 @@ create_type_decl (tree type_name, tree type, bool artificial_p, ...@@ -2330,11 +2330,11 @@ create_type_decl (tree type_name, tree type, bool artificial_p,
GNAT_NODE is used for the position of the decl. */ GNAT_NODE is used for the position of the decl. */
tree tree
create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init, create_var_decl (tree name, tree asm_name, tree type, tree init,
bool const_flag, bool public_flag, bool extern_flag, bool const_flag, bool public_flag, bool extern_flag,
bool static_flag, bool artificial_p, bool debug_info_p, bool static_flag, bool artificial_p, bool debug_info_p,
bool const_decl_allowed_p, struct attrib *attr_list, struct attrib *attr_list, Node_Id gnat_node,
Node_Id gnat_node) bool const_decl_allowed_p)
{ {
/* Whether the object has static storage duration, either explicitly or by /* Whether the object has static storage duration, either explicitly or by
virtue of being declared at the global level. */ virtue of being declared at the global level. */
...@@ -2345,12 +2345,12 @@ create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init, ...@@ -2345,12 +2345,12 @@ create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init,
constant expression for initializing a static variable; otherwise, we constant expression for initializing a static variable; otherwise, we
only check that it is constant. */ only check that it is constant. */
const bool init_const const bool init_const
= (var_init = (init
&& gnat_types_compatible_p (type, TREE_TYPE (var_init)) && gnat_types_compatible_p (type, TREE_TYPE (init))
&& (extern_flag || static_storage && (extern_flag || static_storage
? initializer_constant_valid_p (var_init, TREE_TYPE (var_init)) ? initializer_constant_valid_p (init, TREE_TYPE (init))
!= NULL_TREE != NULL_TREE
: TREE_CONSTANT (var_init))); : TREE_CONSTANT (init)));
/* Whether we will make TREE_CONSTANT the DECL we produce here, in which /* 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 case the initializer may be used in lieu of the DECL node (as done in
...@@ -2367,7 +2367,7 @@ create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init, ...@@ -2367,7 +2367,7 @@ create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init,
= build_decl (input_location, = build_decl (input_location,
(constant_p && const_decl_allowed_p (constant_p && const_decl_allowed_p
&& !AGGREGATE_TYPE_P (type)) ? CONST_DECL : VAR_DECL, && !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 /* 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 elsewhere) unless this is a constant for which we would like to remain
...@@ -2376,17 +2376,17 @@ create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init, ...@@ -2376,17 +2376,17 @@ create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init,
elaboration routine. If we are just annotating types, throw away the elaboration routine. If we are just annotating types, throw away the
initialization if it isn't a constant. */ initialization if it isn't a constant. */
if ((extern_flag && !constant_p) if ((extern_flag && !constant_p)
|| (type_annotate_only && var_init && !TREE_CONSTANT (var_init))) || (type_annotate_only && init && !TREE_CONSTANT (init)))
var_init = NULL_TREE; init = NULL_TREE;
/* At the global level, a non-constant initializer generates elaboration /* At the global level, a non-constant initializer generates elaboration
statements. Check that such statements are allowed, that is to say, statements. Check that such statements are allowed, that is to say,
not violating a No_Elaboration_Code restriction. */ 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); Check_Elaboration_Code_Allowed (gnat_node);
/* Attach the initializer, if any. */ /* Attach the initializer, if any. */
DECL_INITIAL (var_decl) = var_init; DECL_INITIAL (var_decl) = init;
/* Directly set some flags. */ /* Directly set some flags. */
DECL_ARTIFICIAL (var_decl) = artificial_p; DECL_ARTIFICIAL (var_decl) = artificial_p;
...@@ -2421,8 +2421,8 @@ create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init, ...@@ -2421,8 +2421,8 @@ create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init,
|| (TREE_CODE (var_decl) == CONST_DECL && !optimize) || (TREE_CODE (var_decl) == CONST_DECL && !optimize)
|| (extern_flag || (extern_flag
&& constant_p && constant_p
&& var_init && init
&& initializer_constant_valid_p (var_init, TREE_TYPE (var_init)) && initializer_constant_valid_p (init, TREE_TYPE (init))
!= null_pointer_node)) != null_pointer_node))
DECL_IGNORED_P (var_decl) = 1; DECL_IGNORED_P (var_decl) = 1;
...@@ -2484,23 +2484,22 @@ aggregate_type_contains_array_p (tree type) ...@@ -2484,23 +2484,22 @@ aggregate_type_contains_array_p (tree type)
} }
} }
/* Return a FIELD_DECL node. FIELD_NAME is the field's name, FIELD_TYPE is /* Return a FIELD_DECL node. NAME is the field's name, TYPE is its type and
its type and RECORD_TYPE is the type of the enclosing record. If SIZE is RECORD_TYPE is the type of the enclosing record. If SIZE is nonzero, it
nonzero, it is the specified size of the field. If POS is nonzero, it is is the specified size of the field. If POS is nonzero, it is the bit
the bit position. PACKED is 1 if the enclosing record is packed, -1 if it position. PACKED is 1 if the enclosing record is packed, -1 if it has
has Component_Alignment of Storage_Unit. If ADDRESSABLE is nonzero, it 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, 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. */ we should not make a bitfield, which is used by make_aligning_type. */
tree tree
create_field_decl (tree field_name, tree field_type, tree record_type, create_field_decl (tree name, tree type, tree record_type, tree size, tree pos,
tree size, tree pos, int packed, int addressable) int packed, int addressable)
{ {
tree field_decl = build_decl (input_location, tree field_decl = build_decl (input_location, FIELD_DECL, name, type);
FIELD_DECL, field_name, field_type);
DECL_CONTEXT (field_decl) = record_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 /* 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. byte boundary since GCC cannot handle less-aligned BLKmode bitfields.
...@@ -2508,10 +2507,10 @@ create_field_decl (tree field_name, tree field_type, tree record_type, ...@@ -2508,10 +2507,10 @@ create_field_decl (tree field_name, tree field_type, tree record_type,
array, because in this case slices of variable length of this array 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 must be handled by GCC and variable-sized objects need to be aligned
to at least a byte boundary. */ to at least a byte boundary. */
if (packed && (TYPE_MODE (field_type) == BLKmode if (packed && (TYPE_MODE (type) == BLKmode
|| (!pos || (!pos
&& AGGREGATE_TYPE_P (field_type) && AGGREGATE_TYPE_P (type)
&& aggregate_type_contains_array_p (field_type)))) && aggregate_type_contains_array_p (type))))
DECL_ALIGN (field_decl) = BITS_PER_UNIT; DECL_ALIGN (field_decl) = BITS_PER_UNIT;
/* If a size is specified, use it. Otherwise, if the record type is packed /* If a size is specified, use it. Otherwise, if the record type is packed
...@@ -2523,8 +2522,8 @@ create_field_decl (tree field_name, tree field_type, tree record_type, ...@@ -2523,8 +2522,8 @@ create_field_decl (tree field_name, tree field_type, tree record_type,
size = convert (bitsizetype, size); size = convert (bitsizetype, size);
else if (packed == 1) else if (packed == 1)
{ {
size = rm_size (field_type); size = rm_size (type);
if (TYPE_MODE (field_type) == BLKmode) if (TYPE_MODE (type) == BLKmode)
size = round_up (size, BITS_PER_UNIT); size = round_up (size, BITS_PER_UNIT);
} }
...@@ -2546,22 +2545,22 @@ create_field_decl (tree field_name, tree field_type, tree record_type, ...@@ -2546,22 +2545,22 @@ create_field_decl (tree field_name, tree field_type, tree record_type,
if (addressable >= 0 if (addressable >= 0
&& size && size
&& TREE_CODE (size) == INTEGER_CST && TREE_CODE (size) == INTEGER_CST
&& TREE_CODE (TYPE_SIZE (field_type)) == INTEGER_CST && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
&& (!tree_int_cst_equal (size, TYPE_SIZE (field_type)) && (!tree_int_cst_equal (size, TYPE_SIZE (type))
|| (pos && !value_factor_p (pos, TYPE_ALIGN (field_type))) || (pos && !value_factor_p (pos, TYPE_ALIGN (type)))
|| packed || packed
|| (TYPE_ALIGN (record_type) != 0 || (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_BIT_FIELD (field_decl) = 1;
DECL_SIZE (field_decl) = size; DECL_SIZE (field_decl) = size;
if (!packed && !pos) if (!packed && !pos)
{ {
if (TYPE_ALIGN (record_type) != 0 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); DECL_ALIGN (field_decl) = TYPE_ALIGN (record_type);
else else
DECL_ALIGN (field_decl) = TYPE_ALIGN (field_type); DECL_ALIGN (field_decl) = TYPE_ALIGN (type);
} }
} }
...@@ -2574,14 +2573,14 @@ create_field_decl (tree field_name, tree field_type, tree record_type, ...@@ -2574,14 +2573,14 @@ create_field_decl (tree field_name, tree field_type, tree record_type,
{ {
unsigned int bit_align unsigned int bit_align
= (DECL_BIT_FIELD (field_decl) ? 1 = (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)) if (bit_align > DECL_ALIGN (field_decl))
DECL_ALIGN (field_decl) = bit_align; 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_ALIGN (field_decl) = TYPE_ALIGN (type);
DECL_USER_ALIGN (field_decl) = TYPE_USER_ALIGN (field_type); DECL_USER_ALIGN (field_decl) = TYPE_USER_ALIGN (type);
} }
} }
...@@ -2619,7 +2618,7 @@ create_field_decl (tree field_name, tree field_type, tree record_type, ...@@ -2619,7 +2618,7 @@ create_field_decl (tree field_name, tree field_type, tree record_type,
of a copy. This is the case for true bitfields, but the DECL_BIT_FIELD 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 value we have at this point is not accurate enough, so we don't account
for this here and let finish_record_type decide. */ 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; addressable = 1;
DECL_NONADDRESSABLE_P (field_decl) = !addressable; DECL_NONADDRESSABLE_P (field_decl) = !addressable;
...@@ -2627,40 +2626,39 @@ create_field_decl (tree field_name, tree field_type, tree record_type, ...@@ -2627,40 +2626,39 @@ create_field_decl (tree field_name, tree field_type, tree record_type,
return field_decl; return field_decl;
} }
/* Return a PARM_DECL node. PARAM_NAME is the name of the parameter and /* Return a PARM_DECL node. NAME is the name of the parameter and TYPE is
PARAM_TYPE is its type. READONLY is true if the parameter is readonly its type. READONLY is true if the parameter is readonly (either an In
(either an In parameter or an address of a pass-by-ref parameter). */ parameter or an address of a pass-by-ref parameter). */
tree 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, tree param_decl = build_decl (input_location, PARM_DECL, name, type);
PARM_DECL, param_name, param_type);
/* Honor TARGET_PROMOTE_PROTOTYPES like the C compiler, as not doing so /* Honor TARGET_PROMOTE_PROTOTYPES like the C compiler, as not doing so
can lead to various ABI violations. */ can lead to various ABI violations. */
if (targetm.calls.promote_prototypes (NULL_TREE) if (targetm.calls.promote_prototypes (NULL_TREE)
&& INTEGRAL_TYPE_P (param_type) && INTEGRAL_TYPE_P (type)
&& TYPE_PRECISION (param_type) < TYPE_PRECISION (integer_type_node)) && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
{ {
/* We have to be careful about biased types here. Make a subtype /* We have to be careful about biased types here. Make a subtype
of integer_type_node with the proper biasing. */ of integer_type_node with the proper biasing. */
if (TREE_CODE (param_type) == INTEGER_TYPE if (TREE_CODE (type) == INTEGER_TYPE
&& TYPE_BIASED_REPRESENTATION_P (param_type)) && TYPE_BIASED_REPRESENTATION_P (type))
{ {
tree subtype tree subtype
= make_unsigned_type (TYPE_PRECISION (integer_type_node)); = make_unsigned_type (TYPE_PRECISION (integer_type_node));
TREE_TYPE (subtype) = integer_type_node; TREE_TYPE (subtype) = integer_type_node;
TYPE_BIASED_REPRESENTATION_P (subtype) = 1; TYPE_BIASED_REPRESENTATION_P (subtype) = 1;
SET_TYPE_RM_MIN_VALUE (subtype, TYPE_MIN_VALUE (param_type)); SET_TYPE_RM_MIN_VALUE (subtype, TYPE_MIN_VALUE (type));
SET_TYPE_RM_MAX_VALUE (subtype, TYPE_MAX_VALUE (param_type)); SET_TYPE_RM_MAX_VALUE (subtype, TYPE_MAX_VALUE (type));
param_type = subtype; type = subtype;
} }
else 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; TREE_READONLY (param_decl) = readonly;
return param_decl; return param_decl;
} }
...@@ -3015,14 +3013,14 @@ potential_alignment_gap (tree prev_field, tree curr_field, tree offset) ...@@ -3015,14 +3013,14 @@ potential_alignment_gap (tree prev_field, tree curr_field, tree offset)
return true; return true;
} }
/* Return a LABEL_DECL with LABEL_NAME. GNAT_NODE is used for the position /* Return a LABEL_DECL with NAME. GNAT_NODE is used for the position of
of the decl. */ the decl. */
tree tree
create_label_decl (tree label_name, Node_Id gnat_node) create_label_decl (tree name, Node_Id gnat_node)
{ {
tree label_decl 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; DECL_MODE (label_decl) = VOIDmode;
...@@ -3032,10 +3030,10 @@ create_label_decl (tree label_name, Node_Id gnat_node) ...@@ -3032,10 +3030,10 @@ create_label_decl (tree label_name, Node_Id gnat_node)
return label_decl; return label_decl;
} }
/* Return a FUNCTION_DECL node. SUBPROG_NAME is the name of the subprogram, /* Return a FUNCTION_DECL node. NAME is the name of the subprogram, ASM_NAME
ASM_NAME is its assembler name, SUBPROG_TYPE is its type (a FUNCTION_TYPE its assembler name, TYPE its type (a FUNCTION_TYPE node), PARAM_DECL_LIST
node), PARAM_DECL_LIST is the list of the subprogram arguments (a list of the list of its parameters (a list of PARM_DECL nodes chained through the
PARM_DECL nodes chained through the DECL_CHAIN field). DECL_CHAIN field).
INLINE_STATUS, PUBLIC_FLAG, EXTERN_FLAG and ATTR_LIST are used to set the INLINE_STATUS, PUBLIC_FLAG, EXTERN_FLAG and ATTR_LIST are used to set the
appropriate fields in the FUNCTION_DECL. appropriate fields in the FUNCTION_DECL.
...@@ -3047,16 +3045,14 @@ create_label_decl (tree label_name, Node_Id gnat_node) ...@@ -3047,16 +3045,14 @@ create_label_decl (tree label_name, Node_Id gnat_node)
GNAT_NODE is used for the position of the decl. */ GNAT_NODE is used for the position of the decl. */
tree tree
create_subprog_decl (tree subprog_name, tree asm_name, tree subprog_type, create_subprog_decl (tree name, tree asm_name, tree type, tree param_decl_list,
tree param_decl_list, enum inline_status_t inline_status, enum inline_status_t inline_status, bool public_flag,
bool public_flag, bool extern_flag, bool artificial_p, bool extern_flag, bool artificial_p, bool debug_info_p,
bool debug_info_p, struct attrib *attr_list, struct attrib *attr_list, Node_Id gnat_node)
Node_Id gnat_node)
{ {
tree subprog_decl = build_decl (input_location, FUNCTION_DECL, subprog_name, tree subprog_decl = build_decl (input_location, FUNCTION_DECL, name, type);
subprog_type); tree result_decl
tree result_decl = build_decl (input_location, RESULT_DECL, NULL_TREE, = build_decl (input_location, RESULT_DECL, NULL_TREE, TREE_TYPE (type));
TREE_TYPE (subprog_type));
DECL_ARGUMENTS (subprog_decl) = param_decl_list; DECL_ARGUMENTS (subprog_decl) = param_decl_list;
DECL_ARTIFICIAL (subprog_decl) = artificial_p; DECL_ARTIFICIAL (subprog_decl) = artificial_p;
...@@ -3093,13 +3089,13 @@ create_subprog_decl (tree subprog_name, tree asm_name, tree subprog_type, ...@@ -3093,13 +3089,13 @@ create_subprog_decl (tree subprog_name, tree asm_name, tree subprog_type,
DECL_IGNORED_P (subprog_decl) = 1; DECL_IGNORED_P (subprog_decl) = 1;
TREE_PUBLIC (subprog_decl) = public_flag; TREE_PUBLIC (subprog_decl) = public_flag;
TREE_READONLY (subprog_decl) = TYPE_READONLY (subprog_type); TREE_READONLY (subprog_decl) = TYPE_READONLY (type);
TREE_THIS_VOLATILE (subprog_decl) = TYPE_VOLATILE (subprog_type); TREE_THIS_VOLATILE (subprog_decl) = TYPE_VOLATILE (type);
TREE_SIDE_EFFECTS (subprog_decl) = TYPE_VOLATILE (subprog_type); TREE_SIDE_EFFECTS (subprog_decl) = TYPE_VOLATILE (type);
DECL_ARTIFICIAL (result_decl) = 1; DECL_ARTIFICIAL (result_decl) = 1;
DECL_IGNORED_P (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; DECL_RESULT (subprog_decl) = result_decl;
process_attributes (&subprog_decl, &attr_list, true, gnat_node); process_attributes (&subprog_decl, &attr_list, true, gnat_node);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment