Commit 0cb5c2a7 by Eric Botcazou Committed by Eric Botcazou

gigi.h (create_var_decl_1): Declare.

	* gigi.h (create_var_decl_1): Declare.
	(create_var_decl): Turn into a macro invoking create_var_decl_1.
	(create_true_var_decl): Likewise.
	* utils.c (create_var_decl_1): Make global and reorder parameters.
	(create_var_decl): Delete.
	(create_true_var_decl): Likewise.

From-SVN: r134429
parent c993ae60
2008-04-18 Eric Botcazou <ebotcazou@adacore.com>
* gigi.h (create_var_decl_1): Declare.
(create_var_decl): Turn into a macro invoking create_var_decl_1.
(create_true_var_decl): Likewise.
* utils.c (create_var_decl_1): Make global and reorder parameters.
(create_var_decl): Delete.
(create_true_var_decl): Likewise.
2008-04-17 Eric Botcazou <ebotcazou@adacore.com> 2008-04-17 Eric Botcazou <ebotcazou@adacore.com>
* decl.c (gnat_to_gnu_entity) <object>: Promote the alignment of * decl.c (gnat_to_gnu_entity) <object>: Promote the alignment of
...@@ -564,36 +564,51 @@ extern tree create_type_decl (tree type_name, tree type, ...@@ -564,36 +564,51 @@ extern tree create_type_decl (tree type_name, tree type,
bool artificial_p, bool debug_info_p, bool artificial_p, bool debug_info_p,
Node_Id gnat_node); Node_Id gnat_node);
/* Returns a GCC 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 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 (if provided). TYPE is its data type (a GCC ..._TYPE node). VAR_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. CONST_FLAG is true if this variable is constant, in which case we might
return a CONST_DECL node unless CONST_DECL_ALLOWED_P is false.
PUBLIC_FLAG is true if this definition is to be made visible outside of PUBLIC_FLAG is true if this definition is to be made visible outside of
the current compilation unit. This flag should be set when processing the the current compilation unit. This flag should be set when processing the
variable definitions in a package specification. EXTERN_FLAG is nonzero variable definitions in a package specification.
when processing an external variable declaration (as opposed to a
definition: no storage is to be allocated for the variable here). EXTERN_FLAG is nonzero when processing an external variable declaration (as
opposed to a definition: no storage is to be allocated for the variable).
STATIC_FLAG is only relevant when not at top level. In that case STATIC_FLAG is only relevant when not at top level. In that case
it indicates whether to always allocate storage to the variable. it indicates whether to always allocate storage to the variable.
GNAT_NODE is used for the position of the decl. */ GNAT_NODE is used for the position of the decl. */
extern tree create_var_decl (tree var_name, tree asm_name, tree type, tree
tree var_init, bool const_flag, create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init,
bool public_flag, bool extern_flag, bool const_flag, bool public_flag, bool extern_flag,
bool static_flag, bool static_flag, bool const_decl_allowed_p,
struct attrib *attr_list, Node_Id gnat_node); struct attrib *attr_list, Node_Id gnat_node);
/* Similar to create_var_decl, forcing the creation of a VAR_DECL node. */ /* Wrapper around create_var_decl_1 for cases where we don't care whether
extern tree create_true_var_decl (tree var_name, tree asm_name, tree type, a VAR or a CONST decl node is created. */
tree var_init, bool const_flag, #define create_var_decl(var_name, asm_name, type, var_init, \
bool public_flag, bool extern_flag, const_flag, public_flag, extern_flag, \
bool static_flag, static_flag, attr_list, gnat_node) \
struct attrib *attr_list, Node_Id gnat_node); create_var_decl_1 (var_name, asm_name, type, var_init, \
const_flag, public_flag, extern_flag, \
static_flag, true, attr_list, gnat_node)
/* Wrapper around create_var_decl_1 for cases where a VAR_DECL node is
required. The primary intent is for DECL_CONST_CORRESPONDING_VARs, which
must be VAR_DECLs and on which we want TREE_READONLY set to have them
possibly assigned to a readonly data section. */
#define create_true_var_decl(var_name, asm_name, type, var_init, \
const_flag, public_flag, extern_flag, \
static_flag, attr_list, gnat_node) \
create_var_decl_1 (var_name, asm_name, type, var_init, \
const_flag, public_flag, extern_flag, \
static_flag, false, attr_list, gnat_node)
/* Given a DECL and ATTR_LIST, apply the listed attributes. */ /* Given a DECL and ATTR_LIST, apply the listed attributes. */
extern void process_attributes (tree decl, struct attrib *attr_list); extern void process_attributes (tree decl, struct attrib *attr_list);
......
...@@ -1418,31 +1418,31 @@ create_type_decl (tree type_name, tree type, struct attrib *attr_list, ...@@ -1418,31 +1418,31 @@ create_type_decl (tree type_name, tree type, struct attrib *attr_list,
return type_decl; return type_decl;
} }
/* Helper for create_var_decl and create_true_var_decl. Returns a GCC VAR_DECL /* Return a VAR_DECL or CONST_DECL node.
or CONST_DECL node.
VAR_NAME gives the name of the variable. ASM_NAME is its assembler name 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 (if provided). TYPE is its data type (a GCC ..._TYPE node). VAR_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
return a CONST_DECL node unless CONST_DECL_ALLOWED_FLAG is false. return a CONST_DECL node unless CONST_DECL_ALLOWED_P is false.
PUBLIC_FLAG is true if this definition is to be made visible outside of PUBLIC_FLAG is true if this definition is to be made visible outside of
the current compilation unit. This flag should be set when processing the the current compilation unit. This flag should be set when processing the
variable definitions in a package specification. EXTERN_FLAG is nonzero variable definitions in a package specification.
when processing an external variable declaration (as opposed to a
definition: no storage is to be allocated for the variable here). EXTERN_FLAG is nonzero when processing an external variable declaration (as
opposed to a definition: no storage is to be allocated for the variable).
STATIC_FLAG is only relevant when not at top level. In that case STATIC_FLAG is only relevant when not at top level. In that case
it indicates whether to always allocate storage to the variable. it indicates whether to always allocate storage to the variable.
GNAT_NODE is used for the position of the decl. */ GNAT_NODE is used for the position of the decl. */
static tree tree
create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init, create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init,
bool const_flag, bool const_decl_allowed_flag, bool const_flag, bool public_flag, bool extern_flag,
bool public_flag, bool extern_flag, bool static_flag, bool static_flag, bool const_decl_allowed_p,
struct attrib *attr_list, Node_Id gnat_node) struct attrib *attr_list, Node_Id gnat_node)
{ {
bool init_const bool init_const
...@@ -1464,7 +1464,7 @@ create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init, ...@@ -1464,7 +1464,7 @@ create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init,
/* The actual DECL node. CONST_DECL was initially intended for enumerals /* The actual DECL node. CONST_DECL was initially intended for enumerals
and may be used for scalars in general but not for aggregates. */ and may be used for scalars in general but not for aggregates. */
tree var_decl tree var_decl
= build_decl ((constant_p && const_decl_allowed_flag = build_decl ((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); var_name, type);
...@@ -1528,38 +1528,6 @@ create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init, ...@@ -1528,38 +1528,6 @@ create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init,
return var_decl; return var_decl;
} }
/* Wrapper around create_var_decl_1 for cases where we don't care whether
a VAR or a CONST decl node is created. */
tree
create_var_decl (tree var_name, tree asm_name, tree type, tree var_init,
bool const_flag, bool public_flag, bool extern_flag,
bool static_flag, struct attrib *attr_list,
Node_Id gnat_node)
{
return create_var_decl_1 (var_name, asm_name, type, var_init,
const_flag, true,
public_flag, extern_flag, static_flag,
attr_list, gnat_node);
}
/* Wrapper around create_var_decl_1 for cases where a VAR_DECL node is
required. The primary intent is for DECL_CONST_CORRESPONDING_VARs, which
must be VAR_DECLs and on which we want TREE_READONLY set to have them
possibly assigned to a readonly data section. */
tree
create_true_var_decl (tree var_name, tree asm_name, tree type, tree var_init,
bool const_flag, bool public_flag, bool extern_flag,
bool static_flag, struct attrib *attr_list,
Node_Id gnat_node)
{
return create_var_decl_1 (var_name, asm_name, type, var_init,
const_flag, false,
public_flag, extern_flag, static_flag,
attr_list, gnat_node);
}
/* Return true if TYPE, an aggregate type, contains (or is) an array. */ /* Return true if TYPE, an aggregate type, contains (or is) an array. */
......
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