Commit 2056c5ed by Eric Botcazou Committed by Eric Botcazou

gigi.h (create_var_decl): Adjust prototype.

	* gcc-interface/gigi.h (create_var_decl): Adjust prototype.
	(create_subprog_decl): Likewise.
	* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Rename
	static_p into static_flag and add volatile_flag local variable.
	Do not locally change the type of a volatile object, except for the
	pointed-to type if the object is handled by reference.  Adjust calls
	to create_var_decl.
	<E_Subprogram_Type>: Likewise for const and noreturn subprograms.
	(get_minimal_subprog_decl): Adjust call to create_subprog_decl.
	(elaborate_expression_1): Adjust call to create_var_decl.
	(gnat_to_gnu_field): Minor tweak.
	* gcc-interface/trans.c (gigi): Adjust calls to create_var_decl and
	create_subprog_decl.
	(build_raise_check): Likewise.
	(Subprogram_Body_to_gnu): Likewise.
	(create_temporary): Likewise.
	(Handled_Sequence_Of_Statements_to_gnu): Likewise.
	(Exception_Handler_to_gnu_gcc): Likewise.
	(Compilation_Unit_to_gnu): Likewise.
	(gnat_to_gnu): Likewise.
	* gcc-interface/utils.c (maybe_pad_type): Likewise.
	(create_var_decl): Add VOLATILE_FLAG parameter and handle it.
	(create_subprog_decl): Add CONST_FLAG and VOLATILE_FLAG parameters and
	handle them.

From-SVN: r231065
parent 933a7325
2015-11-30 Eric Botcazou <ebotcazou@adacore.com> 2015-11-30 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/gigi.h (create_var_decl): Adjust prototype.
(create_subprog_decl): Likewise.
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Rename
static_p into static_flag and add volatile_flag local variable.
Do not locally change the type of a volatile object, except for the
pointed-to type if the object is handled by reference. Adjust calls
to create_var_decl.
<E_Subprogram_Type>: Likewise for const and noreturn subprograms.
(get_minimal_subprog_decl): Adjust call to create_subprog_decl.
(elaborate_expression_1): Adjust call to create_var_decl.
(gnat_to_gnu_field): Minor tweak.
* gcc-interface/trans.c (gigi): Adjust calls to create_var_decl and
create_subprog_decl.
(build_raise_check): Likewise.
(Subprogram_Body_to_gnu): Likewise.
(create_temporary): Likewise.
(Handled_Sequence_Of_Statements_to_gnu): Likewise.
(Exception_Handler_to_gnu_gcc): Likewise.
(Compilation_Unit_to_gnu): Likewise.
(gnat_to_gnu): Likewise.
* gcc-interface/utils.c (maybe_pad_type): Likewise.
(create_var_decl): Add VOLATILE_FLAG parameter and handle it.
(create_subprog_decl): Add CONST_FLAG and VOLATILE_FLAG parameters and
handle them.
2015-11-30 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/gigi.h (is_simple_additive_expression): Declare. * gcc-interface/gigi.h (is_simple_additive_expression): Declare.
* gcc-interface/trans.c (struct range_check_info_d): Add DISP and * gcc-interface/trans.c (struct range_check_info_d): Add DISP and
NEG_P fields. NEG_P fields.
......
...@@ -685,8 +685,10 @@ extern tree create_type_decl (tree name, tree type, bool artificial_p, ...@@ -685,8 +685,10 @@ extern tree create_type_decl (tree name, tree type, bool artificial_p,
EXTERN_FLAG is nonzero when processing an external variable declaration (as EXTERN_FLAG is nonzero when processing an external variable declaration (as
opposed to a definition: no storage is to be allocated for the variable). 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 and indicates whether
it indicates whether to always allocate storage to the variable. to always allocate storage to the variable.
VOLATILE_FLAG is true if this variable is declared as volatile.
ARTIFICIAL_P is true if the variable was generated by the compiler. ARTIFICIAL_P is true if the variable was generated by the compiler.
...@@ -696,6 +698,7 @@ extern tree create_type_decl (tree name, tree type, bool artificial_p, ...@@ -696,6 +698,7 @@ extern tree create_type_decl (tree name, tree type, bool artificial_p,
extern tree create_var_decl (tree name, tree asm_name, tree type, tree init, extern tree create_var_decl (tree name, tree asm_name, tree type, tree init,
bool const_flag, bool public_flag, bool const_flag, bool public_flag,
bool extern_flag, bool static_flag, bool extern_flag, bool static_flag,
bool volatile_flag,
bool artificial_p, bool debug_info_p, bool artificial_p, bool debug_info_p,
struct attrib *attr_list, Node_Id gnat_node, struct attrib *attr_list, Node_Id gnat_node,
bool const_decl_allowed_p = true); bool const_decl_allowed_p = true);
...@@ -725,8 +728,8 @@ extern tree create_label_decl (tree name, Node_Id gnat_node); ...@@ -725,8 +728,8 @@ extern tree create_label_decl (tree name, Node_Id gnat_node);
the list of its parameters (a list of PARM_DECL nodes chained through the the list of its parameters (a list of 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, CONST_FLAG, PUBLIC_FLAG, EXTERN_FLAG, VOLATILE_FLAG as well
appropriate fields in the FUNCTION_DECL. as ATTR_LIST are used to set the appropriate fields in the FUNCTION_DECL.
ARTIFICIAL_P is true if the subprogram was generated by the compiler. ARTIFICIAL_P is true if the subprogram was generated by the compiler.
...@@ -736,7 +739,8 @@ extern tree create_label_decl (tree name, Node_Id gnat_node); ...@@ -736,7 +739,8 @@ extern tree create_label_decl (tree name, Node_Id gnat_node);
extern tree create_subprog_decl (tree name, tree asm_name, tree type, extern tree 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 extern_flag, bool const_flag, bool public_flag,
bool extern_flag, bool volatile_flag,
bool artificial_p, bool debug_info_p, bool artificial_p, bool debug_info_p,
struct attrib *attr_list, Node_Id gnat_node); struct attrib *attr_list, Node_Id gnat_node);
......
...@@ -1369,7 +1369,7 @@ maybe_pad_type (tree type, tree size, unsigned int align, ...@@ -1369,7 +1369,7 @@ maybe_pad_type (tree type, tree size, unsigned int align,
= create_var_decl (concat_name (name, "XVZ"), NULL_TREE, sizetype, = create_var_decl (concat_name (name, "XVZ"), NULL_TREE, sizetype,
size_unit, true, global_bindings_p (), size_unit, true, global_bindings_p (),
!definition && global_bindings_p (), false, !definition && global_bindings_p (), false,
true, true, NULL, gnat_entity); false, true, true, NULL, gnat_entity);
TYPE_SIZE_UNIT (record) = size_unit; TYPE_SIZE_UNIT (record) = size_unit;
} }
...@@ -2335,8 +2335,10 @@ create_type_decl (tree name, tree type, bool artificial_p, bool debug_info_p, ...@@ -2335,8 +2335,10 @@ create_type_decl (tree name, tree type, bool artificial_p, bool debug_info_p,
EXTERN_FLAG is true when processing an external variable declaration (as EXTERN_FLAG is true when processing an external variable declaration (as
opposed to a definition: no storage is to be allocated for the variable). 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 and indicates whether
it indicates whether to always allocate storage to the variable. to always allocate storage to the variable.
VOLATILE_FLAG is true if this variable is declared as volatile.
ARTIFICIAL_P is true if the variable was generated by the compiler. ARTIFICIAL_P is true if the variable was generated by the compiler.
...@@ -2347,9 +2349,9 @@ create_type_decl (tree name, tree type, bool artificial_p, bool debug_info_p, ...@@ -2347,9 +2349,9 @@ create_type_decl (tree name, tree type, bool artificial_p, bool debug_info_p,
tree tree
create_var_decl (tree name, tree asm_name, tree type, tree 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 volatile_flag, bool artificial_p,
struct attrib *attr_list, Node_Id gnat_node, bool debug_info_p, struct attrib *attr_list,
bool const_decl_allowed_p) 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. */
...@@ -2406,16 +2408,6 @@ create_var_decl (tree name, tree asm_name, tree type, tree init, ...@@ -2406,16 +2408,6 @@ create_var_decl (tree name, tree asm_name, tree type, tree init,
/* Directly set some flags. */ /* Directly set some flags. */
DECL_ARTIFICIAL (var_decl) = artificial_p; DECL_ARTIFICIAL (var_decl) = artificial_p;
DECL_EXTERNAL (var_decl) = extern_flag; DECL_EXTERNAL (var_decl) = extern_flag;
TREE_CONSTANT (var_decl) = constant_p;
TREE_READONLY (var_decl) = const_flag;
/* We need to allocate static storage for an object with static storage
duration if it isn't external. */
TREE_STATIC (var_decl) = !extern_flag && static_storage;
/* The object is public if it is external or if it is declared public
and has static storage duration. */
TREE_PUBLIC (var_decl) = extern_flag || (public_flag && static_storage);
/* Ada doesn't feature Fortran-like COMMON variables so we shouldn't /* Ada doesn't feature Fortran-like COMMON variables so we shouldn't
try to fiddle with DECL_COMMON. However, on platforms that don't try to fiddle with DECL_COMMON. However, on platforms that don't
...@@ -2441,8 +2433,20 @@ create_var_decl (tree name, tree asm_name, tree type, tree init, ...@@ -2441,8 +2433,20 @@ create_var_decl (tree name, tree asm_name, tree type, tree init,
!= null_pointer_node)) != null_pointer_node))
DECL_IGNORED_P (var_decl) = 1; DECL_IGNORED_P (var_decl) = 1;
if (TYPE_VOLATILE (type)) TREE_CONSTANT (var_decl) = constant_p;
TREE_SIDE_EFFECTS (var_decl) = TREE_THIS_VOLATILE (var_decl) = 1; TREE_READONLY (var_decl) = const_flag;
/* The object is public if it is external or if it is declared public
and has static storage duration. */
TREE_PUBLIC (var_decl) = extern_flag || (public_flag && static_storage);
/* We need to allocate static storage for an object with static storage
duration if it isn't external. */
TREE_STATIC (var_decl) = !extern_flag && static_storage;
TREE_SIDE_EFFECTS (var_decl)
= TREE_THIS_VOLATILE (var_decl)
= TYPE_VOLATILE (type) | volatile_flag;
if (TREE_SIDE_EFFECTS (var_decl)) if (TREE_SIDE_EFFECTS (var_decl))
TREE_ADDRESSABLE (var_decl) = 1; TREE_ADDRESSABLE (var_decl) = 1;
...@@ -3044,8 +3048,8 @@ create_label_decl (tree name, Node_Id gnat_node) ...@@ -3044,8 +3048,8 @@ create_label_decl (tree name, Node_Id gnat_node)
the list of its parameters (a list of PARM_DECL nodes chained through the the list of its parameters (a list of 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, CONST_FLAG, PUBLIC_FLAG, EXTERN_FLAG, VOLATILE_FLAG as well
appropriate fields in the FUNCTION_DECL. as ATTR_LIST are used to set the appropriate fields in the FUNCTION_DECL.
ARTIFICIAL_P is true if the subprogram was generated by the compiler. ARTIFICIAL_P is true if the subprogram was generated by the compiler.
...@@ -3055,8 +3059,9 @@ create_label_decl (tree name, Node_Id gnat_node) ...@@ -3055,8 +3059,9 @@ create_label_decl (tree name, Node_Id gnat_node)
tree tree
create_subprog_decl (tree name, tree asm_name, tree type, tree param_decl_list, create_subprog_decl (tree name, tree asm_name, tree type, tree param_decl_list,
enum inline_status_t inline_status, bool public_flag, enum inline_status_t inline_status, bool const_flag,
bool extern_flag, bool artificial_p, bool debug_info_p, bool public_flag, bool extern_flag, bool volatile_flag,
bool artificial_p, bool debug_info_p,
struct attrib *attr_list, Node_Id gnat_node) struct attrib *attr_list, Node_Id gnat_node)
{ {
tree subprog_decl = build_decl (input_location, FUNCTION_DECL, name, type); tree subprog_decl = build_decl (input_location, FUNCTION_DECL, name, type);
...@@ -3097,10 +3102,11 @@ create_subprog_decl (tree name, tree asm_name, tree type, tree param_decl_list, ...@@ -3097,10 +3102,11 @@ create_subprog_decl (tree name, tree asm_name, tree type, tree param_decl_list,
if (!debug_info_p) if (!debug_info_p)
DECL_IGNORED_P (subprog_decl) = 1; DECL_IGNORED_P (subprog_decl) = 1;
TREE_READONLY (subprog_decl) = TYPE_READONLY (type) | const_flag;
TREE_PUBLIC (subprog_decl) = public_flag; TREE_PUBLIC (subprog_decl) = public_flag;
TREE_READONLY (subprog_decl) = TYPE_READONLY (type); TREE_SIDE_EFFECTS (subprog_decl)
TREE_THIS_VOLATILE (subprog_decl) = TYPE_VOLATILE (type); = TREE_THIS_VOLATILE (subprog_decl)
TREE_SIDE_EFFECTS (subprog_decl) = TYPE_VOLATILE (type); = TYPE_VOLATILE (type) | volatile_flag;
DECL_ARTIFICIAL (result_decl) = 1; DECL_ARTIFICIAL (result_decl) = 1;
DECL_IGNORED_P (result_decl) = 1; DECL_IGNORED_P (result_decl) = 1;
......
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